![]() ![]() ![]() The following is a script that utilizes the object and send a command "info" to a connected device with serial number "R200000"įrom time import sleep # Initialize an instance com = ComConnection(serial_number='R200000', command='info', baudrate=9600) def read(): while True: data = com.receive_command() if data: print data sleep(1) def write(): # If you pass an invalid serial-number, an exception will be thrown # This will inform that no device with provided serial number is found. Raise IOError('Try to send data when the connection is closed')ĭef handle_serial_error(self, error=None): Raise IOError('Could not find device with provided serial number.'))ĭevice = self.get_device_name(rial_number) Serial_numbers.append(rial_number.encode('utf-8')) # save list of serial numbers for user reference When not found device with this serial number Get full device name/path from serial number Return "SRN: ".format(rial_number, mand)ĭef get_device_name(self, serial_number): ![]() """Serial wrapper which can be instantiated using the device's serial number"""ĭef _init_(self, serial_number=None, command=None, baudrate=9600):īaud rate such as 9600 or 115200 etc. See an application of this script on GitHub!Īustralian Defense Force Academy from os import linesepįrom _ports import comports The following shows an example of a simple script that will automatically locate the Adaura Technologies device based on the specified serial number and send a command to it via PySerial.
0 Comments
Leave a Reply. |