Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE- XBEE Test — Parallax Forums

SimpleIDE- XBEE Test

tdlivingstdlivings Posts: 437
edited 2013-05-11 11:48 in Propeller 1
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
538 x 558 - 103K
793 x 748 - 187K

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-05-10 14:40
    Please just use this instead: http://forums.parallax.com/attachment.php?attachmentid=99241&d=1360890415

    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.
  • tdlivingstdlivings Posts: 437
    edited 2013-05-10 15:15
    Thank's jazzed,
    I will take a look at it.
  • tdlivingstdlivings Posts: 437
    edited 2013-05-11 11:48
    @jazzed
    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.
    /*
      Test C version of Full Duplex Serial code
    
      from Steve(jazzed)
    
    */
    
    
    
    
    #include "simpletools.h"                      // Include simple tools
    
    #include "FdSerial.h"                         // Add Steve(jazzed) FullDuplexSerial C version
    
    int RX = 5, TX = 4;                           // XBEE connected pins
    
    int main()                                    // Main function
    
    {
    
      // Add startup code here.
    
      pause(1000);
    
      FdSerial_start(RX,TX,0,9600);              // Full Duplex serial to XBEE
    
      char s[40];
    
      putchar(CLS);                              // Clear terminal screen
    
      FdSerial_rxflush();                        // Clear Serial Buffer
    
      pause(100);
    
    
    
    
      while(1)                                    // Repeat indefinitely
    
      {
    
        // Add main loop code here.
    
    
    
    
        int ch = FdSerial_rxcheck();
    
        if( ch != -1) {
    
          printf("%c",ch);
    
        }    
    
      }  
    
    }
    
    
    
    
Sign In or Register to comment.