PySerial provides a convenient way to handle data transfer over COM ports. It works on most of the platforms. The program is written using wxPython to create a simple terminal emulator. It is pretty much similar to the example presented by PySerial itself. However in this case, the UI is built on wx.Panel instead of wx.Frame, thus it is easy to embed the terminal emulator into any wxPython GUI.
All GUI components are populated on a single panel inherited from the wx.Panel. On the left a wx.TextCtrl is located as a terminal window. On the right, handful controls are added for for basic setup and control of the terminal window and the COM port. The controls on the right side can be hidden or shown at any time.This terminal supports ASCII mode and Hexadecimal mode. You can also save data to a disk file.
Since all the features are implemented on a wx.Panel (TermPanel), it can be embedded into any window including main frame window simply by creating an instance and passing a PySerial object(serial.Serial())
self.pnlTerm = TermPanel(self, serial.Serial())
You can find an example on which two such panels are populated to implement a UART sniffer.
Actual reading of COM port is done in a separate thread. Thus it does not affect the performance of the main thread much. However since it reads one byte at a time, it cannot handle long sequence of data stream very well. It is more suited to handle short and intermittent transactions.
<<source code>>
All GUI components are populated on a single panel inherited from the wx.Panel. On the left a wx.TextCtrl is located as a terminal window. On the right, handful controls are added for for basic setup and control of the terminal window and the COM port. The controls on the right side can be hidden or shown at any time.This terminal supports ASCII mode and Hexadecimal mode. You can also save data to a disk file.
Since all the features are implemented on a wx.Panel (TermPanel), it can be embedded into any window including main frame window simply by creating an instance and passing a PySerial object(serial.Serial())
self.pnlTerm = TermPanel(self, serial.Serial())
You can find an example on which two such panels are populated to implement a UART sniffer.
Actual reading of COM port is done in a separate thread. Thus it does not affect the performance of the main thread much. However since it reads one byte at a time, it cannot handle long sequence of data stream very well. It is more suited to handle short and intermittent transactions.
<<source code>>
Comments
Post a Comment