DEFINE OSC 20 input PORTC.1 CURRENT VAR BYTE PAST VAR BYTE NUMBER VAR BYTE I VAR WORD true9600 con 84 ' Our serial communication pins tx var PORTC.6 rx var PORTC.7 ' Used to read response from the XPort inByte var byte ' Track whether or not we are connected to the remote server connected var bit connected = 0 pause 5000 PAST = 0 I = 0 NUMBER = 0 main: if connected = 1 then FOR I = 0 TO 50000 CURRENT = PORTC.1 IF CURRENT <> PAST THEN IF CURRENT = 1 THEN NUMBER = NUMBER + 1 ENDIF PAST = CURRENT ENDIF NEXT I ' If we're already connected then we can send our message gosub http_request NUMBER = 0 ' back off the server for a few seconds pause 500 else ' try and connect gosub xport_connect endif goto main xport_connect: serout2 tx, true9600, ["C128.122.253.189/80", 10] connected = 1 return http_request: SEROUT2 TX, true9600, ["GET /~cj520/netobjects/fileWriter.php?picVars=",DEC NUMBER] serout2 tx, true9600, [" HTTP/1.1", 10] SEROUT2 tx, true9600, ["HOST: itp.nyu.edu", 10] SEROUT2 tx, true9600, ["User-Agent: Mozilla/4.0(compatible;MSIE 5.23;Mac_PowerPC)"] serout2 tx, true9600, [10, 10] ' wait for bytes from server: ' Our server sends a 0 to finish while inByte <> 0 serin2 rx, true9600, [inByte] wend ' now we're disconnected: connected = 0 return