LionelDarras / PySimpleBGC

PySimpleBGC is a python project which aims to allow communication with Basecam Simple-BGC coontroller board
GNU General Public License v3.0
7 stars 8 forks source link

can't make examples to work #4

Closed lweingart closed 3 years ago

lweingart commented 3 years ago

Hello,

I have a gimbal with the SimpleBGC controller linked to a jetson nano that I try to control with python, and I just found this PySimpleBGC. However, I cannot make it work, trying to follow the steps described here: https://pysimplebgc.readthedocs.io/en/latest/#api-reference

Here are my steps: The gimbal is plugged to the Jetson nano via USB cable and is detected as /dev/ttyUSB0. Then I open the python shell and this is what happens:

Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysimplebgc import SimpleBGC32
>>> device = SimpleBGC32.from_url('serial:/dev/ttyUSB0:38400:8N1')
>>> device.getcmdlist()
['CMD_BOARD_INFO', 'CMD_BOARD_INFO_3', 'CMD_REALTIME_DATA_3', 'CMD_REALTIME_DATA_4']

up until now, everything looks good, but then:

>>> device.setcmd('CMD_BOARD_INFO', "")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 181, in setcmd
    unpack_data = self._unpack_response(cmdid, respdata)
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 319, in _unpack_response
    raise BadCmdException()
pysimplebgc.device.BadCmdException
>>> device.setcmd('CMD_BOARD_INFO_3', "")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 181, in setcmd
    unpack_data = self._unpack_response(cmdid, respdata)
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 319, in _unpack_response
    raise BadCmdException()
pysimplebgc.device.BadCmdException
>>> device.setcmd('CMD_BOARD_INFO', 'name')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 177, in setcmd
    cmdid, pack_cmd = self._pack_command(cmdtype, cmddata)
  File "/home/jetson/.virtualenvs/droning_micr/lib/python3.6/site-packages/pysimplebgc/device.py", line 293, in _pack_command
    raise BadCmdException()
pysimplebgc.device.BadCmdException

Well, you get the idea, I cannot seem to get anything useful that way. Could you help me finding what I'm doing wrong, or anything that could help me, I would really appreciate.

Thank you very much in advance Best

lweingart commented 3 years ago

Hi again,

I was actually able to make the examples to work by setting the baud rate to 115200. Meaning, changing this line:

>>> device = SimpleBGC32.from_url('serial:/dev/ttyUSB0:38400:8N1')

with this line:

>>> device = SimpleBGC32.from_url('serial:/dev/ttyUSB0:115200:8N1')

Cheers