I’m trying to send ASCII characters from an NVIDIA Jetson nano to a Roboteq motor controller. (MAX3232 to convert the logic level)
- Using Pyserial for serial comm.
- Sending 3 variable values for motor control, eg: ‘!VAR 1 250’ (‘!’ Is the start of the command)
Following is a snippet of the code,
ser = serial.Serial(
port = '/dev/ttyTHS1',
baudrate = 115200,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
timeout = 1
command = ‘!VAR 1 250’ + ’ \r’
data = ser.readline().decode().strip()
Coming to the issue,
‘!VAR 1 250’ does not pass the same value when sent every time.
Data string gets corrupted.
Is this because I am sending the ASCII command the wrong way? Is it being transferred in bytes?
I feel I am missing something here. How do we send an ASCII string via pyserial?
Have you disabled nvgetty as suggested in
Jetson Nano how to use UART on /ttyTHS1 - #2 by gtj
If not, please disable it and try again.
Yes. I have disabled it. The same string does not transfer always, gets corrupted sometimes.
Does Pyserial only transfer bytes through UART?
How do we send strings?
Pyserial sends strings, and it sounds like you are on the right track if you are getting a string to send at all. Loop the tx/rx and run the pyserial test program provided in the docs. change the port to ‘/dev/ttyTHS1’ where it says ‘LOOP://…’. I presume it will pass all the tests but 2… that being the dtr/cts tests.
Additionally, if you have a scope or a Diligent Analog Discovery board, you can pass the uart through the spy and see the data being transferred in real time.
For your application, make sure the peripheral device uses 3.3V logic levels or it will need a level converter.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.