10 thoughts on “reading binary data in serial buffer”
On the 862 module the script SER.read() returned the binary data that is held in the serial buffer at the time of it being read) but this does not work on the GE910-EUG. Even though binary data is definitely sent to the serial port, SER.read() or SER.readbyte() do not return anything. If I send ASCII then it works but not for binary – I am sure the answer is siimple but please point me in the right direction, many thanks
SER read methods do not make any difference of data input type, is just a stream of bytes, is up to the receiving software to get it right, ie if expects to read NULL terminated strings better use readbyte, if binary data like a JPEG image read() can be used.
Please provide a sample script, data input and output.
SER.set_speed does not take three parameters but two (no flow control) so your port is not open at all, check for en axception at that line or function return which can be -1 (error occured).
The data logger i am using randomly sends out binary data via a
Serial lead , my app is to periodically check for this data and then
send it on in entirety unchanged to my server
In the script:
in my configuration set up I use the line below
SER.set_speed(‘19200′,’8N1′,’hw’)
(i have also tried SER.set_speed(‘19200′,’8N1′,’none’)
then the main program has a loop which always passes the following code:
b = SER.read() time.sleep(3) print ‘checked serial port’ if (b == -1) or (b == 0 ) or (b == ”) or (b == ‘ ‘ ): print ‘no data found’ else: print ‘data found:’,b try: f = open(‘file1.hex’,’w’) f.write(b) f.close()
etc…….
in
the debugger i can see that i never get to the line ***** print ‘data
found:’,b **** but I can see that the data has been looked for.
However:
1) when i switch the data logger for a direct
serial connection between the Telit module and the hyperterminal on my
PC the app works.
2) when i put the data logger serial lead
directly into my PC i can see the binary data coming through in the
hyperterminal.
3) i have had this script working as above on an earlier module without GPS but i upgraded to the 910 because i needed GPS
Thanks for helping.
The data logger i am using randomly sends out binary data via a Serial lead , my app is to periodically check for this data and then send it on in entirety unchanged to my server
In the script:
in my configuration set up I use the line below
SER.set_speed(‘19200′,’8N1′,’hw’)
(i have also tried SER.set_speed(‘19200′,’8N1′,’none’)
then the main program has a loop which always passes the following code:
b = SER.read() time.sleep(3) print ‘checked serial port’ if (b == -1) or (b == 0 ) or (b == ”) or (b == ‘ ‘ ): print ‘no data found’ else: print ‘data found:’,b try: f = open(‘file1.hex’,’w’) f.write(b) f.close()
etc…….
in the debugger i can see that i never get to the line ***** print ‘data found:’,b **** but I can see that the data has been looked for. However:
1) when i switch the data logger for a direct serial connection between the Telit module and the hyperterminal on my PC the app works.
2) when i put the data logger serial lead directly into my PC i can see the binary data coming through in the hyperterminal.
3) i have had this script working as above on an earlier module without GPS but i upgraded to the 910 because i needed GPS
Thanks for helping.
Sorry if this is a duplicate!
In my configuration set up i am using SER.set_speed(‘19200′,’8N1′,’hw’) but have also tried ‘none’.
in the main loop I am using
b = SER.read() time.sleep(3) print ‘checked serial port’ if (b == -1) or (b == 0 ) or (b == ”) or (b == ‘ ‘ ): print ‘no data found’ else: print ‘data found:’,b try: f = open(‘file1.hex’,’w’)
etc……………
I can see from the debugger that i don’t ever get to *** print ‘data found:’,b ****
The app consists of a datalogger that randomly sends binary data via a serial lead. This datalogger is directly connected to the serial port on the Telit module. The script periodically looks for data on the serial port.
However,
1) If i connect my data logger directly to my PC i can see the binary data in the hyperterminal
2) If i connect a serial lead from the PC direclty to the Telit module i can send data and see that this is OK through the debugger and that the script picks it up and sends it to my server
Thanks for your help in this……………..
Have you read my answer above?
yes thank you i will try it as soon as i can this afternoon
… or the port is left open but with the wrong baudrate, still not receiving anything.
! used the 3rd parameter in set_speed because i am running 12.00.214 software and i saw it in section 4.3.6 of the python easy script 2.7 documentation but i will try without this parameter. Also i will set the baud rate at 19,200 within the main loop.
thanks
Ah OK but still check its return value.
And to check if data is returned better use len(b), SER.read returning string type.
We use cookies to enhance your browsing experience and help us improve our websites. To improve our website, we carefully select third parties that use cookies to allow us to serve specific content and achieve the purposes set out in our cookie policy. For more information on how to make adjustments through your browser to the cookies being used on your device, please click Find Out More link. By closing this banner or continuing to browse our website, you agree to our use of such cookies. FIND OUT MORE
On the 862 module the script SER.read() returned the binary data that is held in the serial buffer at the time of it being read) but this does not work on the GE910-EUG. Even though binary data is definitely sent to the serial port, SER.read() or SER.readbyte() do not return anything. If I send ASCII then it works but not for binary – I am sure the answer is siimple but please point me in the right direction, many thanks
SER read methods do not make any difference of data input type, is just a stream of bytes, is up to the receiving software to get it right, ie if expects to read NULL terminated strings better use readbyte, if binary data like a JPEG image read() can be used.
Please provide a sample script, data input and output.
SER.set_speed does not take three parameters but two (no flow control) so your port is not open at all, check for en axception at that line or function return which can be -1 (error occured).
The data logger i am using randomly sends out binary data via a Serial lead , my app is to periodically check for this data and then send it on in entirety unchanged to my server
In the script:
in my configuration set up I use the line below
SER.set_speed(‘19200′,’8N1′,’hw’)
(i have also tried SER.set_speed(‘19200′,’8N1′,’none’)
then the main program has a loop which always passes the following code:
b = SER.read()
time.sleep(3)
print ‘checked serial port’
if (b == -1) or (b == 0 ) or (b == ”) or (b == ‘ ‘ ):
print ‘no data found’
else:
print ‘data found:’,b
try:
f = open(‘file1.hex’,’w’)
f.write(b)
f.close()
etc…….
in the debugger i can see that i never get to the line ***** print ‘data found:’,b **** but I can see that the data has been looked for. However:
1) when i switch the data logger for a direct serial connection between the Telit module and the hyperterminal on my PC the app works.
2) when i put the data logger serial lead directly into my PC i can see the binary data coming through in the hyperterminal.
3) i have had this script working as above on an earlier module without GPS but i upgraded to the 910 because i needed GPS
Thanks for helping.
Sorry if this is a duplicate!
In my configuration set up i am using SER.set_speed(‘19200′,’8N1′,’hw’) but have also tried ‘none’.
in the main loop I am using
b = SER.read()
time.sleep(3)
print ‘checked serial port’
if (b == -1) or (b == 0 ) or (b == ”) or (b == ‘ ‘ ):
print ‘no data found’
else:
print ‘data found:’,b
try:
f = open(‘file1.hex’,’w’)
etc……………
I can see from the debugger that i don’t ever get to *** print ‘data found:’,b ****
The app consists of a datalogger that randomly sends binary data via a serial lead. This datalogger is directly connected to the serial port on the Telit module. The script periodically looks for data on the serial port.
However,
1) If i connect my data logger directly to my PC i can see the binary data in the hyperterminal
2) If i connect a serial lead from the PC direclty to the Telit module i can send data and see that this is OK through the debugger and that the script picks it up and sends it to my server
Thanks for your help in this……………..
Have you read my answer above?
yes thank you i will try it as soon as i can this afternoon
… or the port is left open but with the wrong baudrate, still not receiving anything.
! used the 3rd parameter in set_speed because i am running 12.00.214 software and i saw it in section 4.3.6 of the python easy script 2.7 documentation but i will try without this parameter. Also i will set the baud rate at 19,200 within the main loop.
thanks
Ah OK but still check its return value.
And to check if data is returned better use len(b), SER.read returning string type.