SimpleIDE- XBEE Test
tdlivings
Posts: 437
With the release of Propeller C on Monday I decided to try it out.
Since I was playing around with logging Humidity measurements using XBEE why not
see how it works in the new stuff.
There was no XBEE Device in the Simple Libraries but thinking about it the XBEE is just
a serial device so went looking for a Serial library and then realiazed in the "C" world that
could mean it looks like a FILE and found in SimpleTools.h that there was indeed a FullDuplexSerial.
I did get it working after putting on my "C" style file I/O hat, the hat is old and dusty.
However I would prefer a non "C" style everything has to look like a FILE ie terminal, paper tape reader
etc. for a Serial Library for things like the XBEE.
For what I am doing now the FILE concept works what I am sending by XBEE is a line of text with CRLF
at the end of each line so it for all practical purposes looks like a TEXT FILE to "C" and it does not care it
came in over the air. Using the XBEE in API mode, unless I need deeper knowledge of the FILE* modes
I do not see doing that this way.
I attached a couple of screen pics one of the code and one of the terminal showing lines coming in.
I attached a pic of code so as to keep the coloring and show what is commented out.
I tried a couple of "C" style file I/O concepts. The one not commented out is the only one that worked.
fgetc() never returns just hangs even though the lights on the board a blinking.
fread() works but you have to play with the number of characters to read and it gets out of sync doing incomplete
lines. Not something to trust, I am not sure to totally trust what is working fgets() but it has sat here for over an hour
with all the lines looking right and no hic ups.
fgets() looks for the number of characters or an end of line \n and seems to be just right for what I am sending.
The lines are sent every 15 seconds at 9600 baud so there is plenty of time for the code to process each line.
I miss something like Serial.Avaliable() or rxcheck() to get each char and process it watching for end of line.
I started off thinking fgetc() would do that but it returns nothing.
Tom
Since I was playing around with logging Humidity measurements using XBEE why not
see how it works in the new stuff.
There was no XBEE Device in the Simple Libraries but thinking about it the XBEE is just
a serial device so went looking for a Serial library and then realiazed in the "C" world that
could mean it looks like a FILE and found in SimpleTools.h that there was indeed a FullDuplexSerial.
I did get it working after putting on my "C" style file I/O hat, the hat is old and dusty.
However I would prefer a non "C" style everything has to look like a FILE ie terminal, paper tape reader
etc. for a Serial Library for things like the XBEE.
For what I am doing now the FILE concept works what I am sending by XBEE is a line of text with CRLF
at the end of each line so it for all practical purposes looks like a TEXT FILE to "C" and it does not care it
came in over the air. Using the XBEE in API mode, unless I need deeper knowledge of the FILE* modes
I do not see doing that this way.
I attached a couple of screen pics one of the code and one of the terminal showing lines coming in.
I attached a pic of code so as to keep the coloring and show what is commented out.
I tried a couple of "C" style file I/O concepts. The one not commented out is the only one that worked.
fgetc() never returns just hangs even though the lights on the board a blinking.
fread() works but you have to play with the number of characters to read and it gets out of sync doing incomplete
lines. Not something to trust, I am not sure to totally trust what is working fgets() but it has sat here for over an hour
with all the lines looking right and no hic ups.
fgets() looks for the number of characters or an end of line \n and seems to be just right for what I am sending.
The lines are sent every 15 seconds at 9600 baud so there is plenty of time for the code to process each line.
I miss something like Serial.Avaliable() or rxcheck() to get each char and process it watching for end of line.
I started off thinking fgetc() would do that but it returns nothing.
Tom
Comments
Read the .h file for help. It is basically a port of Chip's FullDuplexSerial opbject I wrote 5 years ago.
If that doesn't fit your needs, please let me know.
I will take a look at it.
Ok tryed out you "C" version of Full Duplex Serial and it worked as expected.
A quick test to see if it builds and does something.