PINK BS2P SPSTR issue
mbmosher
Posts: 13
Ok, so this is due tomorrow so any help is greatly appreciated.
I'm trying to get my BS2P to gather some data from a web form on my PINK, very similar to the demo program that came with the pink manual. But when ever the program gets to the SERIN GETPINK, baudPINK, 100, main, [noparse][[/noparse]SPSTR 64] ('American) it times out and goes back to main. Any pointers?
Here's the code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
'American Dreams BS2P
'Matthew Mosher
'www.matthewbmosher.com
OUTPUT 1
OUTPUT 15
INPUT 14
OUTPUT 9
OUTPUT 10
INPUT 8
INPUT 11
requestPINK PIN 15
GETPINK PIN 14
printerOn PIN 1
rx PIN 8
tx PIN 9
rts PIN 10
cts PIN 11
baudPINK CON 240 '1021 = 2400
baudPRINT CON 240 '= 9600
linefeed CON 10
esc CON 27
inverse CON "{"
inverted CON 1
align CON "a"
center CON "1"
user VAR WORD
country VAR BYTE
statusPINK VAR BYTE
update VAR statusPINK.BIT1
pointer VAR BYTE
char VAR BYTE
PAUSE 1000
'InitializePrinter
HIGH PrinterOn
PAUSE 5000
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverse]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverted]
PAUSE 100
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]align]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]center]
PAUSE 100
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"www.worldisbetter.com"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"Add your dreams at"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"by Matthew B Mosher"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"American Dreams"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
DEBUG "printer on and initialization sent", CR
LOW PrinterOn
main:
'GETstatus:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0ST"]
SERIN GETPINK, baudPINK, [noparse][[/noparse]statusPINK]
PAUSE 1000
DEBUG "PINK status ", DEC update, CR
IF update = 0 THEN GOTO main
'NEWuser:
user = user + 1
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"NB0W13:user", CLS]
DEBUG "user ", DEC user, CR
'GETcountry:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0R12"]
SERIN GETPINK, baudPINK, [noparse][[/noparse]country]
PAUSE 100
DEBUG "country ", DEC country, CR
IF country <> 49 THEN GOTO main
'American:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0R11"]
SERIN GETPINK, baudPINK, 100, main, [noparse][[/noparse]SPSTR 64]
PAUSE 100
DEBUG "data sent to bs2p", CR
'SetUpPrinter
HIGH PrinterOn
PAUSE 5000
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverse]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverted]
DEBUG "printer on", CR
'Printdream:
'line04:
FOR pointer = 96 TO 126
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line03:
FOR pointer = 64 TO 95
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line02:
FOR pointer = 32 TO 63
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line01:
FOR pointer = 0 TO 31
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'PrintUser:
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]" "]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]HEX user]
'EndPrint
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
DEBUG CR, "printer off", CR, CR
LOW PrinterOn
GOTO main
Thanks! Thanks! Thanks!
I'm trying to get my BS2P to gather some data from a web form on my PINK, very similar to the demo program that came with the pink manual. But when ever the program gets to the SERIN GETPINK, baudPINK, 100, main, [noparse][[/noparse]SPSTR 64] ('American) it times out and goes back to main. Any pointers?
Here's the code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
'American Dreams BS2P
'Matthew Mosher
'www.matthewbmosher.com
OUTPUT 1
OUTPUT 15
INPUT 14
OUTPUT 9
OUTPUT 10
INPUT 8
INPUT 11
requestPINK PIN 15
GETPINK PIN 14
printerOn PIN 1
rx PIN 8
tx PIN 9
rts PIN 10
cts PIN 11
baudPINK CON 240 '1021 = 2400
baudPRINT CON 240 '= 9600
linefeed CON 10
esc CON 27
inverse CON "{"
inverted CON 1
align CON "a"
center CON "1"
user VAR WORD
country VAR BYTE
statusPINK VAR BYTE
update VAR statusPINK.BIT1
pointer VAR BYTE
char VAR BYTE
PAUSE 1000
'InitializePrinter
HIGH PrinterOn
PAUSE 5000
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverse]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverted]
PAUSE 100
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]align]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]center]
PAUSE 100
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"www.worldisbetter.com"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"Add your dreams at"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"by Matthew B Mosher"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]"American Dreams"]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
DEBUG "printer on and initialization sent", CR
LOW PrinterOn
main:
'GETstatus:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0ST"]
SERIN GETPINK, baudPINK, [noparse][[/noparse]statusPINK]
PAUSE 1000
DEBUG "PINK status ", DEC update, CR
IF update = 0 THEN GOTO main
'NEWuser:
user = user + 1
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"NB0W13:user", CLS]
DEBUG "user ", DEC user, CR
'GETcountry:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0R12"]
SERIN GETPINK, baudPINK, [noparse][[/noparse]country]
PAUSE 100
DEBUG "country ", DEC country, CR
IF country <> 49 THEN GOTO main
'American:
SEROUT requestPINK, baudPINK, [noparse][[/noparse]"!NB0R11"]
SERIN GETPINK, baudPINK, 100, main, [noparse][[/noparse]SPSTR 64]
PAUSE 100
DEBUG "data sent to bs2p", CR
'SetUpPrinter
HIGH PrinterOn
PAUSE 5000
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]esc]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverse]
SEROUT tx\cts, baudPRINT, [noparse][[/noparse]inverted]
DEBUG "printer on", CR
'Printdream:
'line04:
FOR pointer = 96 TO 126
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line03:
FOR pointer = 64 TO 95
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line02:
FOR pointer = 32 TO 63
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'line01:
FOR pointer = 0 TO 31
GET pointer, char
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]char]
DEBUG char
IF char = CLS THEN EXIT
PAUSE 100
NEXT
'PrintUser:
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]" "]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]HEX user]
'EndPrint
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
SEROUT tx\cts, baudPRINT, 100, main, [noparse][[/noparse]linefeed]
DEBUG CR, "printer off", CR, CR
LOW PrinterOn
GOTO main
Thanks! Thanks! Thanks!
Comments
The short answer is use longer timeouts when talking to the PINK like 250-300:
Another way to attack the problem is to keep asking "Does the PINK has any changes for the stamp."
If you create a loop that keeps asking there will be only a few program delays and no timeouts.
The PINK example code never worked that well for me.
Regards
Tim
See this thread for an example of what I am talking about:
http://forums.parallax.com/showthread.php?p=568653
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com