UDP socket communication with virtual irc5
Hi, I am trying to send udp between virtual IRC5 and external python script but hitting problems. I am having trouble getting udp sockets to connect and communicate in to or out of robot studio. Firstly I am not that familiar with windows or robot studio which may not be helping. Initially I couldn't ping the robot studio machine from my unix machine. I played with the firewall to allow pinging and udp on all ports and the ping server responded. Next I checked that I could send udp between the windows PC and unix using python scripts. This works.
I have robot studio set up with an IRB1200 and IRC5 virtual controller with PC interface enabled. Using the following rapid code as a client send example;
I have robot studio set up with an IRB1200 and IRC5 virtual controller with PC interface enabled. Using the following rapid code as a client send example;
MODULE socket_server
VAR socketdev serverSocket;
VAR socketdev clientSocket;
VAR string data;
PROC main()
SocketCreate clientSocket;
SocketConnect clientSocket, "10.0.1.29", 2021;
SocketSend clientSocket \Str:="Hello server";
ENDPROC
ENDMODULE
----------------------------
Or as a server receive example;
----------------------------
Or as a server receive example;
MODULE socket_server
VAR socketdev serverSocket;
VAR socketdev clientSocket;
VAR string data;
PROC main()
SocketCreate serverSocket;
SocketBind serverSocket, "10.0.1.29", 2020;
SocketListen serverSocket;
SocketAccept serverSocket, clientSocket,\Time:=WAIT_MAX;
ERROR
IF ERRNO=ERR_SOCK_TIMEOUT THEN
RETRY;
ELSEIF ERRNO=ERR_SOCK_CLOSED THEN
SocketClose clientSocket;
SocketClose serverSocket;
SocketCreate serverSocket;
SocketBind serverSocket, "127.0.0.1", 5004;
SocketListen serverSocket;
SocketAccept serverSocket,clientSocket,\Time:=WAIT_MAX;
RETRY;
ELSE
stop;
ENDIF
ENDPROC
ENDMODULE
-----------------------
The error I get when I try to connect the client on the virtual controller and send udp out:
When I create the server on the virtual controller it just hangs on SocketAccept serverSocket, clientSocket,\Time:=WAIT_MAX; until it times out.
Is there anything obvious I have missed out on the set up? Is windows firewall getting in the way? Im totally stumped after a day of trying to get this to work. Any advice would be greatly appreciated.
-----------------------
The error I get when I try to connect the client on the virtual controller and send udp out:
*** SocketConnect clientSocket, "10.0.1.29", 2021;
41574: Socket error
Description
Task: T_ROB1.
The socket must be created before it can be used in any socket instruction.
Program ref: /socket_server/main/SocketConnect/11.
Causes
The reason for this error is one of the following:
1) Socket not created at all.
2) PP movements has been done.
3) Start of program after power fail.
4) The socket has been closed after SocketCreate.
Actions
Insert a SocketCreate instruction at a suitable place in the program before the socket is used.
Recovery: ERR_SOCK_CLOSED.
When I create the server on the virtual controller it just hangs on SocketAccept serverSocket, clientSocket,\Time:=WAIT_MAX; until it times out.
Is there anything obvious I have missed out on the set up? Is windows firewall getting in the way? Im totally stumped after a day of trying to get this to work. Any advice would be greatly appreciated.
Post edited by voidnoise on
0
Comments
-
The server code I pasted is actually missing the socket receive line:MODULE socket_serverVAR socketdev serverSocket;VAR socketdev clientSocket;VAR string data;PROC main()SocketCreate clientSocket;SocketCreate serverSocket;SocketBind serverSocket, "10.0.1.29", 2020;
SocketListen serverSocket;SocketAccept serverSocket, clientSocket,\Time:=WAIT_MAX;SocketReceive serverSocket \Str:=data;SocketSend clientSocket \Str:="received";SocketClose clientSocket;SocketClose serverSocket;ERRORIF ERRNO=ERR_SOCK_TIMEOUT THENRETRY;ELSEIF ERRNO=ERR_SOCK_CLOSED THENSocketClose clientSocket;SocketClose serverSocket;SocketCreate serverSocket;SocketBind serverSocket, "127.0.0.1", 5004;SocketListen serverSocket;SocketAccept serverSocket,clientSocket,\Time:=WAIT_MAX;RETRY;ELSEstop;ENDIFENDPROCENDMODULE0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings