So I'm trying to send commands to my Roomba Discovery via python serial and it works fine as long as it only requires the command opcode. The commands that require additional data bytes (like specific movement or music) don't seem to be working. It's an old roomba, however, I do not believe that is the issue as I am able to use Java based applications like RoombaMidi2 from hackingroomba.com. The code below works fine to have the roomba clean for 5 seconds then sleep:
import serial
import time
import struct
ser = serial.Serial("/dev/ttyUSB0", 57600)
ser.write(bytes([128])) # 128: start command
ser.write(bytes([131])) # 131: Safe Mode
time.sleep (0.25)
ser.write(bytes([135])) # 135: clean command
time.sleep (5)
ser.write(bytes([133])) # 133: puts robot to sleep
ser.close()
But if I want to do a move command it doesn't seem to work. I've tried:
ser.write(bytes([137]))
ser.write(bytearray([255, 56]))
ser.write(bytearray([1, 244]))
No error, but it doesn't do anything. I've also tried sending it as 1 byte array:
ser.write(bytearray([137, 255, 56, 1, 244]))
Any idea on what I'm doing wrong?