Shop OBEX P1 Docs P2 Docs Learn Events
Extended FullDuplexSerial Object — Parallax Forums

Extended FullDuplexSerial Object

Martin HebelMartin Hebel Posts: 1,239
edited 2007-04-13 07:36 in Propeller 1
Hi All,
I have a lot of serial communication needs coming up between XBee and StampDAQ (and maybe a litte StampPlot), and while I appreciate FullDuplexSpin, it didn't have anything in place to accept alphanumeric strings or decimal strings directly, so I knew sooner or later I'd have to write those (hope they weren't already done and missed by me!) in my code or as a library.

So this object library, Extended_FDSerial, uses FullDuplexSerial and extends out those functions allowing reception of serial strings for decimal values, hex values, and alphanumeric, with and without timeouts.

From the documented part:
This object extends Chip Gracey's FullDuplexSerial to allow easy reception of
multiple bytes for decimal values, hex values and strings which end with carriage returns (ASCII 13)

Use as you would FullDuplex for Rx, Tx, Start, Stop, RxTime, RxCheck, RxFlush, DEC, HEX, BIN Str

Adds the following:
RxDec Returns decimal string as value
RxDecTime(ms) Returns decimal string as value with timeout
RxHex Returns received hex string value as decimal
RxHexTime(ms) Returns received hex string value as decimal with timeout
RxStr Passes received string
RxStrTime(ms) Passes received string with timeout

Hope it can help others, I'll see about getting it on the Object Exchange... if it hasn't been done already tongue.gif

-Martin

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·

Post Edited (Martin Hebel) : 1/9/2007 3:47:27 AM GMT

Comments

  • sonex293sonex293 Posts: 9
    edited 2007-01-09 03:29
    Look forward to seeing this! hop.gif

    I too have plans to do a lot of serial input and this sounds just like what I was looking for. Now if that 6.5" sunlight viewable display would show up and my engine monitor w/ serial output would ship, I'd be happy!

    --
    Michael
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-09 03:32
    Arrg, forgot to attach.... Thanks for saying "looking forward".... [noparse]:)[/noparse]

    -MH
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-14 18:52
    I just re-installed V1.0 of the tool, and it's part of "FullDuplexSerial" installed. Here's a copy of it.

    Keep me posted please.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • Brian RileyBrian Riley Posts: 626
    edited 2007-01-14 19:52
    Questions!

    - The recieved string terminated by ASCI 13, is the ASCII 13 passed as part of the string or is it stripped

    - Separators/terminators of numbers (DEC or HEX) ... is it ASCI 13 also, or 'white space' (tab, space, comma)?

    - "decimal numbers" ??? Actual decimals, or base-10 integer returned as a standard Propeller long?

    - Say I have the string "... 072.4357, ..." how would your routine be used to input and parse this?

    Inquiring mind wants to know <grin>!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cheers ... brian riley, n1bq, underhill center, vermont
    See the K107 Serial LCD Controller at
    www.wulfden.org/k107/
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-14 20:47
    Brian Riley said...
    Questions!

    - The recieved string terminated by ASCI 13, is the ASCII 13 passed as part of the string or is it stripped

    - Separators/terminators of numbers (DEC or HEX) ... is it ASCI 13 also, or 'white space' (tab, space, comma)?

    - "decimal numbers" ??? Actual decimals, or base-10 integer returned as a standard Propeller long?

    - Say I have the string "... 072.4357, ..." how would your routine be used to input and parse this?

    Inquiring mind wants to know <grin>!

    Hi Brian,
    It's not very sophisticated, but you are free to adapt to your own needs.

    Q: The recieved string terminated by ASCII 13, is the ASCII 13 passed as part of the string or is it stripped
    The ASCII 13 is not passed, it is stripped so you get only the string up to that point. Also, using StrTime, if the string reaches 15 characters, or the timeout is met, you get that portion of the string.

    Q: Separators/terminators of numbers (DEC or HEX) ... is it ASCI 13 also, or 'white space' (tab, space, comma)?
    Only ASCII 13 at this point, but it would be easy to add OR's for other delimiters. I guess a delimiter could have been passed, it would have been a nice addition.

    Q: "decimal numbers" ??? Actual decimals, or base-10 integer returned as a standard Propeller long?
    Working from the BASIC Stamp DEC, it refers only to integer values.

    Q: Say I have the string "... 072.4357, ..." how would your routine be used to input and parse this?
    Um.... I think it would give you a value of 724357 ignoring the decimal, but you could use a string to accept it instead then convert it to a float using another library object I think.

    I wrote it to meet many needs I often have, so didn't think bigger picture.
    -Martin
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-01-27 06:51
    <!--StartFragment -->·I've adapted "Extended_FDSerial" to allow the following:
    - Parsing based on defined delimiters. Default delimiter is ",",plus the CR is always used also.
    - Returning from a string the integer or whole value ("-123.456") returns -123
    - Returning from a string the fractional value ("-123.456") returns 456
    I though about trying to incorporate the floating point library, but with an AND or two, values can be checked against a reference, and these values can be used to pass to the floating point library if need be.

    The archived example included illustrates parsing a GPS string, such as: (·sent from the PC for testing):

    $GPRMC,235255,A,3524.3873,N,11901.4907,W,001.1,155.3,250107,014.0,E,A*04

    Not yet updated on the object Library.
    -Martin



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • Damien AllenDamien Allen Posts: 103
    edited 2007-02-03 14:00
    Hi I was wondering If you had any plans of adding any CRC routines to your extended full duplex serial object?
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2007-02-26 20:49
    I simply extended out Chip Gracey's FullDuplex, but in any case, error checking is best left up to a higher application level since what it checks (which bytes) and where and how are extremely different between systems.

    I'll be writing a version to support MaxStream's XBee's in API mode where I will implement their checksums, but again, that's a specific applications.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    StampPlot - GUI and Plotting, and XBee Wireless Adapters
    Southern Illinois University Carbondale, Electronic Systems Technologies
  • rokickirokicki Posts: 1,000
    edited 2007-02-26 21:59
    It would be really nice if the standard FullDuplex could be extended to:

    1. Have CONstants at the top defining the size of the input and output buffer;
    2. Have a flag indicating whether input overrun occurred.

    I know at least (1) has been done by some people, but it would be nice to have it
    folded into the standard release. As it is, it is very easy to overrun the input
    buffer and not realize it.
  • mirrormirror Posts: 322
    edited 2007-04-13 07:36
    rokicki said...
    It would be really nice if the standard FullDuplex could be extended to:

    1. Have CONstants at the top defining the size of the input and output buffer;
    2. Have a flag indicating whether input overrun occurred.

    I know at least (1) has been done by some people, but it would be nice to have it
    folded into the standard release. As it is, it is very easy to overrun the input
    buffer and not realize it.
    I don't know if this is the right way to do this, but I wanted something similar. FullDuplexSerial has been extended in the following ways:
    1) Constants at the top to set buffer sizes - power of 2.
    2) I use a·bigger buffer to avoid an input overrun - since my messages are a set length
    3) Check for a stop bit!! If·a stop bit·is not present then·the received byte is dropped (but no flags of any sort are set) and it's up to a higher level of code to check the message for integrity.
Sign In or Register to comment.