eg.SerialThread¶
-
class
eg.
SerialThread
(hFile=0)[source]¶ Eased handling of serial port communication.
-
GetMode
()[source]¶ Returns the currently used serial port mode setting as string.
See
Open()
for a complete description of the mode string.
-
Open
(port=0, baudrate=9600, mode='8N1')[source]¶ Opens the serial port. After the port is opened, you have to call
Start()
to start the actual event processing of this class.Arguments: - port
The port to open as an integer starting at one (0 = COM1)
- baudrate
The baudrate to use as an integer. Defaults to 9600.
- mode
The serial port mode settings to use. This should be a string created by the joining of the following parts:
- byte size
- ‘5’, ‘6’, ‘7’ or ‘8’
- parity mode
- ‘N’ for no parity,
- ‘E’ for even parity,
- ‘O’ for odd parity,
- ‘M’ for mark parity,
- ‘S’ for space parity
- stop bits
- ‘1’ for one stop bit
- ‘1.5’ for one and a half stop bit
- ‘2’ for two stop bits
Example values: ‘8N1’ (default), ‘8E1’, ‘7N1.5’
-
ResumeReadEvents
()[source]¶ Resumes the receive event processing that was disabled before by
SuspendReadEvents()
-
exception
SerialError
(msg=None)¶ Base class for SerialThread related exceptions.
-
SetMode
(mode)[source]¶ Sets the serial port mode setting from a string.
See
Open()
for a complete description of the mode string.
-
SetReadEventCallback
(callback)[source]¶ Sets a callback function for receive event processing. Should be called before
Start()
. The callback should have the form:def HandleReceive(serialThread): ...
where serialThread will be the instance of this SerialThread class, so you can easily call
Read()
andWrite()
on this object.
-
SuspendReadEvents
()[source]¶ Temporarily disables the receive event processing of this class. Call
ResumeReadEvents()
to resume processing.
-