Banner PresencePLUS P4 Series User Manual

Page 78

Advertising
background image

; TCP error
tcp_error:
PRINT "Error during send or receive via TCP:", .ret_val
GOTO all_done

; RCC Command error
cmd_error:
PRINT "Error during command to camera:", .ret_val
GOTO all_done

; Done with program
all_done:
CALL tcp_close
.END

;
; Open a TCP connection to the RCC using specified TCP port number
;
.PROGRAM tcp_open(.ret_val, .port)

.ret_val = 0 ; Initialize the return value
.retry_count = 0 ; Initialize the retry count

; Set the IP address to 192.168.0.1
ip[1] = 192
ip[2] = 168
ip[3] = 0
ip[4] = 1

connect:

; Connect to the RCC port
TCP_CONNECT tcp_sock_id, .port, ip[1]

; Check whether connection was established
IF tcp_sock_id < 0 THEN
IF .retry_count >= 5 THEN
; Number of retries exceeds 5, exit with error
PRINT "Unable to establish connection with camera"
.ret_val = -1
GOTO connect_error
ELSE
; Increment the retry count and try again
.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)

P/N 000000

Banner Engineering Corp. - Minneapolis, MN USA - www.bannerengineering.com

Tel: 763.544.3164

78

7/2009

System Setup Window Overview

Advertising