TCP Help
Posted: Fri Jun 08, 2012 10:35 am
Okay...
I've got a Omni v.3 meter hooked up to an Iserial box. It works and the software works and I have been successful in auto logging to Wattvision.
However, I would like my own controller to read the data. I can not use RS485 since my controller is using it with other devices. There is no overlap in regards to baud, etc. I am happy to use TCP.
I get confirmation of the connection but do not get any data. Are you able to help?
Here is the code of my controller.
SYSLOG "HELLO WORLD"
DIM mtr$(1000)
DIM l
DIM p$(1000)
DIM cr$
cr$ = "/r/n" ' carriage return line feed
OPEN "TCP:192.168.1.125:1000" AS 3 ' open connection on handle 3
Delay 100 ' wait for a bit
IF CONNECTED(3) THEN
SYSLOG "Connection has been made" ' confirm connection
ELSE
SYSLOG "No connection" ' connection failed
END ' give up
ENDIF
10
Delay 5000 'wait 5 seconds
READ 3,mtr$,0,cr$ ' read the connection on handle 3
l= LASTLEN(3) ' get the length of the response
SYSLOG "File length: " + str$(l) ' publish file length
SYSLOG "File read: " + mtr$ ' print file
p$ = "" ' initialize conversion string
FOR i = 1 to l
p$ = p$ + SPRINTF$("%02x" , MIDGET(mtr$,i,2)) ' convert data
NEXT i
SYSLOG "This is the converted string: " + p$ ' print converted string
GOTO 10 ' loop around... do another read
END
I've got a Omni v.3 meter hooked up to an Iserial box. It works and the software works and I have been successful in auto logging to Wattvision.
However, I would like my own controller to read the data. I can not use RS485 since my controller is using it with other devices. There is no overlap in regards to baud, etc. I am happy to use TCP.
I get confirmation of the connection but do not get any data. Are you able to help?
Here is the code of my controller.
SYSLOG "HELLO WORLD"
DIM mtr$(1000)
DIM l
DIM p$(1000)
DIM cr$
cr$ = "/r/n" ' carriage return line feed
OPEN "TCP:192.168.1.125:1000" AS 3 ' open connection on handle 3
Delay 100 ' wait for a bit
IF CONNECTED(3) THEN
SYSLOG "Connection has been made" ' confirm connection
ELSE
SYSLOG "No connection" ' connection failed
END ' give up
ENDIF
10
Delay 5000 'wait 5 seconds
READ 3,mtr$,0,cr$ ' read the connection on handle 3
l= LASTLEN(3) ' get the length of the response
SYSLOG "File length: " + str$(l) ' publish file length
SYSLOG "File read: " + mtr$ ' print file
p$ = "" ' initialize conversion string
FOR i = 1 to l
p$ = p$ + SPRINTF$("%02x" , MIDGET(mtr$,i,2)) ' convert data
NEXT i
SYSLOG "This is the converted string: " + p$ ' print converted string
GOTO 10 ' loop around... do another read
END