Code Monkey home page Code Monkey logo

msp's Introduction

MultiWii / Cleanflight / Baseflight Communication Library (C++)

This library implements the MultiWii Serial Protocol (MSP) for communicating with a MultiWii or Cleanflight flight controller (FC) over a serial device. It defines a low-level API for sending+encoding and receiving+decoding MSP messages, and a high-level API with a subscriber pattern to periodically request data from the FC and call callback functions as soon as a message is received.

The communication has been tested with MultiWii 2.4 on an Arduino Nano 3.0 where it can achieve a update rate of approximately 340Hz (for a FC cycle time of 2.8ms / 357Hz) and Betaflight on a Naze32 Rev6 with update rates of max. 1200Hz.

Installation and Test

Linux (Ubuntu / Debian)

  • install asio and ninja:
    sudo apt install -y --no-install-recommends ninja-build libasio-dev
  • check out the source code and use cmake to compile:
    cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release
    cmake --build build
  • run the example program given the path to the serial device:
    ./msp_read_test /dev/ttyUSB0

Windows

Requirements

Build and Test

  • open the Developer Command Prompt for Visual Studio
  • change to the directory where you checked out msp and run:
    cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DASIO_ROOT=C:\asio-1.20.0
    cmake --build build
  • test with serial device:
    msp_read_test.exe COM3

Hardware Setup

You can connect to Arduino or Naze32 boards either by (1) using a built-in USB-to-Serial connector or (2) by direct serial connection (RX->TX, TX->RX, GND->GND, VCC->VCC). The first option is preferable for high transfer rates, as the direct connection is more exposed to transmission errors.

MultiWii

  • the MSP update rate is determined by variable LOOP_TIME in config.h
    • e.g. #define LOOP_TIME 2800 sets the loop time to 2800µs and the update rate to 1/0.0028 s = 357.14 Hz
  • Some Arduino boards with an integrated USB-to-serial converter auto-reset themselves when a serial connection is established. If you send messages to the FC right after opening a connection the FC will miss your request and will not send a response. You can prevent this by either a delay between opening a connection and sending messages, or by disabling the Data Terminal Ready (DTR) line, e.g. via stty -F /dev/ttyUSB0 -hupcl.

Cleanflight / Betaflight

  • change the update rate for the serial task in the range 100 ... 2000Hz
    • e.g. to 2000Hz: set serial_update_rate_hz=2000, then save
  • it might be necessary to increase the serial baudrate in the Ports configuration tab

Sending and Receiving RC commands

  • activate feature RX_MSP
    • via GUI: Configuration -> Receiver -> Receiver Mode -> MSP RX input
    • via CLI: execute feature RX_MSP

Beginning with Cleanflight 2 and Betaflight 3, MSP_SET_RAW_RC messages are ignored on some targets with insufficient flash memory (like the naze32). You can verify this, if MSP_RC messages return an empty list of channels. To activate MSP_SET_RAW_RC messages on these targets, you need to add #define USE_RX_MSP to your target.h, e.g. src/main/target/NAZE/target.h.

FlightContoller API

The FlightContoller API allows the user to send/receive messages from the flight controller. Messages may be queried periodically, or on demand.

Instantiation

Instantiate and setup the FlightController class:

#include <FlightController.hpp>

fcu::FlightController fcu;

// do connection and setup
fcu.connect("/dev/ttyUSB0", 115200);

Periodic request for messages

Messages that need to be queried periodically can be handled automatically using a subscription. This can be done with a class method or a stand-alone function.

Class method pattern

Define a class that holds callback functions to process information of received message. The function signature is void <callback_name>(const <child_of_msp::Message>& ).

class App {
public:
    void onStatus(const msp::Status& status) {
        std::cout<<status;
    }

    void onImu(const msp::Imu& imu) {
        std::cout<<imu;
    }
}

Instantiate class with callbacks and register them to the FCU with the desired update rate in seconds:

App app;

fcu.subscribe(&App::onStatus, &app, 0.1);
fcu.subscribe(&App::onImu, &app, 0.01);

Requests are sent to and processed by the flight controller as fast as possible. It is important to note that the MultiWii FCU only processed a single message per cycle. All subscribed messages therefore share the effective bandwidth of 1/(2800 us) = 357 messages per second.

Lambda pattern

The FlightController::subscribe method is restricted to callbacks which return void and take an argument of const msp::Message&. In order to call a method that doesn't match that signature (maybe it needs additional information), it sometimes is useful to wrap the non-compliant method in a lambda that matches the expected signature.

auto callback = [](const msp::msg::RawImu& imu){
    // ImuSI is not a subclass of msp::Message, so it's not suitable for use as a callback argument
    std::cout << msp::msg::ImuSI(imu, 512.0, 1.0/4.096, 0.92f/10.0f, 9.80665f);
}

fcu.subscribe<msp::msg::RawImu>(callback, 0.1);

Manual sending of messages

Additional messages that are not sent periodically can be dispatched by the method

bool sendMessage(msp::Message &message, const double timeout = 0)

You need to instantiate an instance of the object matching the message you want to send and provide it to the method with an optional timeout. If the timeout paramter is 0, then the method will wait (possibly forever) until a response is received from the flight controller. A strictly positive value will limit the waiting to the specified interval.

msp::Status status;
if (fcu.sendMessage(status) ) {
    // status will contain the values returned by the flight controller
}

msp::SetCalibrationData calibration;
calibration.acc_zero_x = 0;
calibration.acc_zero_y = 0;
calibration.acc_zero_x = 0;
calibration.acc_gain_x = 1;
calibration.acc_gain_y = 1;
calibration.acc_gain_z = 1;
if (fcu.sendMessage(calibration) ) {
    // calibration data has been sent
    // since this message does not have any return data, the values are unchanged
}

If the message is of a type that has a data response from the flight controller, the instance of the message provided to the sendMessage call will contain the values unpacked from the flight controller's response.

msp's People

Contributors

christianrauch avatar emmhaych avatar moldisocks avatar spacehamster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msp's Issues

I have not tested the `MSP_SET_WP` message before. If you provide a minimal source example to reproduce this issue (as plain text, not screenshots of text) I can try to reproduce this in my Betaflight setup.

I have not tested the MSP_SET_WP message before. If you provide a minimal source example to reproduce this issue (as plain text, not screenshots of text) I can try to reproduce this in my Betaflight setup.

You can increase the logger level to debug to get more informative output. Looking at the source code, receiving this error indicates that ok_id is false, which means that the direction byte is !. This is typically the case if the FCU does not support the requested MSP ID.

Your EOF message may further indicate a connection error. A request with an unsupported MSP ID should not cause connection issues. Have you encountered other connection issues over your serial connection?

Can you:

  1. Test this with an MSPv1 connection instead of the MSPv2 connection.
  2. Verify that this message works correctly with the iNav GUI with MSP version 1 and 2 connections.
  3. Test the connection via a USB connection (USB-to-Serial adapter on FCU) to rule out disturbances with unshielded plain serial connections.

Originally posted by @christianrauch in #49 (comment)

Problems with transmitting control commands from the computer to the FC.

Good afternoon I need to transfer control commands from a computer to a flight controller (t-motor f7, betaflight firmware). If I run client_async_test then the data transfer works correctly. But when I run fcu_test or fcu_motors, nothing happens. RX_MSP is enabled in the betaflight configurator. Thanks a lot!

When running fcu_test, the following messages are printed to the console:

Message v1 with ID 100 is not recognised!
Message v1 with ID 116 has wrong CRC! (expected: 161, received: 83)
Message marker 65 is not recognised!
Version marker 66 is not recognised!
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
terminate called after throwing an instance of 'std::runtime_error'
  what():  Cannot get BoxNames!
Aborted (core dumped)

When running fcu_motors, the following messages are displayed in the console:

Message marker terminate called after throwing an instance of 'std::runtime_error'
65 is not recognised!
Version marker 66 is not recognised!
  what():  Cannot get BoxNames!
Aborted (core dumped)

Unusual connection issues with Quadrino Nano

I am attempting to use msp with a Quadrino Nano with MultiWii v2.4
When attempting to make an initial connection confirmation request, if the request is made too soon the board never recieves the command and thus never replies.

The basic request wait from the test suite:

//MSP initialization
 if(msp.request_wait(ident, 1000))
//Other code

In my case, if the request is made any sooner than 1s (1000ms) it never replies with the identification as if it was never even sent in the first place.
I am not entirely sure what the cause of this is, as I would expect that the ident request would simply stay in the buffer until it could be processed and eventually reply even if sent too soon, but that does not seem to the case.
If you have any ideas as to what could cause this it would be very helpful.

MSPv2 support

To recap, iNAV (http://inavflight.com/) has implemented version 2 of the MultiWii Serial Protocol. Somewhere between Cleanflight and iNAV, messages have diverged a bit. This thread is for discussions related to adding MSPv2 support to this msp library.

I am proposing a design that allows the Client class to return pointers to self-identifying objects that mirror the specifics of the message in whatever version of MSP the FC happens to be speaking.

For discussion purposes, we can look at message id 4, BoardInfo. This MSP library expects the following fields:

    std::string identifier;
    uint16_t version;
    uint8_t type;

The iNAV FC software generates the BoardInfo message with the following code:

        sbufWriteData(dst, boardIdentifier, BOARD_IDENTIFIER_LENGTH);
#ifdef USE_HARDWARE_REVISION_DETECTION
        sbufWriteU16(dst, hardwareRevision);
#else
        sbufWriteU16(dst, 0); // No other build targets currently have$
#endif
        // OSD support (for BF compatibility):
        // 0 = no OSD
        // 1 = OSD slave (not supported in INAV)
        // 2 = OSD chip on board
#if defined(USE_OSD) && defined(USE_MAX7456)
        sbufWriteU8(dst, 2);
#else
        sbufWriteU8(dst, 0);
#endif
        // Board communication capabilities (uint8)
        // Bit 0: 1 iff the board has VCP
        // Bit 1: 1 iff the board supports software serial
        uint8_t commCapabilities = 0;
#ifdef USE_VCP
        commCapabilities |= 1 << 0;
#endif
#if defined(USE_SOFTSERIAL1) || defined(USE_SOFTSERIAL2)
        commCapabilities |= 1 << 1;
#endif
        sbufWriteU8(dst, commCapabilities);
        sbufWriteU8(dst, strlen(targetName));
        sbufWriteData(dst, targetName, strlen(targetName));

Clearly, things have changed in the message definitions. I think this means that objects representing decoded messages will need to be able to identify themselves according to version from which they were decoded. My first thought is to add fields to the msp::Message class for representing version (with getter and setter methods). The Client class could have a method returning a pointer to a message, and the program would query the message to identify the version of the particular message in question.

The downside of course is that the program using the msp library has to understand the relationship between version and message fields.

Input is welcome.

Dynbalance

Hey so I can't send RC commands but I can set motor values because I dont have DYNBALANCE included. Since I am using cleanfliht and not MultiWii code, where should i comment out "#define DYNBALANCE" in Multiwii's config.h?

thanks

running example programs against INAV 2.0.1 firmware on Revo

All tests run in Linux environment using the /dev/ttyACM0 device (direct USB connection to FC board)

./msp_connection_test /dev/ttyACM0

Connected to: /dev/ttyACM0
Waiting for flight controller to become ready...
MSP version 231 ready after: 20 ms
<hangs after this, FC LEDs stop flashing>

Unknown reason for failure.

=========================================================

./msp_read_test /dev/ttyACM0

Connected to: /dev/ttyACM0
Connecting FCU...
MSP version 231 ready
ready
#Ident:
MultiWii Version: 231
MSP Version: 0
Type: Quadrocopter X
Capabilities:
    Bind:   OFF
    DynBal: ON
    Flap:   ON
#Status:
Cycle time: 1003 us
I2C errors: 0
Sensors:
    Accelerometer: ON
    Barometer: ON
    Magnetometer: ON
    GPS: OFF
    Sonar: OFF
Active Boxes (by ID): 20
#Imu:
Linear acceleration: -0.0383072, 0.0957681, 9.61511 m/s²
Angular velocity: 0, 0, -0.244141 deg/s
Magnetometer: -10.58, -54.74, -21.804 uT
#Servo:
1500 1500 1500 1500
1500 1500 1500 1500
#Motor:
1000 1000 1000 1000
0 0 0 0
#Rc channels (18) :
1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 
<hangs after this, FC LEDs stop flashing>

This fails on the msp::msg::Attitude, which has had a change to the data structure.

=========================================================

./cleanflight_read_test /dev/ttyACM0

Connected to: /dev/ttyACM0
MSP ready...
#Api Version:
API: 2.2
Protocol: 0

#FC variant:
Identifier: INAV

#FC version:
Version: 2.0.1

#Board Info:
Identifier: REVO
Version: 0
Type: 0

#Build Info:
Date: Oct 31 2018
Time: 18:34:53
Git revision: a04e68a
<hangs after this, FC LEDs stop flashing>

Crashes on msp::msg::RxConfig message, which has more data in INAV.

=========================================================

./client_read_test /dev/ttyACM0

#Ident:
MultiWii Version: 231
MSP Version: 0
Type: Quadrocopter X
Capabilities:
    Bind:   OFF
    DynBal: ON
    Flap:   ON
#Status:
Cycle time: 1002 us
I2C errors: 0
Sensors:
    Accelerometer: ON
    Barometer: ON
    Magnetometer: ON
    GPS: OFF
    Sonar: OFF
Active Boxes (by ID): 20
#Imu:
Linear acceleration: 0, 0.0957681, 9.71088 m/s²
Angular velocity: 0.244141, 0, -0.244141 deg/s
Magnetometer: -10.672, -54.74, -21.804 uT
#Servo:
1500 1500 1500 1500
1500 1500 1500 1500
#Motor:
1000 1000 1000 1000
0 0 0 0
#Rc channels (18) :
1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 
#Attitude:
Ang : 0.5, 0.1 deg
Heading: 259 deg
#Altitude:
Altitude: -0.11 m, var: -0.03 m/s
#Analog:
Battery Voltage: 0 V
Current: 0 A
Power consumption: 0 Ah
RSSI: 0
#Rc Tuning:
Rc Rate: 1
Rc Expo: 0.7
Roll/Pitch Rate: 0.5
Yaw Rate: 0.5
Dynamic Throttle PID: 0.45
Throttle MID: 0
Throttle Expo: 0.5
#PID:
Name      P     | I     | D     |
----------------|-------|-------|
Roll:      4.3	| 4	| 2
Pitch:     5.8	| 5	| 2.2
Yaw:       7	| 4.5	| 0
Altitude:  5	| 0	| 0
Position:  6.5	| 12	| 1
PositionR: 4	| 1.5	| 10
NavR:      0	| 0	| 0
Level:     2	| 1.5	| 7.5
Magn:      6	| 0	| 0
Vel:       10	| 5	| 1
#Box:
0 aux1: ___, aux2: ___, aux3: ___, aux4: ___, 
1 aux1: ___, aux2: _M_, aux3: ___, aux4: ___, 
2 aux1: ___, aux2: ___, aux3: ___, aux4: ___, 
3 aux1: ___, aux2: ___, aux3: ___, aux4: ___, 
#Miscellaneous:
Power Trigger: 1500
Min Throttle: 1150
Max Throttle: 1850
Failsafe Throttle: 1000
Arm Counter: 0
Lifetime: 5
Magnetic Declination: 0 deg
Battery Voltage Scale: 11 V
Battery Warning Level 1: 3.3 V
Battery Warning Level 2: 4.2 V
Battery Critical Level: 3.5 V
#Motor pins:
Motor 0: pin 1
Motor 1: pin 2
Motor 2: pin 3
Motor 3: pin 4
Motor 4: pin 5
Motor 5: pin 6
Motor 6: pin 7
Motor 7: pin 8
#Box names:
0: ARM
1: ANGLE
2: HORIZON
3: TURN ASSIST
4: AIR MODE
5: HEADING HOLD
6: HEADFREE
7: HEADADJ
8: CAMSTAB
9: NAV ALTHOLD
10: SURFACE
11: NAV POSHOLD
12: NAV RTH
13: NAV WP
14: HOME RESET
15: GCS NAV
16: BEEPER
17: OSD SW
18: BLACKBOX
19: KILLSWITCH
20: FAILSAFE
21: CAMERA CONTROL 1
22: CAMERA CONTROL 2
23: CAMERA CONTROL 3
#PID names:
0: ROLL
1: PITCH
2: YAW
3: ALT
4: Pos
5: PosR
6: NavR
7: LEVEL
8: MAG
9: VEL
#Box IDs:
0: 0
1: 1
2: 2
3: 35
4: 29
5: 5
6: 6
7: 7
8: 8
9: 3
10: 33
11: 11
12: 10
13: 28
14: 30
15: 31
16: 13
17: 19
18: 26
19: 38
20: 27
21: 39
22: 40
23: 41
#Servo conf:
Nr. | [min | middle | max] (rate)
0:  | [1000 | 1500 | 2000] (100)
1:  | [0 | 0 | 255] (0)
2:  | [1000 | 1500 | 2000] (100)
3:  | [0 | 0 | 255] (0)
4:  | [1000 | 1500 | 2000] (100)
5:  | [0 | 0 | 255] (0)
6:  | [1000 | 1500 | 2000] (100)
7:  | [0 | 0 | 255] (0)
Message with ID 253 is not recognised!
unsupported: 253
#Debug:
debug1: 0
debug2: 0
debug3: 0
debug4: 0
<hangs after this, FC LEDs still flashing>

Unclear why Client::close() does not return. might be hanging because there is no data on the serial bus?

=========================================================

./client_async_test /dev/ttyACM0
<success>

=========================================================

./fcu_test /dev/ttyACM0
<success>

=========================================================

./fcu_arm /dev/ttyACM0

Cleanflight API 2.2.0 ready
ready after: 87 ms
RX_MSP enabled, restart
terminate called after throwing an instance of 'std::system_error'
  what():  read: Bad file descriptor
Aborted (core dumped)

This is a know issue due to the /dev/ttyACM0 device disappearing when the FC reboots itself. INAV doesn't treat MSP control as a feature, it's just another control source like SERIAL, PWM, or PPM.

=========================================================

./fcu_custom_type /dev/ttyACM0
<success>

=========================================================

./fcu_motors /dev/ttyACM0

Cleanflight API 2.2.0 ready
terminate called after throwing an instance of 'std::system_error'
  what():  read: Bad file descriptor
Aborted (core dumped)

No idea whats going on here.

cannot connect to betaflight fcs

I get this error

#FC variant:
 Identifier: BTFL
#Api Version:
 API: 1.46
 Protocol: 0
#FC version:
 Version: 4.5.0
#Board Info:
 Identifier: S7X2
 Version: 0
 OSD support: 2
 Comms bitmask: 67
 Board Name: STM32F7X2
#Build Info:
 Date: Jan 13 2024
 Time: 14:39:30
 Git revision: f1cbd83
#Status:
 Cycle time: 124 us
 I2C errors: 0
 Sensors:
    Accelerometer: ON
    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
Message marker 65 is not recognised!
Version marker 85 is not recognised!
terminate called after throwing an instance of 'std::runtime_error'
  what():  Cannot get BoxNames!

Issues with tests

When I run the tests in the examples, fcu_custom_type and fcu_test crash when FlightController fcu is deconstructed, and client_read_test stalls when client.stop() is called.

With fcu_custom_type and fcu_test, I suspect that they crash because PeriodicTimer in SubscriptionBase is deleted without stop being called. Calling stop before deleting seems to block until the next timer tick, so maby a timed mutex could stop the timer faster?

As for client_read_test, it seems to be stuck on asio::read_until(port, buffer, "$M"); at Client::processOneMessage, so i'm not quite sure whats going on there.

By the way, I also needed to make a few changes to get it to compile on windows, changing uint to unsigned int and marking the functions in deserialise.hpp as static.

Issue MSP communication Arduino Leonardo

Hi !

I am having issues when trying to communicate over USB from my computer (running Ubuntu 22.04) to a brand new Arduino Leonardo. My LOOP_TIME is 2800, the Baudrate is 115200 on both devices, and my MultiWii firmware is version 2.4.

I am using the master branch from this repository. I have tried adding a delay between opening a connection and sending messages, and disabling the Data Terminal Ready (DTR) line via stty -F /dev/ttyUSB0 -hupcl, however nothing seems to work and I thus doubt this is the issue.

To make the problem more understandable, I have se the LoggingLevel to DEBUG, and I have added the following line of code under the message ID extraction in the function processOneMessageV1
std::cout << "Intercepted message ID: " << size_t(id) << std::endl;

When I connect the Arduino and execute the file client_read_test (4 times to show the issue), here is my output:

terminal

I execute ^C because the algorithm stops and nothing more happens afterward. It seems like the buffer always keeps the older messages (and thus has nothing if the Arduino just got connected i.e. the first run)

I am wondering if this could be an error induced by a new library version. Could you please help me solve this issue ?

asio.hpp not found

I was trying to build the msp library today but compilation failed for not finding asio.hpp.
I have libboost installed correctly, there is a /usr/include/boost/asio.h, but the build system couldn't find it.

I checked the previous commit and it worked fine.

what(): read: End of file, Segmentation Fault on running client_read_test

As referenced in #43, I'm unable to get client_read_test and any of the examples to run.

I'm using a HGLRCF722 running BTFL 4.2.8.
I've tried the same with different FCs on different versions of BTFL 4.x but can't get it to work.

Below is the output while running the executable with log_level_ (DEBUG):

sending message - ID 100
sending: 100 |
packed: 24 4d 3c 0 64 64
write complete: 6 vs 6
processOneMessage on 0 bytes
buffer returned EOF; reading char directly from port
terminate called after throwing an instance of 'std::system_error
what(): read: End of file
Aborted (core dumped)

I've tried other projects such as pymultiwii, YAMSpy and the official configurator and all of them talk to the FC with no issues.

From my crude understanding, it seems like the issue seems to be that processOneMessage tries to parse an empty message and fails, I'd really appreciate some help on debugging this and getting it working

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

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;
    }

SetRc() only works for half a second with Betaflight MSP_OVERRIDE mode

Hi,

I am trying to send RC commands to a SpeedyBee F405 V3 board using a usb-c cable. The board runs Betaflight 4.5.0-RC2.

When running your fcu_motor_test it works fine. Though this is not using SetRc() of course. But this works fine, even for longer durations.
However, when I change the fcu_motor_test to use SetRc() instead of SetMotors(), like this:

...
    while(true)
    {
        fcu.setRc({{1500, 1500, 1100, 1500, 0, 0, 0, 0}});
    }
...

it only works (sometimes not at all) for about 1/2 seconds. After that, the motors turn off and cannot be turned on. They do not stop abruptly though, like sending command "1000" would do, they rather seem to not be getting any signal at all anymore.

To reproduce:
I am using a regular I-BUS Transmitter (Serial RX, not MSP in Receiver tab). But to be able to send MSP messages, I have configured the MSP_OVERRIDE mode to be enabled via a switch.
I arm the drone with one switch, then turn on the MSP_OVERRIDE mode with another switch, and then run the modified fcu_motor_test. Then, if the motors spin at all, they only do so for about half a second.

Debug output

sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57 
write complete: 22 vs 22
sending message - ID 214
sending: 214 | dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 
packed: 24 4d 3c 10 d6 dc 5 dc 5 4c 4 dc 5 0 0 0 0 0 0 0 0 57

Any ideas what might be going on here?

Omnibus F4 Pro V3 with betaflight and raspberry pi MSP

Hi.Thanks for useful source.I have a problem with this. I can take sensor data from usb on computer. Also while I'm using UART6 on omnibus and serial rx/tx on raspberry pi I can take these datas as same.
data

But when I try to run fcu_motors on computer I take this error:
pcfcu

Also when I run it on raspberry pi it throwing this:
RASPBERRYFCU

I activated MSP on betaflight port tab also set MSP RX input at configuration tab.
What can I do about this?
Thanks.

Can't compile version 3.0.0 on Windows

Hi,

I'm trying to compile version 3.0.0 on Windows but keep getting same errors on every machine I tried. Here is the full console log from Developer Command Proment for VS 2017:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>cd C:\GitHub\MSP\build

C:\GitHub\MSP\build>cmake -DASIO_HEADER_PATH=C:\GitHub\asio-1.12.2\include ..
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17134.0 to target Windows 10.0.17763.
-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: C:/GitHub/MSP/build

C:\GitHub\MSP\build>cmake --build .
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  CMake does not need to re-run because C:/GitHub/MSP/build/CMakeFiles/generate.stamp is up-to-date.
  Building Custom Rule C:/GitHub/MSP/CMakeLists.txt
  CMake does not need to re-run because C:/GitHub/MSP/build/CMakeFiles/generate.stamp is up-to-date.
  Client.cpp
  Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
  - add -D_WIN32_WINNT=0x0501 to the compiler command line; or
  - add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.
  Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).
c:\github\msp\inc\msp\ByteVector.hpp(426): warning C4146: unary minus operator applied to unsigned type, result still unsigned [C:\GitHub\MSP\build\mspclient.vcxproj]
C:\GitHub\MSP\src\Client.cpp(10): error C2280: 'std::atomic_flag::atomic_flag(const std::atomic_flag &)': attempting to reference a deleted function [C:\GitHub\MSP\build\mspclient.vcxproj]
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\atomic(169): note: see declaration of 'std::atomic_flag::atomic_flag'
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\atomic(169): note: 'std::atomic_flag::atomic_flag(const std::atomic_flag &)': function was explicitly deleted
  PeriodicTimer.cpp
C:\GitHub\MSP\src\PeriodicTimer.cpp(8): error C2280: 'std::atomic_flag::atomic_flag(const std::atomic_flag &)': attempting to reference a deleted function [C:\GitHub\MSP\build\mspclient.vcxproj]
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\atomic(169): note: see declaration of 'std::atomic_flag::atomic_flag'
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\atomic(169): note: 'std::atomic_flag::atomic_flag(const std::atomic_flag &)': function was explicitly deleted
  Generating Code...

Is it something related to undefined _WIN32_WINNT or the version of Developer Command Prompt must be older?

wrong scaling of raw values in messages

The MSP version 2 support in #28 introduced different methods for de-/serialisation with integrated scaling.

Some of the scalings got lost (e.g. in MSP_ATTITUDE) and some had their meaning inverted (e.g. MSP_ANALOG). The raw battery value (vbat in MSP_ANALOG) specifies a multiplier of 1/10 (unit: 1/10 volt).

In the code, this is using a scale of 0.1:

rc &= data.unpack<uint8_t>(vbat, 0.1);

but this scale is applied as divisor:
val = tmp / scale;

and not as a multiplier. This leads to a 100 fold value of the correct battery voltage (e.g. 410V instead of 4.1V).

@humanoid2050 Could you clarify how you intended to apply the scale? Is it supposed to be a multiplier, in which case we have to change the unpack method, or is it supposed to be a divisor, in which case we have to update the messages?

Error Compiling on RPi Arch

After cloning repo I entered the folder and ran the mkdir build && cd build && cmake ..&& make -j and got this response:
https://pastebin.com/C0sHTZ1y

I installed this version of asio, and have devtools installed.

Im not sure what to do to resolve this, any help would be appreciated.

EDIT: Im running Arch Linux on a Raspberry Pi 3.

Build works fine but compilation gives error

On compiling fcu_test using

gcc fcu_test.cpp

i get the following error

In file included from /usr/include/asio/associated_allocator.hpp:18,
                 from /usr/include/asio.hpp:18,
                 from /usr/include/c++/9/Client.hpp:4,
                 from /usr/include/c++/9/FlightController.hpp:4,
                 from fcu_test.cpp:1:
/usr/include/asio/detail/config.hpp:26:11: fatal error: boost/config.hpp: No such file or directory
   26 | # include <boost/config.hpp>
      |           ^~~~~~~~~~~~~~~~~~
compilation terminated.

I have installed all the necessary msp related header files but still this asio issue pops up. I checked your comment #4 (comment) which says it does not depend on boost then why am i getting this error?

Build failing on ubuntu 22.04

I assume I must be using clang and -Werror is set, but probably should just initialize the tmp vars.

matt@deepdrive:~$ uname -a
Linux deepdrive 5.10.120-tegra #1 SMP PREEMPT Wed Aug 9 15:29:32 CST 2023 aarch64 aarch64 aarch64 GNU/Linux

matt@deepdrive:~/src/msp$ cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release
-- Configuring done
-- Generating done
-- Build files have been written to: /home/matt/src/msp/build

matt@deepdrive:~/src/msp$ cmake --build build
[1/10] Building CXX object CMakeFiles/client_read_test.dir/examples/client_read_test.cpp.o
FAILED: CMakeFiles/client_read_test.dir/examples/client_read_test.cpp.o 
/usr/bin/c++  -DASIO_HAS_CSTDINT -DASIO_HAS_STD_ADDRESSOF -DASIO_HAS_STD_ARRAY -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_TYPE_TRAITS -DASIO_STANDALONE -I../inc/msp -O3 -DNDEBUG   -Wall -Wextra -Wpedantic -Werror -std=c++17 -MD -MT CMakeFiles/client_read_test.dir/examples/client_read_test.cpp.o -MF CMakeFiles/client_read_test.dir/examples/client_read_test.cpp.o.d -o CMakeFiles/client_read_test.dir/examples/client_read_test.cpp.o -c ../examples/client_read_test.cpp
In file included from ../inc/msp/Client.hpp:11,
                 from ../examples/client_read_test.cpp:1:
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::DebugMessage::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  275 |         int8_t tmp;
      |                ^~~
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::PidNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BoxNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors
[2/10] Building CXX object CMakeFiles/msp_fcu.dir/src/FlightController.cpp.o
FAILED: CMakeFiles/msp_fcu.dir/src/FlightController.cpp.o 
/usr/bin/c++  -DASIO_HAS_CSTDINT -DASIO_HAS_STD_ADDRESSOF -DASIO_HAS_STD_ARRAY -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_TYPE_TRAITS -DASIO_STANDALONE -Dmsp_fcu_EXPORTS -I../inc/msp -O3 -DNDEBUG -fPIC   -Wall -Wextra -Wpedantic -Werror -std=c++17 -MD -MT CMakeFiles/msp_fcu.dir/src/FlightController.cpp.o -MF CMakeFiles/msp_fcu.dir/src/FlightController.cpp.o.d -o CMakeFiles/msp_fcu.dir/src/FlightController.cpp.o -c ../src/FlightController.cpp
In file included from ../inc/msp/Client.hpp:11,
                 from ../inc/msp/FlightController.hpp:4,
                 from ../src/FlightController.cpp:1:
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BuildInfo::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  275 |         int8_t tmp;
      |                ^~~
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::FcVariant::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BoardInfo::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BoxNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors
[3/10] Building CXX object CMakeFiles/client_async_test.dir/examples/client_async_test.cpp.o
FAILED: CMakeFiles/client_async_test.dir/examples/client_async_test.cpp.o 
/usr/bin/c++  -DASIO_HAS_CSTDINT -DASIO_HAS_STD_ADDRESSOF -DASIO_HAS_STD_ARRAY -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_TYPE_TRAITS -DASIO_STANDALONE -I../inc/msp -O3 -DNDEBUG   -Wall -Wextra -Wpedantic -Werror -std=c++17 -MD -MT CMakeFiles/client_async_test.dir/examples/client_async_test.cpp.o -MF CMakeFiles/client_async_test.dir/examples/client_async_test.cpp.o.d -o CMakeFiles/client_async_test.dir/examples/client_async_test.cpp.o -c ../examples/client_async_test.cpp
In file included from ../inc/msp/Client.hpp:11,
                 from ../examples/client_async_test.cpp:1:
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::DebugMessage::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  275 |         int8_t tmp;
      |                ^~~
../inc/msp/ByteVector.hpp: In member function ‘void msp::client::Subscription<T>::decode(msp::ByteVector&) const [with T = msp::msg::DebugMessage]’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BoxNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::PidNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors
[4/10] Building CXX object CMakeFiles/fcu_test.dir/examples/fcu_test.cpp.o
FAILED: CMakeFiles/fcu_test.dir/examples/fcu_test.cpp.o 
/usr/bin/c++  -DASIO_HAS_CSTDINT -DASIO_HAS_STD_ADDRESSOF -DASIO_HAS_STD_ARRAY -DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_TYPE_TRAITS -DASIO_STANDALONE -I../inc/msp -O3 -DNDEBUG   -Wall -Wextra -Wpedantic -Werror -std=c++17 -MD -MT CMakeFiles/fcu_test.dir/examples/fcu_test.cpp.o -MF CMakeFiles/fcu_test.dir/examples/fcu_test.cpp.o.d -o CMakeFiles/fcu_test.dir/examples/fcu_test.cpp.o -c ../examples/fcu_test.cpp
In file included from ../inc/msp/Client.hpp:11,
                 from ../inc/msp/FlightController.hpp:4,
                 from ../examples/fcu_test.cpp:1:
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::DebugMessage::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  275 |         int8_t tmp;
      |                ^~~
../inc/msp/ByteVector.hpp: In member function ‘void msp::client::Subscription<T>::decode(msp::ByteVector&) const [with T = msp::msg::DebugMessage]’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::BoxNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
../inc/msp/ByteVector.hpp: In member function ‘virtual bool msp::msg::PidNames::decode(const msp::ByteVector&)’:
../inc/msp/ByteVector.hpp:275:16: error: ‘tmp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.```

possible bug in msp_msg.hpp

I think I may have found a problem in msp_msg.hpp

The definition for SetRawGPS inherits from Request. I think it should inherit from Response shouldn't it? It has an encode method that matches the Response base class pattern.

EOF when running client_read_test

I am unable to read using client_read_test (i.e. test the project out) when running this on my Odroid (running Ubuntu 18.04.2). I am unfortunately just getting started with C++, so my debugging skills are not up to speed.

I am connecting to a flight controller via USB running Betaflight 3.2.5:

  • under ports Configuration/MSP is activated for USB VCP and at 115200
  • I've done this via GUI: Configuration -> Receiver -> Receiver Mode -> MSP RX input

I set the serial update rate to 2000Hz:

root@odroid:~/msp/build# ./client_read_test /dev/ttyACM0
buffer returned EOF; reading char directly from port
terminate called after throwing an instance of 'std::system_error'
  what():  read: End of file
Aborted

I set the serial update rate to 1000Hz:

root@odroid:~/msp/build# ./client_read_test /dev/ttyACM0
Message v1 with ID 100 has wrong CRC! (expected: 120, received: 39)
unsupported: 100
Message marker 13 is not recognised!
Version marker 10 is not recognised!
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port
buffer returned EOF; reading char directly from port

So it seems that it's related to the update rate?

Let me know what other info I need to provide you,
Thanks!

How to verify feature RX_MSP for my board

Hello
I have problem when doing MSP_SET_RAW_RC via USB serial for my OMNIBUS F4 board (cleanflight)
added #define USE_RX_MSP to src/main/target/OMNIBUSF4/target.h
recompiled cleanflight 2.5 for my board, and flashed it to my board successfully. most MSP get codes work, but MSP_SET_RAW_RC function looks not working yet, how can I see if MSP_SET_RAW_RC is enabled for my board ?
Thanks a lot!

Motors keep spinning

Hi! Thanks for the last quick response. I am now trying to run fcu_motors and I keep getting a bunch of CRC not matching errors. I am using a naze32 with cleanflight 1.11 firmware installed on it. The receiver option right now is RX_MSP and pretty much every time I try to run any of the examples I get something like "CRC not matching: Message 101, expected CRC 123, received CRC 168"

Also, when I try to run fcu_motors, the motors start, but then they won't stop even when the program has stopped running. I dont have Dynbalance included, is that necessary? Without Dynbalance will I not be able to send correct commands?

Thanks :)

Can't use MSP on quadrino

Hi,

I can't connect my quadrino nano to MSP. The client_read_test always returns the following:

./client_read_test / dev / ttyUSB0
message failed to send
unsupported: 100
message failed to send
unsupported: 101
message failed to send
unsupported: 102
message failed to send
unsupported: 103
message failed to send
unsupported: 104
message failed to send
unsupported: 105
message failed to send
unsupported: 108
message failed to send
unsupported: 109
message failed to send
unsupported: 110
message failed to send
unsupported: 111
message failed to send
unsupported: 112
message failed to send
unsupported: 113
message failed to send
unsupported: 114
message failed to send
unsupported: 115
message failed to send
unsupported: 116
message failed to send
unsupported: 117
message failed to send
unsupported: 119
message failed to send
unsupported: 120
message failed to send
unsupported: 253
message failed to send
unsupported: 254
PROGRAM COMPLETE

I've enabled #define USE_MSP_WP in multiwii 2.4 code.

Having trouble reaching desired read speeds

Hi, thanks for the library. I'm trying to read IMU and motor commands on my Betaflight board from a Linux computer, but I'm having trouble getting over 100Hz. I have set serial_update_rate_hz=2000. Increasing the baudrate to 1000000 decreased throughput and 500000 was better.

Do you think this just a result of a poor cable? I will eventually want to write control commands to the board so speeding up the connection is really important for me.

Incorrect GPS longitude value??

I was trying to get the current GPS of my vehicle streamed to my laptop and when I look at my longitude, I am getting about 312 degrees while I should be getting -117 degrees. I am fairly sure that I am just missing something simple.

Thanks!
marsall

No executables after cmake

Hi after I ran cmake in the msp directory it says "build files have been written to /home/pi/msp" but when i go into the examples directory i can't run ./msp_read_test

cmake is supposed to make this and link the headers right?

Thanks

How to write CLI commands to eeprom

It's so good to see the codes to read data from fc.
It would be nice to have a way to write data (to eeprom) instead of the xxflight configurator
Because I want to set multiple options in a time, like:
set serial_update_rate_hz=1000
feature RX_MSP
map AERT1234
...
maybe more in future, so it'll be convenient to have a script to do this without bothering it manually
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.