cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 1 | ============== |
| 2 | pySerial API |
| 3 | ============== |
| 4 | |
| 5 | .. module:: serial |
| 6 | |
| 7 | Classes |
| 8 | ======= |
| 9 | |
| 10 | .. class:: Serial |
| 11 | |
| 12 | .. method:: __init__(port=None, baudrate=9600, bytesize=EIGHTBITS, parity=PARITY_NONE, stopbits=STOPBITS_ONE, timeout=None, xonxoff=0, rtscts=0, interCharTimeout=None) |
| 13 | |
| 14 | :param port: |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 15 | Device name or port number number or None. |
| 16 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 17 | :param baudrate: |
| 18 | Baud rate such as 9600 or 115200 etc. |
| 19 | |
| 20 | :param bytesize: |
| 21 | Number of data bits. Possible values: FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS |
| 22 | |
| 23 | :param parity: |
| 24 | Enable parity checking. Possible values: PARITY_NONE PARITY_EVEN PARITY_ODD PARITY_MARK PARITY_SPACE |
| 25 | |
| 26 | :param stopbits: |
| 27 | Number of stop bits. Possible values: STOPBITS_ONE STOPBITS_ONE_POINT_FIVE STOPBITS_TWO |
| 28 | |
| 29 | :param timeout: |
| 30 | Set a read timeout value. |
| 31 | |
| 32 | :param xonxoff: |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 33 | Enable software flow control. |
| 34 | |
| 35 | :param rtscts: |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 36 | Enable hardware (RTS/CTS) flow control. |
| 37 | |
| 38 | :param interCharTimeout: |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 39 | Inter-character timeout, None to disable. |
| 40 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 41 | :exception ValueError: |
| 42 | Will be raised when parameter are out of range, e.g. baudrate, data bits. |
| 43 | |
| 44 | :exception SerialException: |
| 45 | In case the device can not be found or can not be configured. |
| 46 | |
| 47 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 48 | The port is immediately opened on object creation, when a ``port`` is |
| 49 | given. It is not opened when port is None. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 50 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 51 | - Number: number of device, numbering starts at zero. |
| 52 | - Device name: depending on operating system. e.g. ``/dev/ttyUSB0`` |
| 53 | on GNU/Linux or ``COM3`` on Windows. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 54 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 55 | Possible values for the parameter ``timeout``: |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 56 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 57 | - ``timeout = None``: wait forever |
| 58 | - ``timeout = 0``: non-blocking mode (return immediately on read) |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 59 | - ``timeout = x``: set timeout to ``x`` seconds (float allowed) |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | .. method:: open() |
| 63 | |
| 64 | Open port. |
| 65 | |
| 66 | .. method:: close() |
| 67 | |
| 68 | Close port immediately. |
| 69 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 70 | |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 71 | The following methods may rise :exc:`ValueError` when applied to a closed port. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 72 | |
| 73 | .. method:: inWaiting() |
| 74 | |
| 75 | Return the number of chars in the receive buffer. |
| 76 | |
| 77 | .. method:: read(size=1) |
| 78 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 79 | :param size: Number of bytes to read. |
| 80 | :return: Bytes read from the port. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 81 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 82 | Read ``size`` bytes from the serial port. If a timeout is set it may |
| 83 | return less characters as requested. With no timeout it will block |
| 84 | until the requested number of bytes is read. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 85 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 86 | .. method:: write(data) |
| 87 | |
| 88 | :param data: Data to send. |
| 89 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 90 | :exception SerialTimeoutException: |
| 91 | In case a write timeout is configured for the port and the time is |
| 92 | exceeded. |
| 93 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 94 | Write the string ``data`` to the port. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 95 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 96 | .. method:: flush(): |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 97 | |
| 98 | Flush of file like objects. In this case, wait until all data is |
| 99 | written. |
| 100 | |
| 101 | .. method:: flushInput() |
| 102 | |
| 103 | Flush input buffer, discarding all it's contents. |
| 104 | |
| 105 | .. method:: flushOutput() |
| 106 | |
| 107 | Clear output buffer, aborting the current output and |
| 108 | discarding all that is in the buffer. |
| 109 | |
| 110 | .. method:: sendBreak(duration=0.25) |
| 111 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 112 | :param duration: Time (float) to activate the BREAK condition. |
| 113 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 114 | Send break condition. Timed, returns to idle state after given |
| 115 | duration. |
| 116 | |
| 117 | .. method:: setBreak(level=True) |
| 118 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 119 | :param level: when true activate BREAK condition, else disable. |
| 120 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 121 | Set break: Controls TXD. When active, no transmitting is possible. |
| 122 | |
| 123 | .. method:: setRTS(level=True) |
| 124 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 125 | :param level: Set control line to logic level. |
| 126 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 127 | Set RTS line to specified logic level. |
| 128 | |
| 129 | .. method:: setDTR(level=True) |
| 130 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 131 | :param level: Set control line to logic level. |
| 132 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 133 | Set DTR line to specified logic level. |
| 134 | |
| 135 | .. method:: getCTS() |
| 136 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 137 | :return: Current state (boolean) |
| 138 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 139 | Return the state of the CTS line. |
| 140 | |
| 141 | .. method:: getDSR() |
| 142 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 143 | :return: Current state (boolean) |
| 144 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 145 | Return the state of the DSR line. |
| 146 | |
| 147 | .. method:: getRI() |
| 148 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 149 | :return: Current state (boolean) |
| 150 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 151 | Return the state of the RI line. |
| 152 | |
| 153 | .. method:: getCD() |
| 154 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 155 | :return: Current state (boolean) |
| 156 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 157 | Return the state of the CD line |
| 158 | |
| 159 | Read-only attributes: |
| 160 | |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 161 | .. attribute:: name |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 162 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 163 | Device name. This is always the device name even if the |
| 164 | port was opened by a number. (Read Only). |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 165 | |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 166 | .. versionadded:: 2.5 |
| 167 | |
| 168 | .. attribute:: portstr |
| 169 | |
| 170 | :deprecated: use :attr:`name` instead |
| 171 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 172 | .. attribute:: BAUDRATES |
| 173 | |
| 174 | A list of valid baud rates. The list may be incomplete such that higher |
| 175 | baud rates may be supported by the device and that values in between the |
| 176 | standard baud rates are supported. (Read Only). |
| 177 | |
| 178 | .. attribute:: BYTESIZES |
| 179 | |
| 180 | A list of valid byte sizes for the device (Read Only). |
| 181 | |
| 182 | .. attribute:: PARITIES |
| 183 | |
| 184 | A list of valid parities for the device (Read Only). |
| 185 | |
| 186 | .. attribute:: STOPBITS |
| 187 | |
| 188 | A list of valid stop bit widths for the device (Read Only). |
| 189 | |
| 190 | |
| 191 | New values can be assigned to the following attributes, the port will be reconfigured, even if it's opened at that time: |
| 192 | |
| 193 | .. attribute:: port |
| 194 | |
| 195 | Port name/number as set by the user. |
| 196 | |
| 197 | .. attribute:: baudrate |
| 198 | |
| 199 | Current baud rate setting. |
| 200 | |
| 201 | .. attribute:: bytesize |
| 202 | |
| 203 | Byte size in bits. |
| 204 | |
| 205 | .. attribute:: parity |
| 206 | |
| 207 | Parity setting. |
| 208 | |
| 209 | .. attribute:: stopbits |
| 210 | |
| 211 | Stop bit with. |
| 212 | |
| 213 | .. attribute:: timeout |
| 214 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 215 | Timeout setting (seconds, float). |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 216 | |
| 217 | .. attribute:: xonxoff |
| 218 | |
| 219 | If Xon/Xoff flow control is enabled. |
| 220 | |
| 221 | .. attribute:: rtscts |
| 222 | |
| 223 | If hardware flow control is enabled. |
| 224 | |
| 225 | Platform specific methods. |
| 226 | |
| 227 | .. warning:: Programs using the following methods are not portable to other platforms! |
| 228 | |
| 229 | .. method:: nonblocking() |
| 230 | |
| 231 | :platform: Unix |
cliechti | 86e8787 | 2009-07-21 13:32:45 +0000 | [diff] [blame] | 232 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 233 | Configure the device for nonblocking operations. This can be useful if |
| 234 | the port is used with ``select``. |
| 235 | |
| 236 | .. method:: fileno() |
| 237 | |
| 238 | :platform: Unix |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 239 | :return: File descriptor. |
cliechti | 86e8787 | 2009-07-21 13:32:45 +0000 | [diff] [blame] | 240 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 241 | Return file descriptor number for the port that is opened by this object. |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 242 | |
| 243 | .. method:: setXON(level=True) |
| 244 | |
| 245 | :platform: Windows |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 246 | :param level: Set flow control state. |
cliechti | 86e8787 | 2009-07-21 13:32:45 +0000 | [diff] [blame] | 247 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 248 | Set software flow control state. |
| 249 | |
| 250 | |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 251 | .. class:: RawSerial |
| 252 | |
| 253 | This class is only present when run with Python 2.6 and newer that prides |
| 254 | the module :mod:`io`. It shares the same interface with :class:`Serial` |
| 255 | with the difference that :meth:`read` and :meth:`write` work with |
| 256 | :class:`bytes`and :class:`bytearrays`. |
| 257 | |
| 258 | This also means that readline is borrowed from the :mod:`io` module and |
| 259 | lacks the ``eol`` parameter. |
| 260 | |
| 261 | .. versionadded:: 2.5 |
| 262 | |
| 263 | |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 264 | .. class:: FileLike |
| 265 | |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 266 | An abstract file like class. It is used as base class for :class:`Serial`. |
| 267 | |
| 268 | This class implements readline and readlines based on read and |
| 269 | writelines based on write. |
| 270 | This class is used to provide the above functions for to Serial |
| 271 | port objects. |
| 272 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 273 | Note that when the serial port was opened with no timeout that |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 274 | readline blocks until it sees a newline (or the specified size is |
| 275 | reached) and that readlines would never return and therefore |
| 276 | refuses to work (it raises an exception in this case)! |
| 277 | |
| 278 | .. method:: readline(size=None, eol='\n') |
| 279 | |
| 280 | :param size: Max number of bytes to read, ``None`` -> no limit. |
| 281 | :param eol: The end of line character. |
| 282 | |
| 283 | Read a line which is terminated with end-of-line (eol) character |
| 284 | ('\n' by default) or until timeout. |
| 285 | |
| 286 | .. method:: readlines(sizehint=None, eol='\n') |
| 287 | |
| 288 | :param size: Ignored parameter. |
| 289 | :param eol: The end of line character. |
| 290 | |
| 291 | Read a list of lines, until timeout. ``sizehint`` is ignored and only |
| 292 | present for API compatibility with built-in File objects. |
| 293 | |
| 294 | .. method:: xreadlines(sizehint=None) |
| 295 | |
| 296 | Just calls ``readlines`` - here for compatibility. |
| 297 | |
| 298 | .. method:: writelines(sequence) |
| 299 | |
| 300 | Write a list of strings to the port. |
| 301 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 302 | |
| 303 | The following three methods are overridden in :class:`Serial`. |
| 304 | |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 305 | .. method:: flush() |
| 306 | |
| 307 | Flush of file like objects. It's a no-op in this class, may be overridden. |
| 308 | |
| 309 | .. method:: read() |
| 310 | |
| 311 | Raises NotImplementedError, needs to be overridden by subclass. |
| 312 | |
cliechti | bb5c3c5 | 2009-07-23 02:29:27 +0000 | [diff] [blame] | 313 | .. method:: write(data) |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 314 | |
| 315 | Raises NotImplementedError, needs to be overridden by subclass. |
| 316 | |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 317 | The following functions are implemented for compatibility with other |
| 318 | file-like objects, however serial ports are not seekable. |
| 319 | |
| 320 | |
| 321 | .. method:: seek(pos, whence=0) |
| 322 | |
| 323 | :exception IOError: always, as method is not supported on serial port |
| 324 | |
| 325 | .. versionadded:: 2.5 |
| 326 | |
| 327 | .. method:: tell() |
| 328 | |
| 329 | :exception IOError: always, as method is not supported on serial port |
| 330 | |
| 331 | .. versionadded:: 2.5 |
| 332 | |
| 333 | .. method:: truncate(self, n=None): |
| 334 | |
| 335 | :exception IOError: always, as method is not supported on serial port |
| 336 | |
| 337 | .. versionadded:: 2.5 |
| 338 | |
| 339 | .. method:: isatty() |
| 340 | |
| 341 | :exception IOError: always, as method is not supported on serial port |
| 342 | |
| 343 | .. versionadded:: 2.5 |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 344 | |
| 345 | To be able to use the file like object as iterator for e.g. |
| 346 | ``for line in Serial(0): ...`` usage: |
| 347 | |
| 348 | .. method:: next() |
| 349 | |
| 350 | Return the next line by calling :meth:`readline`. |
| 351 | |
| 352 | .. method:: __iter__() |
| 353 | |
| 354 | Returns self. |
| 355 | |
| 356 | |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 357 | .. class:: SerialBase |
| 358 | |
| 359 | The following attributes are implemented as properties. They work with open |
| 360 | and closed ports. |
| 361 | |
| 362 | .. attribute:: port |
| 363 | |
| 364 | Read or write port. When the port is already open, it will be closed |
| 365 | and reopened with the new setting. |
| 366 | |
| 367 | .. attribute:: baudrate |
| 368 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 369 | Read or write current baud rate setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 370 | |
| 371 | .. attribute:: bytesize |
| 372 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 373 | Read or write current data byte size setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 374 | |
| 375 | .. attribute:: parity |
| 376 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 377 | Read or write current parity setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 378 | |
| 379 | .. attribute:: stopbits |
| 380 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 381 | Read or write current stop bit width setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 382 | |
| 383 | .. attribute:: timeout |
| 384 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 385 | Read or write current read timeout setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 386 | |
| 387 | .. attribute:: writeTimeout |
| 388 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 389 | Read or write current write timeout setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 390 | |
| 391 | .. attribute:: xonxoff |
| 392 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 393 | Read or write current software flow control rate setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 394 | |
| 395 | .. attribute:: rtscts |
| 396 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 397 | Read or write current hardware flow control setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 398 | |
| 399 | .. attribute:: dsrdtr |
| 400 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 401 | Read or write current hardware flow control setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 402 | |
| 403 | .. attribute:: interCharTimeout |
| 404 | |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 405 | Read or write current inter character timeout setting. |
cliechti | edcdbe4 | 2009-07-22 00:48:34 +0000 | [diff] [blame] | 406 | |
| 407 | The following constants are also provided: |
| 408 | |
| 409 | .. attribute:: BAUDRATES |
| 410 | |
| 411 | A tuple of standard baud rate values. The actual device may support more |
| 412 | or less... |
| 413 | |
| 414 | .. attribute:: BYTESIZES |
| 415 | |
| 416 | A tuple of supported byte size values. |
| 417 | |
| 418 | .. attribute:: PARITIES |
| 419 | |
| 420 | A tuple of supported parity settings. |
| 421 | |
| 422 | .. attribute:: STOPBITS |
| 423 | |
| 424 | A tuple of supported stop bit settings. |
| 425 | |
| 426 | |
| 427 | |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 428 | Exceptions |
| 429 | ========== |
| 430 | |
| 431 | .. exception:: SerialException |
| 432 | |
| 433 | Base class for serial port exceptions. |
| 434 | |
| 435 | .. exception:: SerialTimeoutException |
| 436 | |
| 437 | Exception that is raised on write timeouts. |
| 438 | |
| 439 | |
| 440 | Constants |
| 441 | ========= |
| 442 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 443 | Parity |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 444 | ------ |
| 445 | .. data:: PARITY_NONE |
| 446 | .. data:: PARITY_EVEN |
| 447 | .. data:: PARITY_ODD |
| 448 | .. data:: PARITY_MARK |
| 449 | .. data:: PARITY_SPACE |
| 450 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 451 | Stopbits |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 452 | -------- |
| 453 | .. data:: STOPBITS_ONE |
| 454 | .. data:: STOPBITS_ONE_POINT_FIVE |
| 455 | .. data:: STOPBITS_TWO |
| 456 | |
cliechti | 5134aab | 2009-07-21 19:47:59 +0000 | [diff] [blame] | 457 | Bytesize |
cliechti | c1c3760 | 2009-07-21 01:34:57 +0000 | [diff] [blame] | 458 | -------- |
| 459 | .. data:: FIVEBITS |
| 460 | .. data:: SIXBITS |
| 461 | .. data:: SEVENBITS |
| 462 | .. data:: EIGHTBITS |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 463 | |
| 464 | Others |
| 465 | ------- |
cliechti | 6066f84 | 2009-07-24 00:05:45 +0000 | [diff] [blame] | 466 | Default control characters for software flow control. |
| 467 | |
cliechti | 5b7d16a | 2009-07-21 21:53:59 +0000 | [diff] [blame] | 468 | .. data:: XON |
| 469 | .. data:: XOFF |
cliechti | f81362e | 2009-07-25 03:44:33 +0000 | [diff] [blame^] | 470 | |
| 471 | Version |
| 472 | |
| 473 | .. data:: VERSION |
| 474 | |
| 475 | A string indicating the pySerial version, such as ``2.5``. |
| 476 | |
| 477 | Functions: |
| 478 | |
| 479 | .. function:: device(number) |
| 480 | |
| 481 | :param number: Port number. |
| 482 | :return: String containing device name. |
| 483 | :deprecated: Use device names directly. |
| 484 | |
| 485 | Convert a port number to a platform dependent device name. Unfortunately |
| 486 | this does not work well for all platforms; e.g. some may miss USB-Serial |
| 487 | converters and enumerate only internal serial ports. |
| 488 | |
| 489 | The conversion may be made off-line, that is, there is no guarantee that |
| 490 | the returned device name really exists on the system. |