3
$\begingroup$

I want to get telemetry data from my flight controller (Matek F405-CTR) and send control commands to it via MSP protocol.

I've already configured UART3 port on Matek in Inav configurator (look at pic).

UART3 port configuration

Then I connected usb-serial converter (CP2102) to Matek on UART3 port for testing. So that, Matek controller is defined as COM3 on my PC and CP2102 as COM4

Matek and CP2102 connection

But when I'am trying to run simple test from pyMultiWii lib I get nothing from Matek controller neither from CP2102. I've tried this test for COM3 and COM4 ports as well.

#!/usr/bin/env python

"""show-attitude.py: Script to ask the MultiWii Board attitude and print it."""

from pymultiwii import MultiWii
from sys import stdout

if __name__ == "__main__":

    board = MultiWii("COM4")
    #board = MultiWii("COM3")
    try:
        while True:
            board.getData(MultiWii.ATTITUDE)
            #print board.attitude #uncomment for regular printing

            # Fancy printing (might not work on windows...)
            message = "angx = {:+.2f} \t angy = {:+.2f} \t heading = {:+.2f} \t elapsed = {:+.4f} \t".format(float(board.attitude['angx']),float(board.attitude['angy']),float(board.attitude['heading']),float(board.attitude['elapsed']))
            stdout.write("\r%s" % message )
            stdout.flush()
            # End of fancy printing
    except Exception as error:
        print("Error on Main: "+str(error))

enter image description here

May be I'am doing something wrong? I've already read this post, but it dosn't help me. Any advice will be appreciated!

$\endgroup$

1 Answer 1

0
$\begingroup$

Not exactly an answer, but I am unable to post a comment here.

Firstly, verify your baud rates (for Windows, make sure you have set the right baud rate in your device manager/properties window as well). Try using the MultiWiiConf, which is a GUI to monitor your flight data and check if it is able to establish communication with your flight controller board.

Coming back to your code, what happens when you try to retrieve the MSP_IDENT frame as mentioned here? I have written an alternate simple script here for Python, use the requestFrame method with the frame ID and see if it helps.

EDIT: It looks like the pyMultiWii library you are currently using supports only MSPv1. If your board uses MSPv2, the protocol is slightly different as in the link you have already posted in the question. You can use my library as refernece mentioned above to make changes as per MSPv2 protocol and give it a try.

$\endgroup$
4
  • $\begingroup$ After some checking seems that pyMultiWii lib doesnt work.. The is a problem in sendSMD() function, I've checked it separately. An error occurs in this function: "ord() expected string of length 1, but int found". So that, everything after this line of code doesn't work. Actually, getData() in example that I've posted doesn't work, it puts just pre-defined self parameters, to be exact - zeros. Thats why I have zeros in the output. $\endgroup$ Commented Jul 19, 2018 at 17:08
  • $\begingroup$ Sorry, it's working, but only with Python 2.7... Same functions do not work in Python 3. $\endgroup$ Commented Jul 19, 2018 at 21:05
  • $\begingroup$ On stack exchange, it is better to edit your question to add requested information @mr.boris rather than adding more comments. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. If all of the information needed to answer the question is contained within it, the comments can be tidied up (deleted). $\endgroup$
    – Mark Booth
    Commented Aug 14, 2018 at 17:09
  • $\begingroup$ On StackExchange answers need to answer the question. If you wish to discuss a question or answer you can use Robotics Chat, while if you have an idea for how a question can be improved, you will be able to comment when you have comment privileges. Please review How to Ask and tour for more information on how StackExchange works. If you edit your response to look like an answer, rather than a comment, it is more likely that people will find it useful, vote it up, and give you the reputation you need to be able to write comments. $\endgroup$
    – Mark Booth
    Commented Aug 14, 2018 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.