2 次代碼提交 de7d2b360f ... 27c9ab30eb

作者 SHA1 備註 提交日期
  Uhl, Patrick | Friedrich Lütze GmbH 27c9ab30eb fixed typos 8 月之前
  Uhl, Patrick | Friedrich Lütze GmbH 9ddc3054dd moved \x03 send in reset communication function 8 月之前
共有 2 個文件被更改,包括 8 次插入5 次删除
  1. 0 1
      python_driver/shellmatta_transport.py
  2. 8 4
      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 """

+ 8 - 4
python_driver/shellmatta_transport_serial.py

@@ -1,4 +1,4 @@
-""" Wrapper arount a shellmatta with transport layer to send commands and receive the response """
+""" Wrapper around a shellmatta with transport layer to send commands and receive the response """
 
 import time
 import serial
@@ -10,14 +10,14 @@ class ShellmattaSerial():
 
 
     def __init__(self, com_port, baudrate=115200, prompt="->", timeout=1, transport_layer_mandatory=False):
-        """ create the transport layer instance using the passed com port """
+        """ Create the transport layer instance using the passed com port """
         self.prompt = prompt
         self.com = com_port
         self.com_port = serial.Serial(com_port, baudrate=baudrate, timeout=timeout)
 
         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()