Banner PresencePLUS Pro COLOR—PROII Camera User Manual

Page 76

Advertising
background image

.retry_count = .retry_count + 1
PRINT "TCP_CONNECT error – attempt #", .retry_count
GOTO connect
END
ELSE
PRINT "Established connection, socket id = ", tcp_sock_id
END

; Error occurred during connection attempt(s)
connect_error:
RETURN

.END

;
; Close the TCP connection
;
.PROGRAM tcp_close()

.ret_val = 0 ; Initialize the return value

TCP_CLOSE .ret_val, tcp_sock_id

; Check for errors
IF (.ret_val < 0) THEN
PRINT "Unable to close TCP connection, error id = ", .ret_val
ELSE
PRINT "TCP Connection has been closed"
END
.END

;
; Receive data over TCP connection
;
.PROGRAM tcp_recv(.ret_val, .$receive)
.ret_val = 0 ; Initialize the return value
.error_return = -99 ; Return value from TCP_RECV
.timeout_recv = 60 ; Timeout of 60 seconds
.max_recv_len = 255 ; Maximum length of single string element
.$receive = "" ; Empty the return string
.num_elem_recv = 0 ; Number of elements received

; Read the TCP socket
TCP_RECV .error_return, tcp_sock_id, .$recv_buf[1], .num_elem_recv,
.timeout_recv, .max_recv_len

; Process data
IF .error_return < 0 THEN
PRINT "Error receiving data, TCP_RECV error #", .error_return
.ret_val = -1
ELSE
IF .num_elem_recv > 0 THEN

; Ensure the combined return string element lengths do
; not exceed 255 (maximum allowed length of string) – the
; multiplication allows .max_recv_len to be less than 255
IF .num_elem_recv * .max_recv_len <= 255 THEN

; Copy all of the received elements into output buffer
FOR .j = 1 TO .num_elem_recv
.$receive = .$receive+.$recv_buf[.j]
END

Banner Engineering Corp.

Minneapolis, MN USA

76

2/2010

System Setup Dialog

Advertising