Shop OBEX P1 Docs P2 Docs Learn Events
So, what am I doing wrong? Strings and Simple_Serial — Parallax Forums

So, what am I doing wrong? Strings and Simple_Serial

HughHugh Posts: 362
edited 2010-08-07 17:37 in Propeller 1
Hi,

I have some simple code in a prop which says:
prop1 wrote:
OBJ
ss : "Simple_Serial"
PUB MAIN
ss.init(RxPin, TxPin, Baud)



'WAIT FOR INIT DATA ETC
Rx := 0
repeat while Rx <>= "*"
Rx := ss.Rx
if Rx == "%"
print($10D)
elseif Rx == "$"
print($100)
else
print(Rx)

Which I wish to echo text sent from another prop to a PTP LCD display. Any text I send via the PropTerminal works perfectly, including the "%" for carriage return an "$" for clearing the screen.

However, sending data from another prop is a different kettle of fish:
Prop2 wrote:
CON
{{The CON section defines the constants used within the software.}}
_clkmode = xtal1 + pll16x 'Set up frequency and clock data
_xinfreq = 5_000_000
OBJ
PTP : "Simple_Serial"
PUB Main
PTP.init(15, 14, 9600)

PTP.str(string("HH"))

If I send one character via PTP.tx("X") it appears at the other end OK.
If I send a second character it appears as a symbol.

If I send two or more characters via PTP.tx("XX") the second character and subsequent are symbols.

If I send two or more characters via PTP.str(string("XX")) the second character and subsequent are symbols.

What am I missing/doing wrong? What does prop terminal do (or not do) that Simple_Serial does not?

Thanks

Hugh

Comments

  • HughHugh Posts: 362
    edited 2010-08-07 09:22
    More info:

    I sent pairs of characters from one Prop to another and matched the character codes of what was actually displayed:

    Sent: "50 50", displayed "50, 153"
    Sent: "51 51", displayed "51, 153"
    Sent: "52 52", displayed "52. 154"
    Sent: "53 53", displayed "53, 154"
    Sent: "54 54", displayed "54, 155"
    Sent: "55 55", displayed "55, 155"
    Sent: "56 56", displayed "56, 156"
    Sent: "57 57", displayed "57, 156"
    Sent: "58 58", displayed "58, 157"
    Sent: "59 59", displayed "59, 157"

    If they were 128 apart I would suspect a specific bit.... Hmm. Where's the 'head-scratching' emoticon?!
  • jazzedjazzed Posts: 11,803
    edited 2010-08-07 09:37
    Hugh wrote: »
    Where's the 'head-scratching' emoticon?!
    Maybe this is a good substitute :confused:

    Have you tried using FullDuplexSerial instead of Simple_Serial? The reason I ask is that Simple_Serial does not buffer and your code is probably not fast enough to catch the second character in-tact.
  • HughHugh Posts: 362
    edited 2010-08-07 09:43
    jazzed wrote: »
    Maybe this is a good substitute :confused:

    Have you tried using FullDuplexSerial instead of Simple_Serial? The reason I ask is that Simple_Serial does not buffer and your code is probably not fast enough to catch the second character in-tact.

    Thanks, Jazzed, but if I use FDS strange things happen with the LCD display - I assume because it is larger and tramples all over the stack. :-/

    Maybe I can try and hack out the parts of FDS that aren't necessary. Strange that PropTerminal works OK!
  • T ChapT Chap Posts: 4,223
    edited 2010-08-07 09:44
    Can you post your receive side and send side code?

    Ar you using any code on receive to parse the separate values? If you send separate values with some delimiter, you will have to parse on the receive side.
  • jazzedjazzed Posts: 11,803
    edited 2010-08-07 09:49
    Hugh wrote: »
    Thanks, Jazzed, but if I use FDS strange things happen with the LCD display - I assume because it is larger and tramples all over the stack. :-/
    Ok. Why don't you try a delay between sending chars?

    ptp.str(string("HH")) ' sends as fast as possible

    N := 100
    ptp.tx("H")
    waitcnt(clkfreq*N/1000+cnt) ' add 100 millisecond delay
    ptp.tx("H")
  • HughHugh Posts: 362
    edited 2010-08-07 10:17
    You were right though - dropping the baud rate to 2400 sorted things. Thanks for the inspiration!
  • jazzedjazzed Posts: 11,803
    edited 2010-08-07 10:50
    Hugh wrote: »
    You were right though - dropping the baud rate to 2400 sorted things. Thanks for the inspiration!

    Glad I could help :)

    Dropping the baud-rate effectively adds a delay between transmitted chars.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-08-07 17:37
    FullDuplexSerial has FOUR parameters while simple serial has three

    If you initialise FDS properly it works with ANY kind of serial displays
    with the advantage of a send and receive buffer

    best regards

    Stefan
Sign In or Register to comment.