Page 47 - Hacking Roomba
P. 47
28 Part I — Interfacing
Table 2-3 Continued
Command Opcode Hexadecimal Values Number of Data Bytes
SPOT 134 0x86 0
CLEAN 135 0x87 0
MAX 136 0x88 0
DOCK 143 0x8F 0
DRIVE 137 0x89 4
MOTORS 138 0x8A 1
LEDS 139 0x8B 3
SONG 140 0x8C 2+2N
PLAY 141 0x8D 1
SENSORS 142 0x8E 1
Since a command can take a varying number of arguments, a buggy program sending ROI
commands may run into the problem where it’s sending bytes in the wrong sequence, with
Roomba interpreting a data byte as a command byte or vice-versa. The only way around this is
to either power off-and-on the robot or to send the same single-byte command (like START)
enough times to ensure that Roomba really did interpret the byte as a START command. In
practice, especially when using an API library like RoombaComm, this isn’t a big concern
unless the serial connection is severed in the middle of a command sequence.
The largest possible command is a full SONG command at 35 bytes long. This is a rare com-
mand usually. The second largest command is the DRIVE command at five bytes (one byte for
the command byte itself and four data bytes).
To better understand how to use bits and bytes, see the sidebar “Setting and Clearing Bits” later
in this chapter.
ROI Mode Commands
These commands are the ones that alter the operating mode of the Roomba. The START com-
mand is required for any Roomba hacking through the ROI and the CONTROL command is
required for any meaningful hacking. The following list provides an overview of each of the
mode commands:
START: The START command starts the ROI. Roomba must be in the on mode through
either the Power button or toggling the DD line. If the robot is in an unknown state or
you need to reset it, send the START command a few times to put Roomba in a known
state. This command puts Roomba in the passive mode.