andreiciubotariu / multiwii_python Goto Github PK
View Code? Open in Web Editor NEWPython 3 (or 2) implementation of MSP (http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol)
License: Apache License 2.0
Python 3 (or 2) implementation of MSP (http://www.multiwii.com/wiki/index.php?title=Multiwii_Serial_Protocol)
License: Apache License 2.0
I added a couple of prints so i could try and figure out what it's doing. and i'm getting exceptions. I'm new to the MSP protocol and i'm working with 2.1 of inav which apparently uses the v2 version of MSP.
I'm trying to get GPS data from the FC that's all i'm really interested in. So right now the main looks like the following:
i'm assuming the "container" section is the reply from the FC to the IDENT? When I tried the program unmodified, i got the exception in the second code section (under the dashes).
Any help would be appreciated in getting at the GPS data
if __name__ == '__main__':
transport = Serial(port='/dev/ttyACM0',
baudrate=115200,
timeout=5)
msp = MSP(transport, initialization_delay=15)
stop_gps_updates(msp)
print("Getting IDENT")
print(msp.request(MSP_IDENT))
counter = 0
print("Getting RAW_GPS")
while True:
print(counter)
print(msp.receive_data(msp.get_response(MSP_RAW_GPS)))
print(msp.request(MSP_ALTITUDE))
counter += 1
time.sleep(1)
Waiting 15 seconds for board to wake up
Done waiting
Sending MSP len 10
Getting IDENT
Sending MSP len 6
Container:
preamble = b'$M' (total 2)
direction = b'>' (total 1)
size = 7
message_id = 100
version = 231
multitype = 3
msp_version = 0
capability = 2147483708
crc = 59
Getting RAW_GPS
0
Attempted to parse b''
Traceback (most recent call last):
File "msp.py", line 327, in <module>
print(msp.receive_data(msp.get_response(MSP_RAW_GPS)))
File "msp.py", line 293, in receive_data
return self.parse(received_data, parser)
File "msp.py", line 275, in parse
parsed_data = template.parse(data)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 304, in parse
return self.parse_stream(io.BytesIO(data), **contextkw)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 316, in parse_stream
return self._parsereport(stream, context, "(parsing)")
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 1979, in _parse
subobj = sc._parsereport(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 2468, in _parse
return self.subcon._parsereport(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 2538, in _parse
obj = self.subcon._parsereport(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 856, in _parse
return stream_read(stream, length)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 86, in stream_read
raise StreamError("stream read less then specified amount, expected %d, found %d" % (length, len(data)))
construct.core.StreamError: stream read less then specified amount, expected 2, found 0
charlesb@GroundStation:~/src/msp/multiwii_python$ python3 msp.py
Waiting 15 seconds for board to wake up
Done waiting
Sending MSP len 10
Sending MSP len 6
Container:
preamble = b'$M' (total 2)
direction = b'>' (total 1)
size = 7
message_id = 100
version = 231
multitype = 3
msp_version = 0
capability = 2147483708
crc = 59
0
Drop flotation device (timed)
Sending MSP len 7
Attempted to parse b'$M>H4\x00'
Traceback (most recent call last):
File "msp.py", line 364, in <module>
msp.read_ack(MSP_SET_RC_OVERRIDES)
File "msp.py", line 251, in read_ack
ack = self.receive_data(MSP_ACK)
File "msp.py", line 293, in receive_data
return self.parse(received_data, parser)
File "msp.py", line 275, in parse
parsed_data = template.parse(data)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 304, in parse
return self.parse_stream(io.BytesIO(data), **contextkw)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 316, in parse_stream
return self._parsereport(stream, context, "(parsing)")
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 1979, in _parse
subobj = sc._parsereport(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 2468, in _parse
return self.subcon._parsereport(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 328, in _parsereport
obj = self._parse(stream, context, path)
File "/home/charlesb/.local/lib/python3.6/site-packages/construct/core.py", line 2540, in _parse
raise ConstError("parsing expected %r but parsed %r" % (self.value, obj))
construct.core.ConstError: parsing expected 0 but parsed 72
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.