|
39 | 39 |
|
40 | 40 |
|
41 | 41 | class Command: |
42 | | - RTDE_REQUEST_PROTOCOL_VERSION = ord('V') # V=86 |
43 | | - RTDE_GET_URCONTROL_VERSION = ord('v') # v=118 |
44 | | - RTDE_TEXT_MESSAGE = ord('M') # M=77 |
45 | | - RTDE_DATA_PACKAGE = ord('U') # U=85 |
46 | | - RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS = ord('O') # O=79 |
47 | | - RTDE_CONTROL_PACKAGE_SETUP_INPUTS = ord('I') # I=73 |
48 | | - RTDE_CONTROL_PACKAGE_START = ord('S') # S=83 |
49 | | - RTDE_CONTROL_PACKAGE_PAUSE = ord('P') # P=80 |
| 42 | + RTDE_REQUEST_PROTOCOL_VERSION = ord("V") # V=86 |
| 43 | + RTDE_GET_URCONTROL_VERSION = ord("v") # v=118 |
| 44 | + RTDE_TEXT_MESSAGE = ord("M") # M=77 |
| 45 | + RTDE_DATA_PACKAGE = ord("U") # U=85 |
| 46 | + RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS = ord("O") # O=79 |
| 47 | + RTDE_CONTROL_PACKAGE_SETUP_INPUTS = ord("I") # I=73 |
| 48 | + RTDE_CONTROL_PACKAGE_START = ord("S") # S=83 |
| 49 | + RTDE_CONTROL_PACKAGE_PAUSE = ord("P") # P=80 |
50 | 50 |
|
51 | 51 |
|
52 | | -RTDE_PROTOCOL_VERSION_1 = 1 |
53 | | -RTDE_PROTOCOL_VERSION_2 = 2 |
| 52 | +class Protocol: |
| 53 | + VERSION_1 = 1 |
| 54 | + VERSION_2 = 2 |
54 | 55 |
|
55 | 56 |
|
56 | 57 | class ConnectionState: |
@@ -82,7 +83,7 @@ def __init__(self, hostname, port=30004): |
82 | 83 | self.__output_config = None |
83 | 84 | self.__input_config = {} |
84 | 85 | self.__skipped_package_count = 0 |
85 | | - self.__protocolVersion = RTDE_PROTOCOL_VERSION_1 |
| 86 | + self.__protocolVersion = Protocol.VERSION_1 |
86 | 87 | self.__warning_counter = {} |
87 | 88 |
|
88 | 89 | def connect(self): |
@@ -137,10 +138,10 @@ def get_controller_version(self): |
137 | 138 |
|
138 | 139 | def negotiate_protocol_version(self): |
139 | 140 | cmd = Command.RTDE_REQUEST_PROTOCOL_VERSION |
140 | | - payload = struct.pack(">H", RTDE_PROTOCOL_VERSION_2) |
| 141 | + payload = struct.pack(">H", Protocol.VERSION_2) |
141 | 142 | success = self.__sendAndReceive(cmd, payload) |
142 | 143 | if success: |
143 | | - self.__protocolVersion = RTDE_PROTOCOL_VERSION_2 |
| 144 | + self.__protocolVersion = Protocol.VERSION_2 |
144 | 145 | return success |
145 | 146 |
|
146 | 147 | def send_input_setup(self, variables, types=[]): |
@@ -434,7 +435,7 @@ def __unpack_text_message(self, payload): |
434 | 435 | if len(payload) < 1: |
435 | 436 | _log.error("RTDE_TEXT_MESSAGE: No payload") |
436 | 437 | return None |
437 | | - if self.__protocolVersion == RTDE_PROTOCOL_VERSION_1: |
| 438 | + if self.__protocolVersion == Protocol.VERSION_1: |
438 | 439 | msg = serialize.MessageV1.unpack(payload) |
439 | 440 | else: |
440 | 441 | msg = serialize.Message.unpack(payload) |
|
0 commit comments