Shop OBEX P1 Docs P2 Docs Learn Events
Communicating prop to prop with FullDuplexSerialPlus — Parallax Forums

Communicating prop to prop with FullDuplexSerialPlus

RagtopRagtop Posts: 406
edited 2012-10-03 06:41 in Propeller 1
I am having trouble making a serial connection between two props. I am only using one wire connected
to TX pin of primary prop and to the RX pin of secondary prop (both pin 27) with both running FullDuplexSerialPlus
as ToSecondary and FromPrimary.

On Primary
ToSecondary.start(-1,27,0,57600)

On Secondary
FromPrimary.start(27,-1,0,57600)

When button is pressed on Primary it sends
ToSecondary.dec(1)

In a repeat loop on Secondary:
repeat 
  
       if FromPrimary.rxcheck <> -1
          FromPrimary.getdec(command)
          debug.str(string("............Received:  "))
          'debug.str(command)
          debug.str(string(13))
       'else
          debug.str(string("waiting"))

The program locks up on FromPrimary.getdec(command)
If I comment that out it will show Received string when I press button
on Primary prop so the rxcheck seems to be working........

At wits end. I have command as a long.

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-10-03 06:24
    It's usually better to attach the relevant code/objects. For example, the GetDec method in my version of FDS+ (1.1) doesn't take a parameter. That said, rxcheck returns the next available character (or -1) which means you're simply throwing it away. IOW, the "1" sent from the master is consumed and GetDec blocks waiting for another character.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-03 06:29
    The dec(1) statement will send a single byte with a value of $31. The rxcheck will read the $31. getdec reads a string of characters from the serial port until it encounters a carriage return. It will then interpret the string as a decimal number and return resulting value. You must be using a modified version of getdec because the one in FDSplus does not take a calling parameter.

    One of the problems is the the primary is no longer sending any characters, so the secondary is stuck waiting for a string of characters terminated by a carriage return.
  • RagtopRagtop Posts: 406
    edited 2012-10-03 06:41
    Actually that was after a mess of tries. It was command := FromPrimary.getdec

    Thank you, I think you have me on the right track now....as much as I have used serial objects
    I know little on how they actually work.

    So the primary needs to send some throw away bit to trigger the if statement, then the value I want and then a carriage return.
Sign In or Register to comment.