Shop OBEX P1 Docs P2 Docs Learn Events
Full Duplex Serial — Parallax Forums

Full Duplex Serial

172heavy172heavy Posts: 55
edited 2010-09-14 17:42 in Propeller 1
I am new to the prop so please excuse this basic question, I have been experimenting with the full duplex serial and I have figured out how to send data to a terminal program, my question is this, How is this object designed to recieve and store data? If I want to receive a string or dec or whatever what needs to be done? Where do I store it? I am assuming I need a variable but how do I point the received byte(s) to the variable?

Thanks in Advance

Josh

Comments

  • 172heavy172heavy Posts: 55
    edited 2010-09-12 13:36
    ........Is this one a stumper or what?
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-09-12 13:43
    172heavy wrote: »
    ........Is this one a stumper or what?

    You might take a look at the pages starting around pp. 95-100, 103, etc, of the free downloadable PE Labs Fun book:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf

    hope that helps,
    :)
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-09-12 13:45
    Hello and Welcome to the Prop-Forum !

    variables in SPIN are bytes (8bit), words (16bit) or longs (32bit).

    FullDuplexSerial (short FDX) works with bytes

    So for receiving a single byte you have to declare a bytevariable
    VAR
      byte MyReceivedByte 
    

    If you want to receive strings you have to declare an array of bytes
    VAR
      byte MyByteArray[ 11 ]
    

    ATTENTION! Your bytearray has to be one byte longer than your maximum
    stringlength you want to receive. In the last byte a zero is stored to indicate the end of the string

    So called zero-terminated strings.
    If you want to access single bytes of this string the index starts at zero
      MyByteArray[ 0 ] 
    

    for receiving strings you should use FullDuplexSerialPlus
    which provides a method "getstr"
    PUB getstr(stringptr) | index
        '' Gets zero terminated string and stores it, starting at the stringptr memory address
        index~
        repeat until ((byte[stringptr][index++] := rx) == 13)
        byte[stringptr][--index]~ 
    

    that alreday does the details of receiving the bytes
    The parameter is a long that points to bytearray

    @the forum:

    I don't have example-code for receiving strings handy

    can someone post a working example?

    best regards

    Stefan
  • 172heavy172heavy Posts: 55
    edited 2010-09-12 13:55
    Thanks guys, this should be enough of a push, I hope the "stumper" comment didn't come off as rude I sometimes type before I think, I really appreciate your input!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-12 14:31
    In the Propeller Object Exchange, there's an object that does much of what you want. Basically, it sits between your program and FullDuplexSerial and provides some methods to input decimal, hexadecimal, and text strings and convert them to a useful format. Have a look at it.
  • 172heavy172heavy Posts: 55
    edited 2010-09-12 16:44
    So I have been looking for the FullDuplexSerialPlus in the OBEX and I cannot find it, any pointers?
  • 172heavy172heavy Posts: 55
    edited 2010-09-12 16:57
    172heavy wrote: »
    So I have been looking for the FullDuplexSerialPlus in the OBEX and I cannot find it, any pointers?

    Nevermind, I found it........
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-09-12 21:13
    Welcome to the forum. You will find this a fantastic forum with help from many people only questions away. And you will love the prop!!
  • 172heavy172heavy Posts: 55
    edited 2010-09-12 21:50
    Is it possible to get the get.string command to wait in this object? or count characters?

    For Example if I have a string if data coming in like this,

    $GMRMC,1234.555,N,1234,5555,W Etc........ If I only want to save the first "1234" how can I do this if I want to count 7 characters and then capture 4


    PUB rx : rxbyte

    '' Receives byte (may wait for byte)
    '' rxbyte returns $00..$FF

    repeat while (rxbyte := rxcheck) < 0

    I can do this using my BS2, but I wanted to try to move up to the PROP.........
  • wjsteelewjsteele Posts: 697
    edited 2010-09-13 04:16
    Hi 172Heavy,

    First off, I love the name... But I guess only pilots would get it. ;-)

    Second, there is another object in the OBEX that does exactly what you are looking for. It's called GPS_IO. It uses FullDuplexSerial and adds specific parsing functions for handling NMEA strings.

    I've modified it for several other string parsers, which is quite easy to do once you see how it works.

    Bill
  • 172heavy172heavy Posts: 55
    edited 2010-09-13 20:28
    wjsteele wrote: »
    Hi 172Heavy,

    First off, I love the name... But I guess only pilots would get it. ;-)

    Second, there is another object in the OBEX that does exactly what you are looking for. It's called GPS_IO. It uses FullDuplexSerial and adds specific parsing functions for handling NMEA strings.

    I've modified it for several other string parsers, which is quite easy to do once you see how it works.

    Bill


    Thank you, I appreciate the compliment and the advice. I like your picture by the way, what are you flying?
  • 172heavy172heavy Posts: 55
    edited 2010-09-13 21:09
    Bill,

    I have checked the OBEX and I cannot find the GPS_IO do you have a copy you could email to me or do you know where it is? It looks like there are several other Objects that will help though.

    Thanks
  • ratronicratronic Posts: 1,451
    edited 2010-09-13 21:41
    172heavy - I'm not sure if this is the one wjsteele was talking about but this one contains a gps parsing file called GPS_IO_mini.spin that I use.
  • 172heavy172heavy Posts: 55
    edited 2010-09-14 13:26
    ratronic wrote: »
    172heavy - I'm not sure if this is the one wjsteele was talking about but this one contains a gps parsing file called GPS_IO_mini.spin that I use.


    Dave, that is exactly what I was looking for! You and Bill have been a great help!

    Is that a tail number I spot on your sig line?
  • w8anw8an Posts: 176
    edited 2010-09-14 17:20
    172heavy wrote: »
    Is that a tail number I spot on your sig line?

    I believe that is a ham (amateur radio) callsign. You'll find many hams hanging around in this forum.

    Steve
  • ratronicratronic Posts: 1,451
    edited 2010-09-14 17:42
    yes 172heavy that is my amateur radio call sign.
Sign In or Register to comment.