2 """Use the USBSerial class to establish a serial connection with a compatible device via USB port.""" 4 from __future__
import print_function
10 """Establish a serial connection with a connected USB device.""" 13 Initialize class for serial connection. 14 :param port: String: USB port the device is connected to 15 :param baudrate (default=115200): Int: Baudrate to use for the communication with the USB device 25 """Open the serial connection.""" 30 print(
'Unable to open serial connection with: ' + self.
port)
33 """Close the serial connection.""" 38 print(
'Unable to close serial connection with: ' + self.
port)
42 Send serial message over the established connection. 43 :param msg: String: message to be sent over serial connection 48 print(
'Unable to send message over serial connection.')
52 Return a single line from the serial messages with a custom end-of-line character. 53 :param eol_character: Bytes: character or sequence to use as end-of-line character. 54 :return: Bytes: the most recent line that has been sent via the serial connection 57 if not self.ser.isOpen():
73 if line[-leneol:] == eol:
def get_line(self, eol_character)
def __init__(self, port, baudrate=115200)