Shop OBEX P1 Docs P2 Docs Learn Events
Sending variable data to propeller II Using PST — Parallax Forums

Sending variable data to propeller II Using PST

Using the fullduplex serial object with PST Is there a "standard convention" spin routine (object) for propeller II to receive variable data entered from the PST. "Convert numbers to strings" Author.... Jon McPhalen is very useful to go from Propeller II to PST is there a routine for "Convert string to numbers" and a convention for setting up variables to send from PST to propeller II.
Regards
Bob Drury (WRD)

Comments

  • To do this, use the STR and VAL procedures.

  • Thanks for response. Not sure what you mean by procedures. Using spin2.

  • Cluso99Cluso99 Posts: 18,069

    See my 16 port serial objects. There is a RxStr for receiving strings. It’s based on jonnymacs serial so most of the calls are the same (a few have tx prefixes and there’s a txdunp too.

  • The PST object used in the Propeller 1 has a "DecIn" method which is commonly used for this purpose.
    Here's a similar method I use with the P2.

    PUB DecIn() : valueEntered | sign, tempValue, localCharacter
    { Characters other than numbers, minus, and carriage return are ignored.}
      valueEntered := 0
      sign := 1
      repeat
        localCharacter := Usb.Rx()
        case localCharacter
          "-":
            sign := -1
          "0".."9":
            valueEntered *= 10
            valueEntered += localCharacter - "0"
          13:
            'Don't chime bell.
          other:
            Usb.Tx(Usb.BELL)  { Other characters trigger a bell but are otherwise ignored. This may be removed.}
      until localCharacter == 13
    
      valueEntered *= sign
    

    This method doesn't limit the number of characters. I'd be happy to modify the code if you need to limit the number of characters.
    I'm pretty sure there are better ways to do this. This is just one option.

  • Thanks Cluso99 and Duane Degn I will try out the info
    Regards
    Bob Drury

Sign In or Register to comment.