Skip to content

Commit e7d99e4

Browse files
author
Kei
committed
Fixed some bugs in sync/bulk raw APIs.
1 parent a67c5fc commit e7d99e4

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

src/utility/master.cpp

+46-31
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,15 @@ Master::syncRead(InfoSyncReadInst_t* p_info, uint32_t timeout_ms)
600600
return 0;
601601
}
602602

603+
if(p_info->packet.p_buf != nullptr){
604+
p_packet_buf = p_info->packet.p_buf;
605+
packet_buf_cap = p_info->packet.buf_capacity;
606+
}else{
607+
p_packet_buf = p_packet_buf_;
608+
packet_buf_cap = packet_buf_capacity_;
609+
}
610+
603611
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
604-
if(p_info->packet.p_buf != nullptr){
605-
p_packet_buf = p_info->packet.p_buf;
606-
packet_buf_cap = p_info->packet.buf_capacity;
607-
}else{
608-
p_packet_buf = p_packet_buf_;
609-
packet_buf_cap = packet_buf_capacity_;
610-
}
611612
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
612613
DXL_INST_SYNC_READ, 0, p_packet_buf, packet_buf_cap);
613614
if(err == DXL_LIB_OK){
@@ -628,7 +629,8 @@ Master::syncRead(InfoSyncReadInst_t* p_info, uint32_t timeout_ms)
628629
err = end_make_dxl_packet(&info_tx_packet_);
629630
if(err == DXL_LIB_OK){
630631
p_info->packet.gen_length = info_tx_packet_.generated_packet_length;
631-
p_info->packet.is_completed = true;
632+
p_info->packet.is_completed = true;
633+
p_info->is_info_changed = false;
632634
}
633635
}
634636
}
@@ -655,6 +657,8 @@ Master::syncRead(InfoSyncReadInst_t* p_info, uint32_t timeout_ms)
655657
break;
656658
}
657659
}
660+
}else{
661+
p_info->packet.is_completed = false;
658662
}
659663
last_lib_err_ = err;
660664

@@ -687,14 +691,15 @@ Master::syncWrite(InfoSyncWriteInst_t* p_info)
687691
return 0;
688692
}
689693

694+
if(p_info->packet.p_buf != nullptr){
695+
p_packet_buf = p_info->packet.p_buf;
696+
packet_buf_cap = p_info->packet.buf_capacity;
697+
}else{
698+
p_packet_buf = p_packet_buf_;
699+
packet_buf_cap = packet_buf_capacity_;
700+
}
701+
690702
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
691-
if(p_info->packet.p_buf != nullptr){
692-
p_packet_buf = p_info->packet.p_buf;
693-
packet_buf_cap = p_info->packet.buf_capacity;
694-
}else{
695-
p_packet_buf = p_packet_buf_;
696-
packet_buf_cap = packet_buf_capacity_;
697-
}
698703
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
699704
DXL_INST_SYNC_WRITE, 0, p_packet_buf, packet_buf_cap);
700705
if(err == DXL_LIB_OK){
@@ -726,6 +731,7 @@ Master::syncWrite(InfoSyncWriteInst_t* p_info)
726731
if(err == DXL_LIB_OK){
727732
p_info->packet.gen_length = info_tx_packet_.generated_packet_length;
728733
p_info->packet.is_completed = true;
734+
p_info->is_info_changed = false;
729735
}
730736
}
731737
}
@@ -738,6 +744,8 @@ Master::syncWrite(InfoSyncWriteInst_t* p_info)
738744
if(err == DXL_LIB_OK){
739745
p_port_->write(p_packet_buf, p_info->packet.gen_length);
740746
ret = true;
747+
}else{
748+
p_info->packet.is_completed = false;
741749
}
742750
last_lib_err_ = err;
743751

@@ -770,15 +778,15 @@ Master::bulkRead(InfoBulkReadInst_t* p_info, uint32_t timeout_ms)
770778
return 0;
771779
}
772780

773-
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
781+
if(p_info->packet.p_buf != nullptr){
782+
p_packet_buf = p_info->packet.p_buf;
783+
packet_buf_cap = p_info->packet.buf_capacity;
784+
}else{
785+
p_packet_buf = p_packet_buf_;
786+
packet_buf_cap = packet_buf_capacity_;
787+
}
774788

775-
if(p_info->packet.p_buf != nullptr){
776-
p_packet_buf = p_info->packet.p_buf;
777-
packet_buf_cap = p_info->packet.buf_capacity;
778-
}else{
779-
p_packet_buf = p_packet_buf_;
780-
packet_buf_cap = packet_buf_capacity_;
781-
}
789+
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
782790
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
783791
DXL_INST_BULK_READ, 0, p_packet_buf, packet_buf_cap);
784792
if(protocol_ver_idx_ == 1 && err == DXL_LIB_OK){
@@ -810,6 +818,7 @@ Master::bulkRead(InfoBulkReadInst_t* p_info, uint32_t timeout_ms)
810818
if(err == DXL_LIB_OK){
811819
p_info->packet.gen_length = info_tx_packet_.generated_packet_length;
812820
p_info->packet.is_completed = true;
821+
p_info->is_info_changed = false;
813822
}
814823
}
815824
}
@@ -835,6 +844,8 @@ Master::bulkRead(InfoBulkReadInst_t* p_info, uint32_t timeout_ms)
835844
break;
836845
}
837846
}
847+
}else{
848+
p_info->packet.is_completed = false;
838849
}
839850
last_lib_err_ = err;
840851

@@ -867,14 +878,15 @@ Master::bulkWrite(InfoBulkWriteInst_t* p_info)
867878
return 0;
868879
}
869880

881+
if(p_info->packet.p_buf != nullptr){
882+
p_packet_buf = p_info->packet.p_buf;
883+
packet_buf_cap = p_info->packet.buf_capacity;
884+
}else{
885+
p_packet_buf = p_packet_buf_;
886+
packet_buf_cap = packet_buf_capacity_;
887+
}
888+
870889
if(p_info->packet.is_completed == false || p_info->is_info_changed == true){
871-
if(p_info->packet.p_buf != nullptr){
872-
p_packet_buf = p_info->packet.p_buf;
873-
packet_buf_cap = p_info->packet.buf_capacity;
874-
}else{
875-
p_packet_buf = p_packet_buf_;
876-
packet_buf_cap = packet_buf_capacity_;
877-
}
878890
err = begin_make_dxl_packet(&info_tx_packet_, DXL_BROADCAST_ID, protocol_ver_idx_,
879891
DXL_INST_BULK_WRITE, 0, p_packet_buf, packet_buf_cap);
880892
if(err == DXL_LIB_OK){
@@ -898,7 +910,8 @@ Master::bulkWrite(InfoBulkWriteInst_t* p_info)
898910
err = end_make_dxl_packet(&info_tx_packet_);
899911
if(err == DXL_LIB_OK){
900912
p_info->packet.gen_length = info_tx_packet_.generated_packet_length;
901-
p_info->packet.is_completed = true;
913+
p_info->packet.is_completed = true;
914+
p_info->is_info_changed = false;
902915
}
903916
}
904917
}
@@ -910,6 +923,8 @@ Master::bulkWrite(InfoBulkWriteInst_t* p_info)
910923
if(err == DXL_LIB_OK){
911924
p_port_->write(p_packet_buf, p_info->packet.gen_length);
912925
ret = true;
926+
}else{
927+
p_info->packet.is_completed = false;
913928
}
914929
last_lib_err_ = err;
915930

0 commit comments

Comments
 (0)