Shop OBEX P1 Docs P2 Docs Learn Events
Full Duplex Serial — Parallax Forums

Full Duplex Serial

NewzedNewzed Posts: 2,503
edited 2007-09-04 00:02 in Propeller 1
I·am using FullDuplex so my Proto Board can commnicate with Hyper, and everything works fine.· Now i want to send a word -35000 - to Hyper but the FullDuplex method comm.rx will only handle a byte.· How do I modify FullDuplex so I can send a word terminated with Enter?

Thanks

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com
·

Comments

  • Mike CookMike Cook Posts: 829
    edited 2007-09-03 15:51
    Sid,

    If possible use FullDuplexSerial.spin from the Propeller Tool v1.05.5, it has the dec method you are looking for.


    PUB dec(value) | i
    '' Print a decimal number
      if value < 0
        -value
        tx("-")
      i := 1_000_000_000
      repeat 10
        if value => i
          tx(value / i + "0")
          value //= i
          result~~
        elseif result or i == 1
          tx("0")
        i /= 10
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • MightorMightor Posts: 338
    edited 2007-09-03 15:52
    Hi,

    Use something like this:
    Debug.str(string("Your word goes here", 10, 13))

    This is assuming you have defined FullDuplexSerial as Debug [noparse]:)[/noparse]

    Gr,
    Mightor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    | To know recursion, you must first know recursion.
  • NewzedNewzed Posts: 2,503
    edited 2007-09-03 16:25
    I have no problem using comm.dec -·I can display any number I want.· What I want to do is enter a number larger than 255 "on the fly".· This is used to clear my EEPROM.· My program tells me the last EEPROM byte used - say it was 38442.· So now I want to clear my EEPROM to 38450.· I must be abe to enter that number from the keyboard - i do not want to have to go into the program, enter the value, and reload.

    Does anyone have the answer I need?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • Mike CookMike Cook Posts: 829
    edited 2007-09-03 16:39
    Ok, If you want to send a number terminated with a Carriage Return, from hyperterm to the Propeller,·then you need Martin Hebel's "Extended Full Duplex Serial", this can be found in the Propeller Object Exchange. It has the following method:

    PUB rxDec : Value | place, ptr, x
    {{
       Accepts and returns serial decimal values, such as "1234" as a number.
       String must end in a carriage return (ASCII 13)
       x:= Serial.rxDec     ' accept string of digits for value
    }}   
        place := 1                                           
        ptr := 0
        value :=0                                             
        dataIn[noparse][[/noparse]ptr] := RX       
        ptr++
        repeat while (DataIn[noparse][[/noparse]ptr-1] <> 13) and (DataIn[noparse][[/noparse]ptr-1] <> Delimiter)                     
           dataIn[noparse][[/noparse]ptr] := RX                             
           ptr++
        if ptr > 2 
          repeat x from (ptr-2) to 1                            
            if (dataIn[noparse][[/noparse]x] => ("0")) and (datain[noparse][[/noparse]x] =< ("9"))
              value := value + ((DataIn[noparse][[/noparse]x]-"0") * place)       
              place := place * 10                               
        if (dataIn[noparse][[/noparse]0] => ("0")) and (datain[noparse][[/noparse]0] =< ("9")) 
          value := value + (DataIn[noparse][[/noparse]0]-48) * place
        elseif dataIn[noparse][[/noparse]0] == "-"                                  
             value := value * -1
        elseif dataIn[noparse][[/noparse]0] == "+"                               
             value := value 
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • JonathanJonathan Posts: 1,023
    edited 2007-09-03 16:42
    to eter a word value from a keyboard, here is the cheesy method I use, there is more than likely a better way. Lets assume you type "32000" on the keyboard. Collect it in a 5 byte arre and then:

    value :=value + databyte[noparse][[/noparse]0] * 10_000
    value := value + databyte * 1000
    value := value + databyte * 100
    value := value + databyte * 10
    value := value + databyte

    HTH,

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot

  • JonathanJonathan Posts: 1,023
    edited 2007-09-03 16:44
    dang, I shoulld have put it in a code snip, it took away the square brackets.

    /code

    value := value + databyte[noparse][[/noparse]0] * 10_000
    value := value + databyte * 1000
    value := value + databyte * 100
    value := value + databyte* 10
    value := value + databyte

    /code

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot

  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-03 18:26
    Try editing one of these posts (click on the pencil), [noparse][[/noparse] code /code ] ought to work in that editor. Then your code snippet should display correctly. The quick reply editor isn't as smart.
  • Tom WyckoffTom Wyckoff Posts: 26
    edited 2007-09-04 00:02
    If you use FullDuplexSerialPlus you can enter the value you need, as long as the variable you're putting it into is a long, not a byte.
    Try this, it's what I used when I testing FullDuplexSerialPlus.spin :




    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000
    _stack = 200

    obj
    comm: "FullDuplexSerialPlus"

    var
    byte str1[noparse][[/noparse]36]
    byte str2[noparse][[/noparse]36]
    long num1
    long num2
    long num3





    pub main | index, index2
    comm.start(16,17,0,57600)
    comm.str(string("Gimme a number!",10,13))
    num1 := comm.GetDec
    comm.str(string("I'm going to double that",10,13))
    num2 := num1 * 2
    comm.dec(num2)
    comm.str(string(10,13,"Our original number was: "))
    comm.dec(num1)
    comm.str(string(10,13))
    comm.str(string(10,13,"Maybe you want it in HEX? ",10,13))
    comm.hex(num1,8)
    comm.str(string(10,13,"Or maybe in binary even?",10,13))
    comm.bin(num1,12)
    comm.str(string(10,13))
    comm.str(string("Now give me one in HEX",10,13))
    num2 := comm.gethex
    comm.str(string(10,13,"OK That was:",10,13))
    comm.hex(num2,8)
    comm.str(string(10,13,"Can we make it decimal easily?",10,13))
    comm.dec(num2)
    comm.str(string(10,13))
    comm.str(string("Now for binary, gimme another number",10,13))
    num2 := comm.getbin
    comm.str(string(10,13,"In decimal that's",10,13))
    comm.dec(num2)
    comm.str(string(10,13))
    comm.str(string("Now just give me a word or two, up to 30 characters",10,13))
    comm.getstr(@str2)
    index := strsize(@str2)
    comm.dec(index)
    comm.str(string(10,13))
    repeat index2 from index to 0
    comm.tx(str2[noparse][[/noparse]index2])
    comm.str(string(10,13,"Oops, I got it backwards!",10,13))

    Post Edited (Tom Wyckoff) : 9/4/2007 12:10:01 AM GMT
Sign In or Register to comment.