Xylem System 5000 BASIC Manual User Manual
Page 39

37
Basic Commands and Functions
FileExists = 1
FileName$ = “LogFile.csv”
IF (NOT OPEN(#1, FileName$)) THEN
FileExists = 0
ELSE
CLOSE #1
ENDIF
Serial Port:
SETPORT 300, 8, none, 1, none, 50, 0 REM port settings
OPEN “COM 1” AS #5 REM open the COM at 300 baud w/50ms tx char delay
CLOSE #5
Ethernet Port:
OPEN “www.waterlog.com:80” AS #2
headers$ = “GET / HTTP/1.1\r\n”
headers$ = headers$ + “Host: www.waterlog.com\r\n”
headers$ = headers$ + “User-Agent: System 5000\r\n”
headers$ = headers$ + “Accept: text/html\r\n”
headers$ = headers$ + “Accept-Language: en-us,en;\r\n”
headers$ = headers$ + “Accept-Charset: ISO-8859-1,utf-8\r\n”
PRINT #2, headers$ REM Send our request for the web page
REM As the maximum receiving length is capped at 1024 characters,
REM multiple INPUT commands needs to be run to retrieve the content
INPUT #2 1000, webpage$ REM Give a full second for the first response
WHILE (LEN(webpage$) > 0)
PRINT webpage$
REM Print the contents to the terminal
INPUT #2 100, webpage$ REM Retrieve remaining contents(100ms waiting)
WEND
CLOSE #2
Listening Port:
REM Display a simple web page, probably via the Ethernet port
OPEN “LISTENER” AS #9
INPUT #9, rcv$
PRINT #9 “HTTP/1.0 200 OK”
PRINT #9 “”
PRINT #9 “”
PRINT #9 “
”
PRINT #9 “
PRINT #9 “”
PRINT #9 “
”
GETTASK “myTask”, Task1Val$
GETTIMESTAMP “myTask”, Task1ts$
PRINT #9 “Task: “, Task1$, “ DateTime:”, Task1ts$, “ Value:”, Task1Val$
PRINT #9 “”
PRINT #9 “”
CLOSE #9