Commit cd5cdf04 authored by Sergi Hernandez's avatar Sergi Hernandez

Modified the slave example to simulate an RX28 Servo.

parent e024ac80
......@@ -3,6 +3,16 @@
#include <iostream>
#include <boost/bind.hpp>
#define SERVO_MEMORY_SIZE 50
unsigned char rx28_servo_data[SERVO_MEMORY_SIZE]={0x1c,0x00,0x00,0x01,0x22,0xFA,0x00,0x00,
0xFF,0x03,0x00,0x50,0x3C,0xBE,0xFF,0x03,
0x02,0x24,0x24,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x20,0x20,0x00,0x00,
0x00,0x00,0xFF,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x78,0x19,0x00,0x00,0x00,0x00,
0x20,0x00};
std::string serial="A400gavm";
void on_ping(void)
......@@ -12,7 +22,11 @@ void on_ping(void)
unsigned char on_read(unsigned short int address, unsigned short int length, unsigned char *data)
{
unsigned char num;
std::cout << "read operation at address " << address << " with length " << length << std::endl;
for(unsigned int i=address,num=0;i<address+length || i<SERVO_MEMORY_SIZE;i++,num++)
data[num]=rx28_servo_data[i];
return 0x00;
}
......@@ -21,6 +35,9 @@ unsigned char on_write(unsigned short int address, unsigned short int length, un
{
std::cout << "wrirte operation at address " << address << " with length " << length << std::endl;
for(unsigned int i=address,num=0;i<address+length || i<SERVO_MEMORY_SIZE;i++,num++)
rx28_servo_data[i]=data[num];
return 0x00;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment