Newer
Older
packetData[port_num].txpacket_[PKT_PARAMETER0 + 2] = DXL_LOBYTE(data_length);
packetData[port_num].txpacket_[PKT_PARAMETER0 + 3] = DXL_HIBYTE(data_length);
for (_s = 0; _s < param_length; _s++)
packetData[port_num].txpacket_[PKT_PARAMETER0 + 4 + _s] = packetData[port_num].data_write_[_s];
TxRxPacket2(port_num);
}
void BulkReadTx2(int port_num, UINT16_T param_length)
{
UINT8_T _s;
int _i;
packetData[port_num].communication_result_ = COMM_TX_FAIL;
packetData[port_num].txpacket_ = (UINT8_T *)realloc(packetData[port_num].txpacket_, param_length + 10);
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
// 10: HEADER0 HEADER1 HEADER2 RESERVED ID LEN_L LEN_H INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_ID] = BROADCAST_ID;
packetData[port_num].txpacket_[PKT_LENGTH_L] = DXL_LOBYTE(param_length + 3); // 3: INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_LENGTH_H] = DXL_HIBYTE(param_length + 3); // 3: INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_INSTRUCTION] = INST_BULK_READ;
for (_s = 0; _s < param_length; _s++)
packetData[port_num].txpacket_[PKT_PARAMETER0 + _s] = packetData[port_num].data_write_[_s];
TxPacket2(port_num);
if (packetData[port_num].communication_result_ == COMM_SUCCESS)
{
int _wait_length = 0;
for (_i = 0; _i < param_length; _i += 5)
_wait_length += DXL_MAKEWORD(packetData[port_num].data_write_[_i + 3], packetData[port_num].data_write_[_i + 4]) + 10;
SetPacketTimeout(port_num, (UINT16_T)_wait_length);
}
}
void BulkWriteTxOnly2(int port_num, UINT16_T param_length)
{
UINT8_T _s;
packetData[port_num].communication_result_ = COMM_TX_FAIL;
packetData[port_num].txpacket_ = (UINT8_T *)realloc(packetData[port_num].txpacket_, param_length + 10);
// 10: HEADER0 HEADER1 HEADER2 RESERVED ID LEN_L LEN_H INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_ID] = BROADCAST_ID;
packetData[port_num].txpacket_[PKT_LENGTH_L] = DXL_LOBYTE(param_length + 3); // 3: INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_LENGTH_H] = DXL_HIBYTE(param_length + 3); // 3: INST CRC16_L CRC16_H
packetData[port_num].txpacket_[PKT_INSTRUCTION] = INST_BULK_WRITE;
for (_s = 0; _s < param_length; _s++)
packetData[port_num].txpacket_[PKT_PARAMETER0 + _s] = packetData[port_num].data_write_[_s];
TxRxPacket2(port_num);
}