Skip to content
Snippets Groups Projects
Commit 8ea315f7 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Moved the new packet buffer to the slave data structure to avoid errors when...

Moved the new packet buffer to the slave data structure to avoid errors when the packet is not fully received in a cycle.
parent cbe7d928
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,11 @@ typedef struct TDynamixelSlave
*
*/
unsigned char rx_buffer[MAX_DYN_SLAVE_RX_BUFFER_LEN];
/**
* \brief
*
*/
unsigned char current_packet[MAX_DYN_SLAVE_RX_BUFFER_LEN];
/**
* \brief
*
......
......@@ -224,20 +224,20 @@ unsigned char dyn_slave_get_next_packet(TDynamixelSlave *slave,unsigned char *pa
void dyn_slave_loop(TDynamixelSlave *slave)
{
unsigned char send_status=0xFF,error,data_in[MAX_DYN_SLAVE_RX_BUFFER_LEN],data_out[MAX_DYN_SLAVE_RX_BUFFER_LEN];
unsigned char send_status=0xFF,error,data_out[MAX_DYN_SLAVE_RX_BUFFER_LEN]={0};
unsigned short int length,i;
if(slave!=0x00000000)
{
while(dyn_slave_get_next_packet(slave,data_in))
while(dyn_slave_get_next_packet(slave,slave->current_packet))
{
// check address
for(i=0;i<slave->num_slave_devices;i++)
{
if(slave->version==DYN_VER1)
send_status=dyn_v1_slave_loop(slave->slave_devices[i],data_in,&error,(unsigned char *)&length,data_out);
send_status=dyn_v1_slave_loop(slave->slave_devices[i],slave->current_packet,&error,(unsigned char *)&length,data_out);
else
send_status=dyn_v2_slave_loop(slave->slave_devices[i],data_in,&error,&length,data_out);
send_status=dyn_v2_slave_loop(slave->slave_devices[i],slave->current_packet,&error,&length,data_out);
if(send_status==0x01)
dyn_slave_send_status_packet(slave,slave->slave_devices[i]->address,error,length,data_out,slave->slave_devices[i]->return_delay);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment