Hi all,
I'm having two issues with my F2424 controller. First, the controller seems to close TCP connections without reason during data transfer, and second, the STATUS(3) command doesn't detect the closed connection.
What happens is the controller connects to a central server to upload a sensor log, but sometimes during the data upload the TCP connection is dropped. The server sees a 'Connection reset by peer'.
There doesn't seem to be a way to detect the dropped connection on the PLC, as STATUS(3) call in the following code is ineffectual in stopping the loop. When the connection drops, the controller is unaware and continues trying to upload the data.
Any help will be much appreciated!
Andrew
This is the code that is affected by the dropped connection:
' loop through the controller log
WHILE I < N
' offset from start of log
O = DM[34] + (DM[30] * DM[32])
' format data to send (6-char ascii number)
A$ = STR$(DM[O], 6)
A$ = A$ + STR$(DM[O + 1], 6)
A$ = A$ + STR$(DM[O + 2], 6)
A$ = A$ + STR$(DM[O + 3], 6)
A$ = A$ + STR$(DM[O + 4], 6)
PRINT# 4 A$
' Erase log entries that have been sent
DM[O] = 0
DM[O + 1] = 0
DM[O + 2] = 0
DM[O + 3] = 0
DM[O + 4] = 0
' Bring the start index up to speed
DM[30] = (DM[30] + 1) MOD (DM[33] / DM[32])
' if the connection is closed, close our end down
' and log an error
IF STATUS(3) <> 1 THEN
PRINT# 4 "</>"
DM[DM[40]] = DM[DM[40]] | 4
RETURN
ENDIF
I = I + 1
ENDWHILE