@@ -531,7 +531,7 @@ Master::clear(uint8_t id, uint8_t option, uint32_t ex_option, uint32_t timeout_m
531
531
// (Protocol 1.0) Not Supported
532
532
// (Protocol 2.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol2/#sync-read
533
533
bool
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)
535
535
{
536
536
bool ret = false ;
537
537
DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -574,7 +574,7 @@ Master::beginSyncRead(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_sy
574
574
}
575
575
576
576
bool
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)
578
578
{
579
579
bool ret = false ;
580
580
DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -599,23 +599,48 @@ Master::addSyncReadID(uint8_t id, InfoSyncBulkInst_t *p_sync_info, bool flag_end
599
599
600
600
if (err == DXL_LIB_OK){
601
601
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 ;
612
603
}
613
604
614
605
last_lib_err_ = err;
615
606
616
607
return ret;
617
608
}
618
609
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
+
619
644
uint8_t
620
645
Master::sendSyncRead (uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBulkInst_t *p_sync_info)
621
646
{
@@ -663,6 +688,8 @@ Master::sendSyncRead(uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBu
663
688
if (rxStatusPacket (&p_recv_buf[i*p_info->addr_len ],
664
689
recv_buf_capacity-i*p_info->addr_len , 3 ) != nullptr ){
665
690
recv_cnt++;
691
+ }else {
692
+ break ;
666
693
}
667
694
}
668
695
@@ -674,7 +701,7 @@ Master::sendSyncRead(uint8_t *p_recv_buf, uint16_t recv_buf_capacity, InfoSyncBu
674
701
// (Protocol 1.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol1/#sync-write
675
702
// (Protocol 2.0) Refer to http://emanual.robotis.com/docs/en/dxl/protocol2/#sync-write
676
703
bool
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)
678
705
{
679
706
bool ret = false ;
680
707
DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -717,7 +744,7 @@ Master::beginSyncWrite(uint16_t addr, uint16_t addr_len, InfoSyncBulkInst_t *p_s
717
744
}
718
745
719
746
bool
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)
721
748
{
722
749
bool ret = false ;
723
750
DXLLibErrorCode_t err = DXL_LIB_OK;
@@ -743,16 +770,7 @@ Master::addSyncWriteData(uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync
743
770
err = add_param_to_dxl_packet (&info_tx_packet_, (uint8_t *)p_data, p_info->addr_len );
744
771
if (err == DXL_LIB_OK){
745
772
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 ;
756
774
}
757
775
}
758
776
@@ -761,6 +779,40 @@ Master::addSyncWriteData(uint8_t id, uint8_t *p_data, InfoSyncBulkInst_t *p_sync
761
779
return ret;
762
780
}
763
781
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
+
764
816
bool
765
817
Master::sendSyncWrite (InfoSyncBulkInst_t *p_sync_info)
766
818
{
0 commit comments