CmdMessenger + PyCmdMessenger on teensy

Status
Not open for further replies.

mqlo

Member
Hi,

I'm trying to run the CmdMessenger and PyCmdMessenger combo example from https://github.com/harmsm/PyCmdMessenger/tree/master/examples on my Teensy 3.6.

This is on Ubuntu.

I get the following error on the Python side:

Code:
$ python3 python-basic.py 
Connecting to arduino on /dev/ttyACM0... done.
('my_name_is', ['Bob'], 1511212793.2456436)
Traceback (most recent call last):
  File "python-basic.py", line 31, in <module>
    msg = c.receive()
  File "/usr/local/lib/python3.5/dist-packages/PyCmdMessenger/PyCmdMessenger.py", line 284, in receive
    received.append(self._recv_methods[arg_format_list[i]](f))
  File "/usr/local/lib/python3.5/dist-packages/PyCmdMessenger/PyCmdMessenger.py", line 551, in _recv_int
    return struct.unpack(self.board.int_type,value)[0]
struct.error: unpack requires a bytes object of length 2

Any suggestions?
 
I have the same issue, using a teensy 3.5 and windows. Did you resolve it? The only thing I caught was that the baud rates were mismatched at first, but I still get the error after making them the same.
 
I have the same issue, using a teensy 3.5 and windows. Did you resolve it? The only thing I caught was that the baud rates were mismatched at first, but I still get the error after making them the same.


I didn't resolve it and just abandoned the project. Sorry.
 
I am not a python person, but was wondering what version of python you were running? Sounds like it was developed for 3.x version of python, but also gives you a link to go to if you are tying to run on 2.7. I noticed on my windows machine if I try to run python, it says version 2.7.3

I remember some other recent thread where someone was having issues when they were trying to convert a program between two different versions of python.
 
I overcame the (first part) of the problem by realizing I had the wrong sketch on the teensy. In the \PyCmdMessenger\test\pingpong_arduino, the main.cpp is actually the sketch to upload. It threw me off since it was a .ino extension. Now all the types of size 4 bytes are passing. I am still having trouble with kDouble, which should be 8 bytes for both my python system and teensy micro. Struct.unpack() is looking for 4 byte buffer for some reason.

KurtE- no that is not the problem, I'm on the latest python.
 
Right- I did see that configuration and I have the types reflecting the bytes from here:
https://forum.pjrc.com/threads/36658-datatypes-bit-depth
So I use
Code:
 double_bytes = 8
, and
Code:
struct.calcsize('d')
= 8 on my machine.
Also,
Code:
struct.calcsize('@d')
and
Code:
struct.calcsize('=d')
are both 8 on my machine.
I need to enter a debug session I think and examine what pycommandmessenger is receiving and why it is expecting 4 bytes, not 8.
 
Did anyone get this working? I'm trying to use CmdMessenger now with a Teensy3.2 and PyCmdMessenger. I'm pulling my hair out.
The library seems to be exactly what I need. Send messages in both directions with arguments and callback functions. The only problem is that I can't even get the turn-on-LED example to work. If anyone has working Arduino and Python code I'd really appreciate seeing it.
Thanks,
Chris
 
Status
Not open for further replies.
Back
Top