So, what am I doing wrong? Strings and Simple_Serial
Hugh
Posts: 362
Hi,
I have some simple code in a prop which says:
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:
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
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
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?!
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!
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.
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")
Glad I could help
Dropping the baud-rate effectively adds a delay between transmitted chars.
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