This library is a library for controlling a motor by Sabertooth2x25(Packetized Serial Mode).
Diff: Sabertooth2x25.cpp
- Revision:
- 1:b8f62e733e56
- Parent:
- 0:3f784e34179c
- Child:
- 2:6a3a047c1ce1
--- a/Sabertooth2x25.cpp Wed Sep 21 16:55:39 2011 +0000 +++ b/Sabertooth2x25.cpp Fri Sep 23 13:06:59 2011 +0000 @@ -5,15 +5,12 @@ } void Sabertooth2x25::sendCommand(int address, int command, int data) { - tx_buf[0] = (unsigned char)address; - tx_buf[1] = (unsigned char)command; - tx_buf[2] = (unsigned char)data; - tx_buf[3] = (unsigned char)((address + command + data) & 0x7F);// checksum + checksum_ = (unsigned char)((address + command + data) & 0x7F);// checksum - device_.putc(tx_buf[0]); - device_.putc(tx_buf[1]); - device_.putc(tx_buf[2]); - device_.putc(tx_buf[3]); + device_.putc((unsigned char)address); + device_.putc((unsigned char)command); + device_.putc((unsigned char)data); + device_.putc(checksum_); } void Sabertooth2x25::forward_motor_1(int device_address, int speed) {