@@ -137,7 +137,7 @@ def _request(self, flag=""):
137137 header = "ReadSYS["
138138 read = data .find (header ) + len (header )
139139 end = data [read :].find (']' )
140- return data [read :read + end ]
140+ return int ( data [read :read + end ])
141141 elif flag == 'system_version' :
142142 start_idx = data .find ("GetSystemVersion[" )
143143 if start_idx != - 1 :
@@ -640,31 +640,45 @@ def get_gripper_angle(self):
640640 self ._debug (command )
641641 return self ._request ("gripper" )
642642
643- def set_system_value (self , id , address , value ):
643+ def set_system_value (self , id , address , value , mode = None ):
644644 """_summary_
645645
646646 Args:
647647 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
650653 """
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
653660 self ._serial_port .write (command .encode ())
654661 self ._serial_port .flush ()
655662 self ._debug (command )
656663
657- def get_system_value (self , id , address ):
664+ def get_system_value (self , id , address , mode = None ):
658665 """_summary_
659666
660667 Args:
661668 id (int): 4 or 7
662669 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
663673
664674 Returns:
665675 _type_: _description_
666676 """
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
668682 self ._serial_port .write (command .encode ())
669683 self ._serial_port .flush ()
670684 self ._debug (command )
@@ -677,7 +691,7 @@ def get_system_version(self):
677691 Returns:
678692 (float) Firmware version
679693 """
680- command = 'GetSystemVersion[1.50]' + ProtocolCode .END
694+ command = ProtocolCode . GET_SYSTEM_VERSION + ProtocolCode .END
681695 self ._serial_port .write (command .encode ())
682696 self ._serial_port .flush ()
683697 self ._debug (command )
@@ -690,7 +704,7 @@ def get_modify_version(self):
690704 Returns:
691705 (int) modify version
692706 """
693- command = 'GetModifyVersion[0]' + ProtocolCode .END
707+ command = ProtocolCode . GET_MODIFY_VERSION + ProtocolCode .END
694708 self ._serial_port .write (command .encode ())
695709 self ._serial_port .flush ()
696710 self ._debug (command )
0 commit comments