Hello all.
Is it possible to use hserin pin to receive background data and then revert this pin into normal pin to receive more data (eg, 8 bytes)?
I have a small program that checks with 'hserin wX' if a wake-up byte (ASCII 63) is background received and if so, then replies with a 'command prompt' and waits for an extra byte to be received using serin on the same pin. When the extra byte is received it sends it back to the serial and returns to the 'checking' loop. Although it seems to work fine, I have noticed that if I send the same wake-up byte as a 'data' byte then the program thinks it has just received another wake-up byte and displays the prompts to receive additional data.
Code for Picaxe 14m2:
Any tips?
Thanks,
Stelios
Is it possible to use hserin pin to receive background data and then revert this pin into normal pin to receive more data (eg, 8 bytes)?
I have a small program that checks with 'hserin wX' if a wake-up byte (ASCII 63) is background received and if so, then replies with a 'command prompt' and waits for an extra byte to be received using serin on the same pin. When the extra byte is received it sends it back to the serial and returns to the 'checking' loop. Although it seems to work fine, I have noticed that if I send the same wake-up byte as a 'data' byte then the program thinks it has just received another wake-up byte and displays the prompts to receive additional data.
Code for Picaxe 14m2:
Code:
' Pin symbols
symbol SER_IN = B.1
symbol SER_OUT = B.2
' Variable names
symbol COUNTER = b2
symbol SERINDATA = w6
' Configure the hserin pin for background serial in
hsersetup B4800_32, %00
main_loop:
' Loop to check for incoming data
for COUNTER = 1 to 20
let SERINDATA = $FFFF
hserin SERINDATA
' Check if we got the '?' character
if SERINDATA = 63 then
' Get into serial-in mode
gosub get_serial_data
endif
' Make a pause
pause 1000
next COUNTER
' Start again
goto main_loop
get_serial_data:
do
' Get the serial data
' Send ACK prompt (">")
serout SER_OUT, T4800_32, ("> ")
serin SER_IN, T4800_32, b12
serout SER_OUT, T4800_32, ("OK ", b12, " ", 10, 13)
' Loop over if the first character is "1"
loop while b12 = "1"
return
Thanks,
Stelios