diff --git a/Robot-Framework/lib/KMTronicLibrary.py b/Robot-Framework/lib/KMTronicLibrary.py index 26fac06b..7dcb8199 100644 --- a/Robot-Framework/lib/KMTronicLibrary.py +++ b/Robot-Framework/lib/KMTronicLibrary.py @@ -12,18 +12,22 @@ class KMTronicLibrary: def __init__(self, port): """Initialize the serial connection""" - self.ser = serial.Serial( - port=port, # Port to which the device is connected - baudrate=9600, # Baud rate - bytesize=serial.EIGHTBITS, # Number of data bits - parity=serial.PARITY_NONE, # No parity - stopbits=serial.STOPBITS_ONE, # One stop bit - timeout=1 # Timeout for reading data - ) - if self.ser.is_open: - print(f"Connection established successfully on port {port}.") + if port == 'NONE': + self.ser = None + print("No serial connection initialized (port set to 'NONE').") else: - raise RuntimeError(f"Failed to open connection on port {port}") + self.ser = serial.Serial( + port=port, # Port to which the device is connected + baudrate=9600, # Baud rate + bytesize=serial.EIGHTBITS, # Number of data bits + parity=serial.PARITY_NONE, # No parity + stopbits=serial.STOPBITS_ONE, # One stop bit + timeout=1 # Timeout for reading data + ) + if self.ser.is_open: + print(f"Connection established successfully on port {port}.") + else: + raise RuntimeError(f"Failed to open connection on port {port}") def close_relay_board_connection(self): """ diff --git a/Robot-Framework/resources/serial_keywords.resource b/Robot-Framework/resources/serial_keywords.resource index 6770809f..1800bbf4 100644 --- a/Robot-Framework/resources/serial_keywords.resource +++ b/Robot-Framework/resources/serial_keywords.resource @@ -20,15 +20,6 @@ Open Serial Port ... stopbits=1 ... timeout=${timeout} -Open Relay Serial Port - [Arguments] ${serialr_port} ${timeout}=1.0 ${baudrate}=9600 - Add Port ${serialr_port} - ... baudrate=${baudrate} - ... bytesize=8 - ... parity=N - ... stopbits=1 - ... timeout=${timeout} - Turn Relay Off [Documentation] Turn given ${relay_number} relay off. [Arguments] ${relay_number}