I have a device that communicate via serial com port. From time to time , the device stuck and I don't have access to read any information from it.Only when I physically disconnect and re-connect the device from my computer , i can read the data again. Can I do it (disconnect and connect ) with python script?
when I tried to open the com port i print connection data:
def print_connection_data(self):
logger.info("checking if port is opened:")
logger.info(self.ser.isOpen())
logger.info("checking if we have characters to read:")
logger.info(self.ser.inWaiting())
logger.info("getting settings dict:")
logger.info(self.ser.getSettingsDict())
and the results are:
- 2015-04-13 18:33:45,322 - wtests - INFO - checking if port is opened:
- 2015-04-13 18:33:45,322 - wtests - INFO - True
- 2015-04-13 18:33:45,323 - wtests - INFO - checking if we have characters to read:
- 2015-04-13 18:33:45,323 - wtests - INFO - 0
- 2015-04-13 18:33:45,323 - wtests - INFO - getting settings dict:
- 2015-04-13 18:33:45,323 - wtests - INFO - {'parity': 'N', 'baudrate': 9600, 'bytesize': 8, 'xonxoff': False, 'interCharTimeout': None, 'rtscts': False, 'timeout': 1, 'stopbits': 1, 'dsrdtr': False, 'writeTimeout': None}