Shop OBEX P1 Docs P2 Docs Learn Events
Unexpected Display results Prop to Prop Comunnications — Parallax Forums

Unexpected Display results Prop to Prop Comunnications

jcfjrjcfjr Posts: 74
edited 2011-07-19 11:31 in Propeller 1
I am using two propeller chips. U1 takes some data through PST, calculates some values, and sends three values as strings to U2. U2 drives my 3.5" touchscreen to display these values. The chips are talking, and the following code displays the correct values through PST (debug). But I don't think I am terminating the strings properly when sending. The values are typically

@SWRdisplay 1.18
@tfwd 949
@tref 7.6

which are displayed correctly through PST.

They are displayed in touchscreen as follows

@SWRdisplay 1.189497.6
@tfwd 9497.6

So @SWRdisplay has the correct value 1.18, but it also has @tfwd and @tref appended, the two following values transmitted, and @tfwd has the correct value, but appends the following transmits to it.

I use

Comm.Str(String(debug#cr))

to send cr to terminate the string, but this does not give the correct result.

Is there simply a missing termination, or do I need to do more?

PS This is my first post, so if I haven't included something needed, I please beg your forgiveness.

CODE TO SEND DATA FROM U1 TO U2

OBJ
Comm : "Extended_FDSerial_JCF"
Debug : "FullDuplexSerialPlus"
fMath : "Float32"
fString : "FloatString"
ClockGen: "Synth" 'object that generates the 5mhz clock.
Loader : "PropellerLoader" 'programs U1, U3, U4.
PUB Begin
ClockGen.Synth("A",FreqPin, Freq) 'Generate 5mhz
Loader[0].Connect(VideoRst, VideoTx, VideoRx, 1, 1, @VideoSequencer) 'program U1
Comm.start(VideoRx, VideoTx, 0, 250000) 'run communication data to video prop
...
....
....
debug.Str(String(debug#cr))
debug.str(string("FPower= "))
debug.str(fstring.FloatToString(fpwrw))
debug.Str(String(debug#cr))
debug.str(string("RPower= "))
debug.str(fstring.FloatToString(rpwrw))
debug.str(string(debug#cr))
debug.str(string("SWRdisplay="))
debug.str(fstring.FloatToString(swr))

'Send data to U2 for display)

Comm.str(fstring.FloatToString(swr))
Comm.Str(String(debug#cr))
Comm.str(fstring.FloatToString(fpwrw))
Comm.Str(String(debug#cr))
Comm.str(fstring.FloatToString(rpwrw))
Comm.Str(String(debug#cr))

CODE TO RECEIVE DATA AT U2

OBJ 'Objects for Graphics Demo
gr : "graphics"
lcd : "PTP_LcdDriver" 'Modified to drive 3.5" TFT
Comm : "Extended_FDSerial_JCF" 'allows communication between with U1
.....
.....
Comm.start(VideoRx, VideoTx, 0, 250000) 'run communication data to U1 Prop
....
....
Comm.rxstr(@SWRdisplay)
Comm.Rxstr(@tfwd)
Comm.Rxstr(@tref)
fwdpower:=Comm.IntOfString(@tfwd)
refpower:=Comm.IntOfString(@tref)
'Factor power values for bar length
fwd:=fwdpower / 7
ref:=refpower * 4

Comments

  • BeanBean Posts: 8,129
    edited 2011-07-19 10:50
    I'm pretty sure strings have to be terminated with a zero byte instead of a carrage return.

    Bean
  • jcfjrjcfjr Posts: 74
    edited 2011-07-19 11:31
    I think the fstring.FloatToString should add the 0. But the Object Extended_FD_Serial states:

    PUB RxStr (stringptr) : Value | ptr
    {{
    Accepts a string of characters - up to 15 - to be passed by reference
    String acceptance terminates with a carriage return or the defined delimiter character.
    Will accept up to 15 characters before passing back.
    Serial.Rxstr(@MyStr) ' accept
    serial.str(@MyStr) ' transmit
    }}

    I don't think the "Comm.Str(String(debug#cr))" line after the send is fulfilling the expect termination in Object Extended_FD_Serial.

    How do I add a #cr to the end of

    Comm.str(fstring.FloatToString(fpwrw)

    so that the 0 terminated string produced by fstring is appended with a cr......or am I on the wrong path here?
Sign In or Register to comment.