Skip to content

Instantly share code, notes, and snippets.

@rudolph9
Created June 10, 2013 19:22
Show Gist options
  • Save rudolph9/5751446 to your computer and use it in GitHub Desktop.
Save rudolph9/5751446 to your computer and use it in GitHub Desktop.
MicroAeth
>>> microAeth = serial.Serial('/dev/ttyUSB1', 500000, timeout=1, parity=serial.PARITY_MARK)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 261, in __init__
self.open()
File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 282, in open
self._reconfigurePort()
File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 376, in _reconfigurePort
raise ValueError('Invalid parity: %r' % self._parity)
ValueError: Invalid parity: 'M'
>>> microAeth = serial.Serial('/dev/ttyUSB1', 500000, timeout=1, parity=serial.PARITY_NONE)
>>> microAeth.readline()
'\x0e\x08\n'
>>> microAeth.readline()
'\x00d\x00\x03\x04\x05\x06\x07\x08\t\n'
>>> microAeth.readline()
'\x0b\x0c\x8d\x03\x02%AE5X:MYO\r0\xf5\x0c\xb4\xb2\x0c0\x00!\r\x06\n'
>>> microAeth.readline()
'\x0e\x08\x0b\x00d\x00\x03\x04\x05\x06\x07\x08\t\n'
>>> daq = serial.Serial('/dev/ttyUSB0', 38400, timeout=1, parity=serial.PARITY_NONE)
>>> daq.readline()
' 419133.0, 382, 3, over, 11426, over\r\n'
>>> daq.readline()
' 419134.0, 382, 3, over, 8053, over\r\n'
>>> daq.readline()
' 419135.0, 382, 3, over, 11661, over\r\n'
@rudolph9
Copy link
Author

Update to serialposix.py to accept M Parity

        elif self._parity == PARITY_MARK:
            cflag &= ~(TERMIOS.PARODD)
            cflag |=  (TERMIOS.PARMRK)

Accessing the microAeth there after

>>> import serial
>>> microAeth = serial.Serial('/dev/ttyUSB1', 500000, timeout=1,  parity=serial.PARITY_MARK)
>>> microAeth.readline()
'\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02%AE5X:Mp9\r\x7f\xd0\x0c\xdb\xac\x0c2\x00%\r\x06\n'
>>> microAeth.readline()
'\x103(\x00d\x00\x03\x04\x05\x06\x07\x08\t\n'
>>> microAeth.readline()
'\x0b\x0c\xd1\x03\x02%AE5X:MN9\r|\xd0\x0c\xf3\xac\x0c0\x00%\r\x06\n'

@rudolph9
Copy link
Author

>>> while 1:
...      hex(ord(microAeth.read()))
...
'0x2'
'0x25'
'0x41'
'0x45'
'0x35'
'0x58'
'0x3a'
'0x4d'
'0x34'
'0x37'
'0xd'
'0x21'
'0xc0'
'0xc'
'0xbf'
'0xab'
'0xc'
'0x32'
'0x0'
'0x26'
'0xd'
'0x6'
'0xa'
'0x12'
'0x34'
'0x34'
'0x0'
'0x64'
'0x0'
'0x3'
'0x4'
'0x5'
'0x6'
'0x7'
'0x8'
'0x9'
'0xa'
'0xb'
'0xc'
'0xac'
'0x3'
'0x2'
'0x25'
'0x41'
'0x45'
'0x35'
'0x58'
'0x3a'
'0x4d'
'0x42'
'0x37'
'0xd'
'0x36'
'0xc0'
'0xc'
'0xce'
'0xab'
'0xc'
'0x30'
'0x0'
'0x26'
'0xd'
'0x6'
'0xa'
'0x12'
'0x34'
'0x35'
'0x0'
'0x64'
'0x0'
'0x3'
'0x4'
'0x5'
'0x6'
'0x7'
'0x8'
'0x9'
'0xa'
'0xb'
'0xc'
'0xbf'
'0x3'
'0x2'
'0x25'
'0x41'
'0x45'
'0x35'
'0x58'
'0x3a'
'0x4d'
'0x56'
'0x37'
'0xd'
'0x40'
'0xc0'
'0xc'
'0xd7'
'0xab'
'0xc'
'0x32'
'0x0'
'0x26'
'0xd'
'0x6'
'0xa'
'0x12'
'0x34'
'0x36'
'0x0'
'0x64'
'0x0'
'0x3'
'0x4'
'0x5'
'0x6'
'0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2d'
'0x3'
'0x2'
'0x25'
'0x41'
'0x45'
'0x35'
'0x58'
'0x3a'
'0x4d'
'0xf6'
'0x36'
'0xd'
'0xef'
'0xbf'
'0xc'
'0x9c'
'0xab'
'0xc'
'0x31'
'0x0'
'0x26'
'0xd'
'0x6'
'0xa'
'0x12'
'0x35'
'0x3'
'0x0'
'0x64'
'0x0'
'0x3'
'0x4'
'0x5'
'0x6'
'0x7'
'0x8'
'0x9'
'0xa'
'0xb'
'0xc'
'0xc8'
'0x3'
'0x2'
'0x25'
'0x41'
'0x45'
'0x35'
'0x58'
'0x3a'
'0x4d'
'0xe3'
'0x36'
'0xd'
'0xec'
'0xbf'
'0xc'
'0x97'
'0xab'
'0xc'
'0x30'
'0x0'
'0x26'
'0xd'
'0x6'
'0xa'
'0x12'
'0x35'
'0x4'
'0x0'
'0x64'
'0x0'
'0x3'
'0x4'
'0x5'
'0x6'
'0x7'
'0x8'
'0x9'
'0xa'
'0xb'
'0xc'
'0xd3'
'0x3'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment