2 Commits de7d2b360f ... 27c9ab30eb

Author SHA1 Message Date
  Uhl, Patrick | Friedrich Lütze GmbH 27c9ab30eb fixed typos 7 months ago
  Uhl, Patrick | Friedrich Lütze GmbH 9ddc3054dd moved \x03 send in reset communication function 7 months ago

+ 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()