Manual to the micro controller: https://drive.google.com/file/d/0B8PmY6nhQadKSVc5OE04c3ZJaFU/view?usp=sharing , where page 18-19 introduces the serial communication protocol.
The micro controller on Amazon: https://www.amazon.com/Channel-Controller-Bluetooth-steering-Raspberry/dp/B018YP228A/ref=sr_1_1_sspa?keywords=usb+servo+controller&qid=1562646724&s=industrial&sr=1-1-spons&psc=1
The microcontroller is connected via USB to a Raspberry Pi 3b+.
I am on my Raspberry with Python 3.5.3 and pySerial. In python command line I can write:
>>>import serial # pySerial
>>>sc = serial.Serial('/dev/ttyAMA0', baudrate=9600)
(I found the port name ttyAMA0
using dmesg | grep tty
)
Then
>>>sc.write(b'') # Instantly returns 0
0
>>>recovery = [0xFF, 0x0b, 0x00, 0x00, 0x00] # Any 5 bytes command packet.
>>>sc.write(bytes(recovery)) # Stalls until write_timeout
I have been unsuccessful in sending any actual packet to the port, as when i write, the python command line never returns, unless I specify a write_timeout, in which case it raises the serial.serialutil.SerialTimeoutException
. Does anyone have experience with controlling microcontrollers with python? Should I be using pySerial at all?
I can control it through the GUI of the Motor Control software, but I want a sort of API (Python highly preferred) to automate things.
Motor Control software with GUI: https://drive.google.com/file/d/0B8PmY6nhQadKR013T2hDQXJxaWc/view?usp=sharing
Update: Read also stalls.
>>>sc.read() # Stalls
sc.write('G91 \n'.encode('ascii'))
, no issues there. \$\endgroup\$/dev/ttyS0
instead of/dev/ttyAMA0
. Since this is different on different Pis you can use the alias/dev/serial0
to select the primary UART. \$\endgroup\$