christianrauch / msp

Implementation of the MultiWii Serial Protocol (MSP) for MultiWii and Cleanflight flight controller
http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol
GNU Lesser General Public License v3.0
72 stars 26 forks source link

timeout for fcu.connect() never happens when no FCU is hooked up #58

Closed catkira closed 3 months ago

catkira commented 4 months ago

I have set my timeout to 1.0, but the connect() function gets stuck indefinately if no FCS is hooked up. If I enable output for the connect() routine, it stops after these lines

#Status:
 Cycle time: <unset> us
 I2C errors: <unset>
 Sensors:
    Accelerometer: OFF
    Barometer: OFF
    Magnetometer: OFF
    GPS: OFF
    Sonar: OFF
 Active Boxes (by ID):
#Ident:
 MultiWii Version: <unset>
 MSP Version: <unset>
 Type: UNDEFINED
 Capabilities:
    Bind:   OFF
    DynBal: OFF
    Flap:   OFF

so it probably gets stuck somewhere in this code

    // get boxes
    initBoxes();

    // determine channel mapping
    if(getFwVariant() == msp::FirmwareVariant::MWII) {
        // default mapping
        for(uint8_t i(0); i < msp::msg::MAX_MAPPABLE_RX_INPUTS; ++i) {
            channel_map_[i] = i;
        }
    }
    else {
        // get channel mapping from MSP_RX_MAP
        msp::msg::RxMap rx_map(fw_variant_);
        client_.sendMessage(rx_map, timeout);
        if(print_info) std::cout << rx_map;
        channel_map_ = rx_map.map;
    }
christianrauch commented 4 months ago

Can you provide a reproducible example that shows the hanging? I tried this with an USB-Serial-Adapter (067b:2303 Prolific Technology, Inc. PL2303 Serial Port / Mobile Action MA-8910P) but cannot reproduce a hang.

However, I encountered a different error when looking up the flight controller variant. This has been addressed in https://github.com/christianrauch/msp/pull/61. Does this PR fix your issue too?

catkira commented 4 months ago

I will try a bit tomorrow. I am using a verilog uart (UARTLITE) from Xilinx on a ZYNQ fpga.