@@ -137,7 +137,7 @@ def _request(self, flag=""):
137
137
header = "ReadSYS["
138
138
read = data .find (header ) + len (header )
139
139
end = data [read :].find (']' )
140
- return data [read :read + end ]
140
+ return int ( data [read :read + end ])
141
141
elif flag == 'system_version' :
142
142
start_idx = data .find ("GetSystemVersion[" )
143
143
if start_idx != - 1 :
@@ -640,31 +640,45 @@ def get_gripper_angle(self):
640
640
self ._debug (command )
641
641
return self ._request ("gripper" )
642
642
643
- def set_system_value (self , id , address , value ):
643
+ def set_system_value (self , id , address , value , mode = None ):
644
644
"""_summary_
645
645
646
646
Args:
647
647
id (int): 4 or 7
648
- address (int): 0 ~ 69
649
- value (int):
648
+ address (int): 7 ~ 69
649
+ value (int):
650
+ mode (int): 1 or 2, can be empty, default mode is 1
651
+ 1 - setting range is 0-255, address 21 (P value) can be used
652
+ 2 - setting value range is 0-65535, address 56 (setting position) can be used
650
653
"""
651
- command = ProtocolCode .SET_SYSTEM_VALUE + " X{} " .format (id ) + "Y{} " .format (address ) + "Z{} " .format (
652
- value ) + ProtocolCode .END
654
+ if mode :
655
+ command = ProtocolCode .SET_SYSTEM_VALUE + " X{} " .format (id ) + "Y{} " .format (address ) + "Z{} " .format (
656
+ value ) + "P{} " .format (mode ) + ProtocolCode .END
657
+ else :
658
+ command = ProtocolCode .SET_SYSTEM_VALUE + " X{} " .format (id ) + "Y{} " .format (address ) + "Z{} " .format (
659
+ value ) + ProtocolCode .END
653
660
self ._serial_port .write (command .encode ())
654
661
self ._serial_port .flush ()
655
662
self ._debug (command )
656
663
657
- def get_system_value (self , id , address ):
664
+ def get_system_value (self , id , address , mode = None ):
658
665
"""_summary_
659
666
660
667
Args:
661
668
id (int): 4 or 7
662
669
address (_type_): 0 ~ 69
670
+ mode (int): 1 or 2, can be empty, default mode is 1
671
+ 1 - read range is 0-255, address 21 (P value) can be used
672
+ 2 - read value range is 0-65535, address 56 (read position) can be used
663
673
664
674
Returns:
665
675
_type_: _description_
666
676
"""
667
- command = ProtocolCode .GET_SYSTEM_VALUE + " J{} " .format (id ) + "S{} " .format (address ) + ProtocolCode .END
677
+ if mode :
678
+ command = ProtocolCode .GET_SYSTEM_VALUE + " J{} " .format (id ) + "S{} " .format (address ) + "P{} " .format (
679
+ mode ) + ProtocolCode .END
680
+ else :
681
+ command = ProtocolCode .GET_SYSTEM_VALUE + " J{} " .format (id ) + "S{} " .format (address ) + ProtocolCode .END
668
682
self ._serial_port .write (command .encode ())
669
683
self ._serial_port .flush ()
670
684
self ._debug (command )
@@ -677,7 +691,7 @@ def get_system_version(self):
677
691
Returns:
678
692
(float) Firmware version
679
693
"""
680
- command = 'GetSystemVersion[1.50]' + ProtocolCode .END
694
+ command = ProtocolCode . GET_SYSTEM_VERSION + ProtocolCode .END
681
695
self ._serial_port .write (command .encode ())
682
696
self ._serial_port .flush ()
683
697
self ._debug (command )
@@ -690,7 +704,7 @@ def get_modify_version(self):
690
704
Returns:
691
705
(int) modify version
692
706
"""
693
- command = 'GetModifyVersion[0]' + ProtocolCode .END
707
+ command = ProtocolCode . GET_MODIFY_VERSION + ProtocolCode .END
694
708
self ._serial_port .write (command .encode ())
695
709
self ._serial_port .flush ()
696
710
self ._debug (command )
0 commit comments