소스 검색

moved \x03 send in reset communication function

Uhl, Patrick | Friedrich Lütze GmbH 8 달 전
부모
커밋
9ddc3054dd
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 0 1
      python_driver/shellmatta_transport.py
  2. 6 2
      python_driver/shellmatta_transport_serial.py

+ 0 - 1
python_driver/shellmatta_transport.py

@@ -258,7 +258,6 @@ class ShellmattaTransport():
         self.received_buffer = b''
         # flush the buffer and send one cancel
         self.com_obj.write(b'\x00' * (self.Packet.MAX_PAYLOAD_LENGTH + 12))
-        self.write(b'\x03')
 
     def close(self):
         """ Close port """

+ 6 - 2
python_driver/shellmatta_transport_serial.py

@@ -17,7 +17,7 @@ class ShellmattaSerial():
 
         self.transport = ShellmattaTransport(self.com_port, transport_layer_mandatory)
 
-    def send_command(self, command):
+    def send_command(self, command, enter=True):
         """ Send command and wait for the prompt in the response. """
 
         if isinstance(command, str):
@@ -28,7 +28,8 @@ class ShellmattaSerial():
         retries = 3
 
         while retries:
-            send_data = send_data + b"\r"
+            if enter:
+                send_data += b"\r"
             self.transport.write(send_data)
             data = b''
 
@@ -71,6 +72,9 @@ class ShellmattaSerial():
         self.com_port.reset_input_buffer()
         self.com_port.reset_output_buffer()
 
+        # send cancel - and read response from input buffer
+        _result = self.send_command("\x03", enter=False)
+
     def close_serial(self):
         """ Closes the serial port """
         self.com_port.close()