blob: 33450ea57f1df6daa5d78a0ee0a389e436600ae4 [file] [log] [blame]
cliechti86e87872009-07-21 13:32:45 +00001==========
2 Examples
3==========
4
5Miniterm
6========
7This is a console application that provides a small terminal application.
8miniterm itself does not implement any terminal features such as VT102
9compatibility. However it inherits these features from the terminal it is run.
10For example on GNU/Linux running from an xterm it will support the escape
11sequences of the xterm. On Windows the typical console window is dumb and does
12not support any escapes. When ANSI.sys is loaded it supports some escapes.
13
cliechti5134aab2009-07-21 19:47:59 +000014miniterm::
15
16 --- Miniterm on /dev/ttyS0: 9600,8,N,1 ---
17 --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
18
cliechti86e87872009-07-21 13:32:45 +000019Command line options can be given so that binary data including escapes for
20terminals are escaped or output as hex.
21
cliechti5134aab2009-07-21 19:47:59 +000022Command line options ``miniterm.py -h``::
23
24 Usage: miniterm.py [options] [port [baudrate]]
25
26 Miniterm - A simple terminal program for the serial port.
27
28 Options:
29 -h, --help show this help message and exit
30 -p PORT, --port=PORT port, a number (default 0) or a device name
31 (deprecated option)
32 -b BAUDRATE, --baud=BAUDRATE
33 set baud rate, default 9600
34 --parity=PARITY set parity, one of [N, E, O, S, M], default=N
35 -e, --echo enable local echo (default off)
36 --rtscts enable RTS/CTS flow control (default off)
37 --xonxoff enable software flow control (default off)
38 --cr do not send CR+LF, send CR only
39 --lf do not send CR+LF, send LF only
40 -D, --debug debug received data (escape non-printable chars)
41 --debug can be given multiple times: 0: just print
42 what is received 1: escape non-printable characters,
43 do newlines as unusual 2: escape non-printable
44 characters, newlines too 3: hex dump everything
45 --rts=RTS_STATE set initial RTS line state (possible values: 0, 1)
46 --dtr=DTR_STATE set initial DTR line state (possible values: 0, 1)
47 -q, --quiet suppress non error messages
48 --exit-char=EXIT_CHAR
49 ASCII code of special character that is used to exit
50 the application
51 --menu-char=MENU_CHAR
52 ASCII code of special character that is used to
53 control miniterm (menu)
54
55
56miniterm supports some control functions. Typing :kbd:`Control+t Control+h` when it is
57running shows the help text::
58
59 --- pySerial - miniterm - help
60 ---
61 --- Ctrl+] Exit program
62 --- Ctrl+T Menu escape key, followed by:
63 --- Menu keys:
64 --- Ctrl+T Send the menu character itself to remote
65 --- Ctrl+] Send the exit character to remote
66 --- Ctrl+I Show info
67 --- Ctrl+U Upload file (prompt will be shown)
68 --- Toggles:
69 --- Ctrl+R RTS Ctrl+E local echo
70 --- Ctrl+D DTR Ctrl+B BREAK
71 --- Ctrl+L line feed Ctrl+A Cycle repr mode
72 ---
73 --- Port settings (Ctrl+T followed by the following):
74 --- 7 8 set data bits
75 --- n e o s m change parity (None, Even, Odd, Space, Mark)
76 --- 1 2 3 set stop bits (1, 2, 1.5)
77 --- b change baud rate
78 --- x X disable/enable software flow control
79 --- r R disable/enable hardware flow control
80
cliechti86e87872009-07-21 13:32:45 +000081
82miniterm.py_
83 The miniterm program.
84
85setup-miniterm-py2exe.py_
86 This is a py2exe setup script for Windows. It can be used to create a
87 standalone ``miniterm.exe``.
88
89.. _miniterm.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/miniterm.py
90.. _setup-miniterm-py2exe.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/setup-miniterm-py2exe.py
91
92
93TCP/IP - serial bridge
94======================
95This program opens a TCP/IP port. When a connection is made to that port (e.g.
96with telnet) it forwards all data to the serial port and vice versa.
97
98The serial port settings are set on the command line when starting the program.
99There is no possibility to change settings from remote.
cliechti5134aab2009-07-21 19:47:59 +0000100::
101
102 Usage: tcp_serial_redirect.py [options] [port [baudrate]]
103
104 Simple Serial to Network (TCP/IP) redirector.
105
106 Options:
107 -h, --help show this help message and exit
108 -q, --quiet suppress non error messages
109 --spy peek at the communication and print all data to the
110 console
111
112 Serial Port:
113 Serial port settings
114
115 -p PORT, --port=PORT
116 port, a number (default 0) or a device name
117 -b BAUDRATE, --baud=BAUDRATE
118 set baud rate, default: 9600
119 --parity=PARITY set parity, one of [N, E, O], default=N
120 --rtscts enable RTS/CTS flow control (default off)
121 --xonxoff enable software flow control (default off)
122 --rts=RTS_STATE set initial RTS line state (possible values: 0, 1)
123 --dtr=DTR_STATE set initial DTR line state (possible values: 0, 1)
124
125 Network settings:
126 Network configuration.
127
128 -P LOCAL_PORT, --localport=LOCAL_PORT
129 local TCP port
130
131 Newline Settings:
132 Convert newlines between network and serial port. Conversion is
133 normally disabled and can be enabled by --convert.
134
135 -c, --convert enable newline conversion (default off)
136 --net-nl=NET_NEWLINE
137 type of newlines that are expected on the network
138 (default: LF)
139 --ser-nl=SER_NEWLINE
140 type of newlines that are expected on the serial port
141 (default: CR+LF)
142
143 NOTE: no security measures are implemented. Anyone can remotely connect to
144 this service over the network. Only one connection at once is supported. When
145 the connection is terminated it waits for the next connect.
146
cliechti86e87872009-07-21 13:32:45 +0000147
148tcp_serial_redirect.py_
149 Main program.
150
151.. _tcp_serial_redirect.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/tcp_serial_redirect.py
152
153
154wxPython examples
155=================
156A simple terminal application for wxPython and a flexible serial port
157configuration dialog are shown here.
158
159wxTerminal.py_
160 A simple terminal application. Note that the length of the buffer is
161 limited by wx and it may suddenly stop displaying new input.
162
163wxTerminal.wxg_
164 A wxGlade design file for the terminal application.
165
166wxSerialConfigDialog.py_
167 A flexible serial port configuration dialog.
168
169wxSerialConfigDialog.wxg_
170 The wxGlade design file for the configuration dialog.
171
172setup_demo.py_
173 A py2exe setup script to package the terminal application.
174
175.. _wxTerminal.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxTerminal.py
176.. _wxTerminal.wxg: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxTerminal.wxg
177.. _wxSerialConfigDialog.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxSerialConfigDialog.py
178.. _wxSerialConfigDialog.wxg: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/wxSerialConfigDialog.wxg
179.. _setup_demo.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/setup_demo.py
180
181
182Wrapper class
183=============
184This example provides a subclass based on ``Serial`` that has an alternative
185implementation of ``readline()``
186
187enhancedserial.py_
188 A class with alternative ``readline()`` implementation.
189
190.. _enhancedserial.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/enhancedserial.py
191
192
193Finding serial ports
194====================
195scan.py_
196 A simple loop that probes serial ports by number.
197
198scanwin32.py_
199 A Windows only version that returns a list of serial ports with information
200 from the registry.
201
202.. _scan.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/scan.py
203.. _scanwin32.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/scanwin32.py
204
205
206Unit tests
207==========
208The project uses a number of unit test to verify the functionality. They all
209need a loop back connector. The scripts itself contain more information.
210
211test.py_
212 Basic tests.
213
214test_high_load.py_
215 Tests involving sending a lot of data.
216
217test_advanced.py_
218 Test more advanced features.
219
220.. _test.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test.py
221.. _test_high_load.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test_high_load.py
222.. _test_advanced.py: http://pyserial.svn.sourceforge.net/viewvc/*checkout*/pyserial/trunk/pyserial/examples/test_advanced.py