Greetings!
I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit http://openeeg.sourceforge.net)
The analogue output is amplified and processed via an ADC (in an ATmega8 microcontroller) and is converted to RS232 by a MAX232.
The RS232 Signal is as follows:
Byte 1: sync value 0xa5
Byte 2: sync value 0x5a
Byte 3: version
Byte 4: Frame number
Byte 5: Channel 1 Low Byte
Byte 6: Channel 1 High Byte
Byte 7: Channel 2 Low Byte
Byte 8: Channel 2 High Byte
...
Bytes 9-16 are for extra electrode channels but data not required since only using the first two
...
Byte 17: Button states (b1-b4)
I've got some basic PySerial functionality but I need to figure a way to make use of the incoming data by buffering it and plotting the useful values as 2 real-time x-y waveforms (time vs voltage)
Question update:
I'm getting the code to print with the obvious few lines of PySerial but it's gibberish. I'm trying to strip the data down in to the format of values that can then be plotted. The 17 bytes of data is currently coming in at 256 frames/sec. The (two) channels are made up 10 bits of data each (with 6 zeros to make up the rest of the 2 bytes). They are unsigned giving possible values of 0 to 1023. These correspond to values that should be plotted as positive and negative, so a binary value of 512 corresponds to a plot of zero (micro)volts....
How do I read the incoming stream as 8 bit binary (stripping out the data that I don't need), then combine the two relevant bytes from each channel that I want (possibly removing the surplus 6 zeros if necessary)?