Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial Assistance Needed — Parallax Forums

FullDuplexSerial Assistance Needed

Brian CarpenterBrian Carpenter Posts: 728
edited 2009-08-21 09:19 in Propeller 1
Ok, how to start.·
I am currently using the FullSerialDuplex object from the object exchange and i am sending data (strings) out the .tx· i have been doing this successfully for a while now.· But what i want to do is also recieve data back.· I have done this in one program.
    repeat until ser.rx == "#"                  ' wait for start char
    
    ch := sock.rxtime(250)                       ' get response code
    
    if ch <> "0"


but all this gets me is one character.·

What if i want to recieve data like·· #1042,123,1513,1232,1220$

I was thinking that the # would let the rx know that it is the beginning and the $ would signify the end?



how do i get all this stored into a variable. or better yet, parse between comma's and store several variables.

i am stumped and would love to see an example

Thanks



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


It's Only A Stupid Question If You Have Not Googled It First!!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-20 05:04
    I think the FullDuplexSerialPlus object from the Object Exchange includes routines to convert numeric values to numbers and you could use that as a starting point. The routine in FullDuplexSerialPlus uses a carriage return to delimit numbers, but you could change the routine to use any of several characters to mark the end of the numbers.

    Post Edited (Mike Green) : 8/20/2009 5:09:56 AM GMT
  • SRLMSRLM Posts: 5,045
    edited 2009-08-20 05:46
    It looks like you'll need to change (in FullDuplexSerialPlus.spin) line 176 to compare to the value of 44 (instead of 0, after the equal sign). Then do the same thing with line 140 (except that it's replacing a $0D). From there, you should be able to just call GetDec. Of course, it would mean that if you also wanted to get strings you'd have to made some changes (probably an OR or two). Once you have that, something like this might work:

    repeat until ser.rx == "#"
    
    num1 := ser.getdec
    num2 := ser.getdec
    ...
    
    



    edit: you'll probably have to have an OR on those two lines, since there are multiple possibilities for end of number ( "," and "$"). On a side note, if you have control over the serial stream you may want to put the $ first, just to be consistent with NMEA GPS strings. Also, if you do have control and you always know how many numbers are transmitted in a string, you might as well end it with another ','.

    Post Edited (SRLM) : 8/20/2009 5:51:54 AM GMT
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-08-20 06:06
    rtxtime returns a value >= 0 when a char is available, -1 if it timed out.
    IIRC!

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2009-08-21 04:16
    Mike i searched for FullDuplexSerialPlus and found nothing. Am i missing something?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-21 04:30
    Well, it's "Extended FullDuplexSerial": obex.parallax.com/objects/31/.

    Shows you the value of browsing through the index rather than searching. If at first you don't succeed, go browse. It takes less than a minute!
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2009-08-21 04:33
    Thanks Mike, I did find the extended FullDuplexSerial. I wanted to make sure i was looking at the one you were making reference to. Thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • SRLMSRLM Posts: 5,045
    edited 2009-08-21 04:40
    What happened to FDSP? I have a copy on my machine by that very name, and I'm pretty sure I got it through downloading.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-08-21 09:19
    FullDuplexSerialPlus FDS+ FDX+ is included in the setupfile of the propellertool but after installing it it is someway hided in the subsubdir

    C:\Program Files\Parallax Inc\Propeller Tool v1.2.6\Examples\PE Kit\6 - Objects Lab

    in similar cases do a search for *plus*.spin in directory "Propeller Tool v1.2.6" including all subdirectories.
    By the way and somehow OT: the tool Instant File Name Search
    scans my entire harddisk with over 360.000 files within 30 seconds if PC is not busy and in 3 minutes if PC is busy
    After scanning searching for a filename is done in less than 1 second ! never wanna miss this tool again

    best regards
    Stefan

    Post Edited (StefanL38) : 8/21/2009 9:26:19 AM GMT
Sign In or Register to comment.