Introducing myself / a parser-generator I've written for MSP

Post Reply
simondlevy
Posts: 7
Joined: Sun Jul 12, 2015 7:14 am

Introducing myself / a parser-generator I've written for MSP

Post by simondlevy »

Hi everyone,

My name's Simon, and I teach computer science / robotics at a small liberal arts college. One of the many cool things about this job is being able to try out new technology and develop new software for it. After building and flying quadrotors with all the popular open-source flight controllers (Pixhawk, OpenPilot, KK2) I fell in love with the Naze32 platform, because of the simple, elegant board layout (big pins = big win for a butterfingers like me!) and the incredible ease-of-use of the Baseflight configurator. Being able to see the raw receiver inputs so clearly was a big eye-opener for me, and allowed me to write Arduino code to send modulated PWM signals into the Naze. This led me to wonder whether I could also communicate with the Naze over its UART and/or USB port, which led me to the msp.js code in Baseflight. So now I'm happily flying our little 250mm quadrotor with the Naze, developing code for the Naze, and hope eventually to be able to contribute to the firmware in Baseflight and/or Cleanflight.

Meanwhile, if you're into this kind of thing, my students and I have written a little parser-generator that takes JSON specifications of MSP messages and auto-generates code for parsing and serializing them in Python, Java, and C++. I've tested it with Attitude message (#108) and am hoping that MSP has messages for input demands (sending pitch/roll/yaw/throttle demands over the UART from a Teensy board or ODROID). If anyone's done that, or if you have suggestions for MSPPG (maybe outputting C# or JavaScript or something), I'd love to hear from you. My eventual goal is to have a swarm of Naze-equipped micro-copters talking to each other with MSP over an XBee network. Meanwhile, it's great to see that there's an active Multiwii community, and I hope to be able to contribute more.

brm
Posts: 287
Joined: Mon Jun 25, 2012 12:00 pm

Re: Introducing myself / a parser-generator I've written for

Post by brm »

nice work!
i'd rather work with your parser frontend as with the orignal logic.

ffuri
Posts: 4
Joined: Mon Jul 27, 2015 2:43 pm

Re: Introducing myself / a parser-generator I've written for

Post by ffuri »

thank you for your working Simon.

I have some questions. I use WINDOWS system, and i follow your order on github. Installed setup.py and after that, ' msppg.py example.json ' I put this command on CMD.

C:\Users\bit\Desktop\MSPPG-master\MSPPG-master>msppg.py example.json
Traceback (most recent call last):
File "C:\Users\bit\Desktop\MSPPG-master\MSPPG-master\msppg.py", line 508, in <module>
argname = clean(clean(json.dumps(arg.keys())))
File "C:\Python34\lib\json\__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "C:\Python34\lib\json\encoder.py", line 192, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Python34\lib\json\encoder.py", line 250, in iterencode
return _iterencode(o, 0)
File "C:\Python34\lib\json\encoder.py", line 173, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: dict_keys(['ID']) is not JSON serializable

But CMD show like that.
so, I really want to know how to use your generator and see the example complete MSPPG output.

Thank you

norem
Posts: 2
Joined: Tue Jul 01, 2014 6:46 am

Re: Introducing myself / a parser-generator I've written for

Post by norem »

I was getting the same errors using python 3 but 2 seems to output code without errors, I was under the impression that the com port could be changed in the generated code but not seeing where in the c++ code ?

simondlevy
Posts: 7
Joined: Sun Jul 12, 2015 7:14 am

Re: Introducing myself / a parser-generator I've written for

Post by simondlevy »

Sorry for the delay, guys! I thought I was set up to get auto-generated emails whenever anyone posted to this thread, but I wasn't.

Anyway, yes: the problem was that MSPPG worked with Python2 but not Python3. I have changed that, tested the code, and updated the repository. So it will now work with Python3 but not Python2. At this point I don't have time to support backward compatibility.

As for the COM port in the C++ version: Since serial I/O is so easy in Python and so difficult in C/C++ (in my experience at least), the only serial I/O examples I provide are Python and Arduino.

I have also added a Pure C version for those wishing to run the code on a Naze32 or other STM32 flight controller.

Post Reply