FullDuplexSerial programming help
Jared5755
Posts: 26
I'm working with the AVRCam http://www.jrobot.net/Projects/AVRcam.html
How do you all suggest writing a routine that continuously outputs "PG" on the tx pin·until "ACK" is received on the rx pin.· I'm using FullDuplexSerial to do this.· Here's what I've come up with (doesn't work):
I've left some code out from the post.· My two other serial connections work just fine.· So, it has to be either my configuration for this one, or the routine to wait for an "ACK"
Thanks a lot
How do you all suggest writing a routine that continuously outputs "PG" on the tx pin·until "ACK" is received on the rx pin.· I'm using FullDuplexSerial to do this.· Here's what I've come up with (doesn't work):
rxAVRcam=8 txAVRCam=9 modeAVRCam=%0000 baudrateAVRCam=115200
AVRCam.start(rxAVRCam, txAVRCam, modeAVRCam, baudrateAVRCam)
c1:="P" c2:="P" c3:="P" repeat until (c1=="A" and c2=="C" and c3=="K") AVRCam.str(string("PG")) c1:=AVRCam.rxcheck c2:=AVRCam.rxcheck c3:=AVRCam.rxcheck
I've left some code out from the post.· My two other serial connections work just fine.· So, it has to be either my configuration for this one, or the routine to wait for an "ACK"
Thanks a lot
Comments
take a look into the comments of fullduplexserial
as the sourcecode of fullduplexserial says
PUB rxcheck : rxbyte
'' Check if byte received (never waits)
'' returns -1 if no byte received, $00..$FF if byte
if the AVRCam does not respond "A" "C" "K" faster than the SPIN-code is running down
c1:=AVRCam.rxcheck
c2:=AVRCam.rxcheck
c3:=AVRCam.rxcheck
you might have the situation that your variables have the result
c1 = "-1"
c2 = "A"
c3 = "C"
and in the next loopturn
c1 = "K"
c2 = "A"
c3 = "C"
and then the condition is NEVER true
you could try this
or this
PUB rx : rxbyte
'' Receive byte (may wait for byte)
'' returns $00..$FF
best regards
Stefan
P.S.:
for debugging purposes you could have coded something
that sends the received value to another serial connection or tv_text or something like that
and THEN you would have recognized the proplem by yourself
so as a general advice:
if you don't find the error by looking at the code
code a feedback that shows you what is REALLY happening