Shop OBEX P1 Docs P2 Docs Learn Events
Differernce between fullduplex serial RX and RxCheck — Parallax Forums

Differernce between fullduplex serial RX and RxCheck

CRST1CRST1 Posts: 103
edited 2014-06-28 12:12 in Propeller 1
I'm trying to receive bytes from a xbee in command mode. When I send the +++ command and check the fullduplex serial buffer with Buffer[1] := serial.rx and Buffer[2] := serial.rx I get "O" in buffer[1] and "K" in buffer[2]. If I use serial.rxcheck they show up as two "." The variable buffer is a long aray. Why do I get different results just by changing between RX and RxCheck? Rx returnes a byte and RxCheck returnes a byte as long as there is a byte in the buffer acording to the docs. I don't understand the difference. Can anyone help?

Thank you

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-06-28 10:56
    Rx waits for a character and RxCheck either returns the character or a -1 if the buffer is empty. It's a good idea to use a temporary long sized variable to catch the return value of RxCheck so it can be compared properly with -1 but when a valid character is received, it should be saved to a byte sized buffer element. All the string handling commands use byte buffers and trying to store characters in a buffer of longs is likely to cause you trouble.

    I don't understand why RxCheck would be returning periods. You might want to post your code.

    Negative ones will have the value 255 or $FF in all four bytes. When displayed with a TV or VGA object this shows up as the infinity symbol. I don't know what it looks like in a terminal window.

    BTW, All Spin methods return a long. Often only the least significant byte is used but the return value is long sized.
  • CRST1CRST1 Posts: 103
    edited 2014-06-28 11:17
    This code sends back two periods
                buffer[1] := 0
                buffer[2] := 0
                fds.rxflush
                fds.str(string("+++"))
    
                waitcnt(80000000+cnt)
                buffer[1] := fds.rxcheck
                buffer[2] := fds.rxcheck
                waitcnt(80000000+cnt)
                fds.str(string("atcn"))
                fds.tx($0D)
                waitcnt(800000+cnt)  
                fds.str(string("test"))  
                fds.tx(buffer[1])
                fds.tx(buffer[2])
    

    This code sends back "OK"
                buffer[1] := 0
                buffer[2] := 0
                fds.rxflush
                fds.str(string("+++"))
    
                waitcnt(80000000+cnt)
                buffer[1] := fds.rx
                buffer[2] := fds.rx
                waitcnt(80000000+cnt)
                fds.str(string("atcn"))
                fds.tx($0D)
                waitcnt(800000+cnt)  
                fds.str(string("test"))  
                fds.tx(buffer[1])
                fds.tx(buffer[2])
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-06-28 11:40
    Add this code to the end of the second first set of code (and to the first second if you want).
               
                fds.tx(" ")
                fds.dec(buffer[1])  
                fds.tx(" ")
                fds.dec(buffer[2])
    

    What's the output from the extra code?

    Edit: The extra code needs to be added to the first set.
  • CRST1CRST1 Posts: 103
    edited 2014-06-28 12:12
    I found out the problem. Went out cut grass and cooled off in pool and it came to me. I was using this board with another project that needed speed so it has a 6mhz crystal and the pll was set to 16. I guess fullduplexserial doesn't like the overclock. Changed it to pll8 and it now works. Thanks for the tips.
Sign In or Register to comment.