Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplex String Question — Parallax Forums

FullDuplex String Question

Brian CarpenterBrian Carpenter Posts: 728
edited 2010-11-01 22:12 in Propeller 1
I have a question concerning the printing of a string with FullDuplex to my PC.

I have been playing with the WiFly program that Rayman wrote. Instead of displaying that data to the 4.3 touch screen that he wrote it for, i would like to display the information to my PC via FullDuplex.
First, i will have to admit that i didnt understand the parsing of the data, but now i understand it.
    pSearch:=string("<br>")
    pos1:=pos2+1'SeekString(pos2+2,pSearch,@WebPageBuffer)
     
    pSearch:=string("<br>")                                        
    pos2:=SeekString(pos1+2,pSearch,@WebPageBuffer)
     
    'Print Weather
    repeat i from pos1+3 to pos2-1
      print(WebPageBuffer[i])
    print(13)

    pos2++
The top part is how he determines where the data is in the string that he wants. The second part is how he is printing it to his screen.

So if i know how to find the start of my string and the end of the string, how do i output it to FullDuplex?
I have a
PUB str(stringptr)

'' Send string                    

  repeat strsize(stringptr)
    tx(byte[stringptr++])
but that would print everything and not the range i want. So, what am i missing?

Comments

  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2010-11-01 21:56
    Looking at this some more....
    Knowing that i have pos1 and pos2, can i subtract the two and get the Length of the String and then modify the code and pass the value StringLength to fullduplex?
    PUB str(stringptr)
    
    '' Send string                    
    
      repeat strsize(StringLength)
        tx(byte[stringptr++])
    
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-01 22:07
    By convention, most string routines for the Propeller use the C convention of a zero byte as a string terminator so the starting address of the string can be passed around as the string itself. The str() routines used for most character I/O drivers assume this as you can see in the code for str() in FullDuplexSerial.

    There is no particular reason why you can't have other conventions. You can supply your own str() variation that uses two parameters, one a starting address and the other a string length like:
    PUB strTwo( addr, length )
       repeat length
          tx(byte[addr++])
    

    or this with a starting and ending address:
    PUB strThree(startAddr, endAddr)
       repeat endAddr - startAddr + 1
          tx(byte[startAddr++])
    
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2010-11-01 22:12
    thank you Mike Green. I will give that a try and see if i can make it work for me. I will report back.

    thanks again
Sign In or Register to comment.