serial module

Grant Edwards invalid at invalid.invalid
Tue May 22 11:42:15 EDT 2012


On 2012-05-22, Albert van der Horst <albert at spenarnc.xs4all.nl> wrote:

>># configure the serial connections (the parameters differs on the device
>># you are connecting to)
>>ser = serial.Serial(
>>        port='/dev/ttyUSB0',
>>        baudrate=19200,
>>        parity=serial.PARITY_ODD,
>>        stopbits=serial.STOPBITS_TWO,
>>        bytesize=serial.SEVENBITS
>>)
>>
>>ser.open()
>>
>>Why do I get this error?
>
> You realize that these parameters relate to RS232 ports?

/dev/ttyUSB0 is a serial port. In all likelyhood an RS-232 port, but
it could be RS-485 or RS-422 or some other physical layer.  In anycase
it works just like a "normal" serial port such as /dev/ttyS0.

> It is anybody's guess what they do in USB.

They do exactly what they're supposed to regardless of what sort of
bus is used to connect the CPU and the UART (ISA, PCI, PCI-express,
USB, Ethernet, etc.).

> The best answers is probably that it depends on the whim of whoever
> implements the usb device.

It does not depend on anybody's whim.  The meaning of those parameters
is well-defined.

> Certainly this stuff is system dependant,

No, it isn't.

> so please start with stating which version kernel etc. of Linux you
> run, and the output of lsusb --verbose.

There's very probably no need for that.

The drivers for the various USB-attached serial ports all work pretty
much exactly like the normal ISA/PCI-attached drivers.  The main
things you'll notice are differences in buffer/fifo sizes and the
timing of things like commands to set/clear modem control lines.

-- 
Grant Edwards               grant.b.edwards        Yow! I didn't order any
                                  at               WOO-WOO ... Maybe a YUBBA
                              gmail.com            ... But no WOO-WOO!



More information about the Python-list mailing list