0

Similar to this question I am trying to use Python to find a certain relay board on a Raspberry Pi when the port could be switching between /dev/ttyACM0 and /dev/ttyACM1 each time the pi is powered up, I have 2 boards connected to the pi and they can switch back and forth as to which is 0 and which is 1. I am using a Numato 16 channel relay, which comes with an ID that can be get and set on each board, however I am having trouble reading the results. Numato's website says that id get returns an 8 byte string with the id, and elsewhere I read that the return will have a couple of extra characters due to how they concatenate and format their echos and returns.

My script looks like this

import serial
request = serial.Serial("/dev/ttyACM0", 19200, timeout=1)
request.write(b"id get\n\r")
request.read(20)

However, instead of getting the result b'\n\rid get\n\rXXXXXXXX' I am getting the result b'\nid get\n\n\r>'

When I ran with the 'ver' command I was able to get the results returned properly.

vencaslac
  • 2,727
  • 1
  • 18
  • 29
Daishozen
  • 109
  • 4

0 Answers0