Python serial data aquisition

Flavio codeco coelho fccoelho at
Sun Jan 9 17:13:28 EST 2005


I am using pyserial to acquire data from an A/D converter plugged to
my serial port.

my hardware represents analog voltages as 12bit numbers. So, according
to the manufacturer, this number will be stored in two bytes like
Byte1: x  x   x   n1 n2 n3   n4   n5
Byte2: x  n6 n7 n8 n9 n10 n11 n12

where x is some other information, and nx are the digits of my number.

My problem is to how to recover my reading from these bytes, since
pyserial gives me a character (string) from each byte... I dont know
how to throw away the   unneeded bits and concatenate the remaining
bits to form a number...

Flávio Codeço Coelho

More information about the Python-list mailing list