Hi guys,
Can you help as I'm pulling my hair out on this one.
I'm using a sequencer to step through my program, each step sends out a different string. the sequencer is advanced via relay NEXT_CALL. this sequencer just goes round in circles as long as the data is coming in. Each step has a fixed 1 second timer contact in series with the sequence step to re-call the custfn
Each call sends a string out of comm 1. If no data is received I increment B and return to the caller forever..... B counts the transmit attempts
If data is received, I convert the data from hex to dec and store in DM
when A >0 i want to move on to the next custfn for the next string etc.
This all works fine except after data has been received I want to move on and not re send the same string.
If you look at the attachement you will see I send the data out to my serial listerning tool a couple of times then I force a reply (highlighted in blue) at this point I want to move to the next custfn but I always send the original string before moving on to the next string and I cannot get rid of it!
I have tried only sending the string out of comm 1 if A = 0 but this doesnt stop this happening either..... i.e
IF
A = 0
PRINT #1 "50002402000E00027A"
ENDIF
***********ACTUAL CODE****************
CLRIO NEXT_CALL
SETIO TX_LED_RELAY ' SET TX LED
PRINT #1 "50002402000E00027A" ' ASK CCM FOR SPEED TIMING MAP 0 -255
A$ = INPUT$(1) ' CHECK FOR DATA ON COMM PORT 1
IF LEN(A$)= 0
SETLCD 0,0,chr$(1) ' 1 SENT TO LCD WILL CLEAR SCREEN
SETLCD 0,1,CHR$(12) ' NO CURSOR
SETLCD 1,1, "NO TIMING MAP DATA"
B = B + 1 ' COUNTS NO DATA RECEIVED
RETURN ' NO DATA HAS BEEN RECEIVED
ENDIF
IF LEN(A$) > 0 ' LOOK TO SEE IF RETURN STRING IS > 0
A = A + 1 ' COUNTS DATA RECEIVED
SETIO RX_LED_RELAY ' SET RX LED
B$ = MID$(A$, LEN(A$)-5, 4) ' COPY LAST FOUR BYTES (-5) AND NUMBER OF BYTES LONG
ENDIF
DM[1] = HEXVAL(B$) 'CONVERT RECEIVED DATA FROM HEX TO DEC
SETLCD 0,0,CHR$(1) ' 1 SENT TO LCD WILL CLEAR SCREEN
SETLCD 0,1,CHR$(12) ' NO CURSOR
SETLCD 1,1, "TIMING MAP = " +STR$(DM[1],2)
IF
A > 0 ' WHEN NUMBER OF REPLIES = 1 MOVE ON TO NEXT CALL
SETIO NEXT_CALL
B = 0
A = 0
ENDIF