I’m currently trying to estabish a socket communcation between an ABB IRB1200 Robot and a 3D Camera from Solomon. The controller has the PC-Interface package installed, the robot IP is 192.168.0.6 and the PC has the IP 192.168.0.2 and the declared port 10000. I can succesfully create the Socket but when it reaches the SocketConnect command it idles there until the timeout error occures. I was wondering if you have any ideas for this problem. Thank you very much!
!Creating socket and verifying
SocketCreate SocketSolomon;
IF (SocketGetStatus(SocketSolomon)=SOCKET_CLOSED) THEN
TPWrite “Socket failed to create!”;
SocketFails:=SocketFails+1;
GOTO VisionInit;
ELSE
TPWrite “Socket created successfully!”;
ENDIF
!Connecting socket and verifying
SocketConnect SocketSolomon,“192.168.0.2”,10000;
IF (SocketGetStatus(SocketSolomon)<>SOCKET_CONNECTED) THEN
Hi …
There is a time for creation, connection and data exchange, in addition there is a number of sockets and connections that are allowed, so try not to create/connect too many sockets.
I believe you are not giving enough time for the commands to complete.
Try the solution to see what appears as a response.
PROC ConnectServerSocket(string addressP,num portP)
! ## ATTRIBUTES ############################################# ##############################
VAR socketdev mySocketL;
! ## ATTRIBUTES ############################################# ##############################
! Creates a connection via socket if there is no connection created with the PLC for data exchange ...
IF SocketGetStatus(mySocketL)<>SOCKET_CREATED THEN
SocketCreate mySocketL;
ENDIF
IF SocketGetStatus(mySocketL)=SOCKET_CREATED THEN
SocketConnect mySocketL,addressP,portP\Time:=1;
IF SocketGetStatus(mySocketL)=SOCKET_CONNECTED THEN
! CODE ....
ENDIF
ENDIF
! At the end of the routine, close the connection with the PLC to avoid creating an unnecessary socket when executing the routine again ...
SocketClose mySocketL;
RETURN ;
ERROR
! #################### ##################### !
! #################### Handling error ################### !
! #################### #################### !
TEST ERRNO
CASE ERR_SOCK_TIMEOUT:
ErrWrite "ERR_SOCK_TIMEOUT","";
CASE ERR_SOCK_CLOSED:
ErrWrite "ERR_SOCK_CLOSED","";
DEFAULT:
TPWrite "??? ERRNO ???";
ENDTEST
! Testando o status do socket para definir ações a serem tomadas ...
TEST SocketGetStatus(mySocketL)
CASE SOCKET_CREATED:
TPWrite "SocketCreate";
CASE SOCKET_CLOSED:
TPWrite "SocketClose";
CASE SOCKET_BOUND:
TPWrite "SocketBind";
CASE SOCKET_LISTENING:
TPWrite "Instruction SocketListen or SocketAccept has been executed";
CASE SOCKET_CONNECTED:
TPWrite "SocketConnect, SocketReceive or SocketSend";
DEFAULT:
TPWrite "??? SocketGetStatus ???";
ENDTEST
RETURN ;
ENDPROC