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