5.f. Serial Script Commands

The Maestro has several serial commands for controlling the execution of the user script.

Stop Script

Compact protocol: 0xA4
Pololu protocol: 0xAA, device number, 0x24

This command causes the script to stop, if it is currently running.

Restart Script at Subroutine

Compact protocol: 0xA7, subroutine number
Pololu protocol: 0xAA, device number, 0x27, subroutine number

This command starts the script running at a location specified by the subroutine number argument. The subroutines are numbered in the order they are defined in your script, starting with 0 for the first subroutine. The first subroutine is sent as 0x00 for this command, the second as 0x01, etc. To find the number for a particular subroutine, click the “View Compiled Code…” button and look at the list below. Subroutines used this way should not end with the RETURN command, since there is no place to return to — instead, they should contain infinite loops or end with a QUIT command.

Restart Script at Subroutine with Parameter

Compact protocol: 0xA8, subroutine number, parameter low bits, parameter high bits
Pololu protocol: 0xAA, device number, 0x28, subroutine number, parameter low bits, parameter high bits

This command is just like the Restart Script at Subroutine command, except it loads a parameter on to the stack before starting the subroutine. Since data bytes can only contain 7 bits of data, the parameter must be between 0 and 16383.

Get Script Status

Compact protocol: 0xAE
Pololu protocol: 0xAA, device number, 0x2E
Response: 0x00 if the script is running, 0x01 if the script is stopped

This command responds with a single byte, either 0 or 1, to indicate whether the script is running (0) or stopped (1). Using this command together with the commands above, you can activate a sequence stored on the Maestro and wait until the sequence is complete before moving on to the next step of your program.