Skip to content

Commit a9e7229

Browse files
author
Kei
committed
Fixed sync/bulk functions & bulk example.
1 parent a9fa5dc commit a9e7229

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

examples/advanced/bulk_read_write_raw/bulk_read_write_raw.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ void setup() {
153153

154154

155155
// Fill the members of structure for bulkWrite using internal packet buffer
156-
br_infos.packet.p_buf = nullptr;
157-
br_infos.packet.is_completed = false;
156+
bw_infos.packet.p_buf = nullptr;
157+
bw_infos.packet.is_completed = false;
158158
bw_infos.p_xels = info_xels_bw;
159159
bw_infos.xel_count = 0;
160160

src/utility/master.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ Master::syncRead(InfoSyncReadInst_t* p_info, uint32_t timeout_ms)
608608
packet_buf_cap = packet_buf_capacity_;
609609
}
610610

611+
if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_SYNC_READ){
612+
p_info->packet.is_completed = false;
613+
}
614+
611615
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
612616
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
613617
DXL_INST_SYNC_READ, 0, p_packet_buf, packet_buf_cap);
@@ -635,9 +639,6 @@ Master::syncRead(InfoSyncReadInst_t* p_info, uint32_t timeout_ms)
635639
}
636640
}
637641
}
638-
}else if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_SYNC_READ){
639-
p_info->packet.is_completed = false;
640-
err = DXL_LIB_ERROR_NOT_INITIALIZED;
641642
}
642643

643644
if(err == DXL_LIB_OK){
@@ -699,6 +700,10 @@ Master::syncWrite(InfoSyncWriteInst_t* p_info)
699700
packet_buf_cap = packet_buf_capacity_;
700701
}
701702

703+
if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_SYNC_WRITE){
704+
p_info->packet.is_completed = false;
705+
}
706+
702707
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
703708
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
704709
DXL_INST_SYNC_WRITE, 0, p_packet_buf, packet_buf_cap);
@@ -736,9 +741,6 @@ Master::syncWrite(InfoSyncWriteInst_t* p_info)
736741
}
737742
}
738743
}
739-
}else if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_SYNC_WRITE){
740-
p_info->packet.is_completed = false;
741-
err = DXL_LIB_ERROR_NOT_INITIALIZED;
742744
}
743745

744746
if(err == DXL_LIB_OK){
@@ -786,6 +788,10 @@ Master::bulkRead(InfoBulkReadInst_t* p_info, uint32_t timeout_ms)
786788
packet_buf_cap = packet_buf_capacity_;
787789
}
788790

791+
if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_BULK_READ){
792+
p_info->packet.is_completed = false;
793+
}
794+
789795
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
790796
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
791797
DXL_INST_BULK_READ, 0, p_packet_buf, packet_buf_cap);
@@ -822,9 +828,6 @@ Master::bulkRead(InfoBulkReadInst_t* p_info, uint32_t timeout_ms)
822828
}
823829
}
824830
}
825-
}else if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_BULK_READ){
826-
p_info->packet.is_completed = false;
827-
err = DXL_LIB_ERROR_NOT_INITIALIZED;
828831
}
829832

830833
if(err == DXL_LIB_OK){
@@ -886,6 +889,10 @@ Master::bulkWrite(InfoBulkWriteInst_t* p_info)
886889
packet_buf_cap = packet_buf_capacity_;
887890
}
888891

892+
if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_BULK_WRITE){
893+
p_info->packet.is_completed = false;
894+
}
895+
889896
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
890897
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
891898
DXL_INST_BULK_WRITE, 0, p_packet_buf, packet_buf_cap);
@@ -915,9 +922,6 @@ Master::bulkWrite(InfoBulkWriteInst_t* p_info)
915922
}
916923
}
917924
}
918-
}else if(p_info->packet.p_buf == nullptr && info_tx_packet_.inst_idx != DXL_INST_BULK_WRITE){
919-
p_info->packet.is_completed = false;
920-
err = DXL_LIB_ERROR_NOT_INITIALIZED;
921925
}
922926

923927
if(err == DXL_LIB_OK){

0 commit comments

Comments
 (0)