@@ -531,7 +531,7 @@ Master::clear(uint8_t id, uint8_t option, uint32_t ex_option, uint32_t timeout_m
531531// (Protocol 1.0) Not Supported
532532// (Protocol 2.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol2/#sync-read
533533bool
534- Master::beginSyncRead (uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info)
534+ Master::beginSetupSyncRead (uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info)
535535{
536536 bool ret = false ;
537537 DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -574,7 +574,7 @@ Master::beginSyncRead(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sy
574574}
575575
576576bool
577- Master::addSyncReadID (uint8_t id, InfoSyncBulkInst_t *p_sync_info, bool flag_end_add )
577+ Master::addSyncReadID (uint8_t id, InfoSyncBulkInst_t *p_sync_info)
578578{
579579 bool ret = false ;
580580 DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -599,23 +599,48 @@ Master::addSyncReadID(uint8_t id, InfoSyncBulkInst_t *p_sync_info, bool flag_end
599599
600600 if (err == DXL_LIB_OK){
601601 p_info->id_cnt ++;
602- if (flag_end_add == true ){
603- err = end_make_dxl_packet (&info_tx_packet_);
604- if (err == DXL_LIB_OK){
605- p_info->packet_length = info_tx_packet_.generated_packet_length ;
606- p_info->is_complete_packet = true ;
607- ret = true ;
608- }
609- }else {
610- ret = true ;
611- }
602+ ret = true ;
612603 }
613604
614605 last_lib_err_ = err;
615606
616607 return ret;
617608}
618609
610+ bool
611+ Master::endSetupSyncRead (InfoSyncBulkInst_t *p_sync_info)
612+ {
613+ bool ret = false ;
614+ DXLLibErrorCode_t err = DXL_LIB_OK;
615+ InfoSyncBulkInst_t *p_info = &info_sync_bulk_;
616+
617+ // Parameter exception handling
618+ if (protocol_ver_idx_ != 2 ){
619+ err = DXL_LIB_ERROR_NOT_SUPPORTED;
620+ }else if (info_tx_packet_.inst_idx != DXL_INST_SYNC_READ){
621+ err = DXL_LIB_ERROR_NOT_INITIALIZED;
622+ }
623+ if (err != DXL_LIB_OK){
624+ last_lib_err_ = err;
625+ return false ;
626+ }
627+
628+ if (p_sync_info != nullptr ){
629+ p_info = p_sync_info;
630+ }
631+
632+ if (info_tx_packet_.inst_idx == DXL_INST_SYNC_READ){
633+ err = end_make_dxl_packet (&info_tx_packet_);
634+ if (err == DXL_LIB_OK){
635+ p_info->packet_length = info_tx_packet_.generated_packet_length ;
636+ p_info->is_complete_packet = true ;
637+ ret = true ;
638+ }
639+ }
640+
641+ return ret;
642+ }
643+
619644uint8_t
620645Master::sendSyncRead (uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBulkInst_t *p_sync_info)
621646{
@@ -663,6 +688,8 @@ Master::sendSyncRead(uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBu
663688 if (rxStatusPacket (&p_recv_buf[i*p_info->addr_len ],
664689 recv_buf_capacity-i*p_info->addr_len , 3 ) != nullptr ){
665690 recv_cnt++;
691+ }else {
692+ break ;
666693 }
667694 }
668695
@@ -674,7 +701,7 @@ Master::sendSyncRead(uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBu
674701// (Protocol 1.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol1/#sync-write
675702// (Protocol 2.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol2/#sync-write
676703bool
677- Master::beginSyncWrite (uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info)
704+ Master::beginSetupSyncWrite (uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sync_info)
678705{
679706 bool ret = false ;
680707 DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -717,7 +744,7 @@ Master::beginSyncWrite(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_s
717744}
718745
719746bool
720- Master::addSyncWriteData (uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync_info, bool flag_end_add )
747+ Master::addSyncWriteData (uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync_info)
721748{
722749 bool ret = false ;
723750 DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -743,16 +770,7 @@ Master::addSyncWriteData(uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync
743770 err = add_param_to_dxl_packet (&info_tx_packet_, (uint8_t *)p_data, p_info->addr_len );
744771 if (err == DXL_LIB_OK){
745772 p_info->id_cnt ++;
746- if (flag_end_add == true ){
747- err = end_make_dxl_packet (&info_tx_packet_);
748- if (err == DXL_LIB_OK){
749- p_info->packet_length = info_tx_packet_.generated_packet_length ;
750- p_info->is_complete_packet = true ;
751- ret = true ;
752- }
753- }else {
754- ret = true ;
755- }
773+ ret = true ;
756774 }
757775 }
758776
@@ -761,6 +779,40 @@ Master::addSyncWriteData(uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync
761779 return ret;
762780}
763781
782+ bool
783+ Master::endSetupSyncWrite (InfoSyncBulkInst_t *p_sync_info)
784+ {
785+ bool ret = false ;
786+ DXLLibErrorCode_t err = DXL_LIB_OK;
787+ InfoSyncBulkInst_t *p_info = &info_sync_bulk_;
788+
789+ // Parameter exception handling
790+ if (protocol_ver_idx_ != 2 ){
791+ err = DXL_LIB_ERROR_NOT_SUPPORTED;
792+ }else if (info_tx_packet_.inst_idx != DXL_INST_SYNC_WRITE){
793+ err = DXL_LIB_ERROR_NOT_INITIALIZED;
794+ }
795+ if (err != DXL_LIB_OK){
796+ last_lib_err_ = err;
797+ return false ;
798+ }
799+
800+ if (p_sync_info != nullptr ){
801+ p_info = p_sync_info;
802+ }
803+
804+ if (info_tx_packet_.inst_idx == DXL_INST_SYNC_WRITE){
805+ err = end_make_dxl_packet (&info_tx_packet_);
806+ if (err == DXL_LIB_OK){
807+ p_info->packet_length = info_tx_packet_.generated_packet_length ;
808+ p_info->is_complete_packet = true ;
809+ ret = true ;
810+ }
811+ }
812+
813+ return ret;
814+ }
815+
764816bool
765817Master::sendSyncWrite (InfoSyncBulkInst_t *p_sync_info)
766818{
0 commit comments