Socket Communication
ravi
✭
Hi,
I am planning to develop a socket communication between robot and another c# program using a TCP/IP communication. One of the limitation of sending the data using TCP/IP communication is the size of the data. If I am sending the following string as "0;0;15030;6013;125;47200;76466;-56;47200;76466;-56;47200;76466;-56;47200;76466;-56;#END=1;" to the rapid program. I get an error on the Teach pendant saying that the string is too long. Is there any method to overcome this apart from breaking the string into smaller strings?
Thanks in advance for the help.
BR
Ravi
I am planning to develop a socket communication between robot and another c# program using a TCP/IP communication. One of the limitation of sending the data using TCP/IP communication is the size of the data. If I am sending the following string as "0;0;15030;6013;125;47200;76466;-56;47200;76466;-56;47200;76466;-56;47200;76466;-56;#END=1;" to the rapid program. I get an error on the Teach pendant saying that the string is too long. Is there any method to overcome this apart from breaking the string into smaller strings?
Thanks in advance for the help.
BR
Ravi
0
Comments
-
Hi ??Oravi??_i am doing the same thing with you .can you give me your code please?thanks alot0
-
Dear doc-zee,
I'v done this some years before. I'll post it here for you. Once I'm brazilian the coments are in portugese, but if you need a better explanation in some item, just write me back. I now that I've already answerd this kind of question before, so if you search in the forum you may find my previous posts.
Regarding to the string size limitation, that's a fact. Strings are 80 chars log limited. What can be done to avoid this is sending data by a rawbytes pack. Rawbytes can be 1024 bytes long.
So, here is the code:
!=========================================================================
PROC OpenTCPServerConnection()
! DescriA?A?o: Implementa uma conexA?o via TCP.
! Entradas: Nenhuma
! SaA-das: Nenhuma
! AlteraA?A?es: Tela do TP
!*************************************************************************
! Fecha eventuas conexA?es abertas
SocketClose Server_Socket;
SocketClose Client_Socket;
!Cria o socket serivor
SocketCreate Server_Socket;
SocketBind Server_Socket, server_ip, TCP_Port;
! Escuta e aguarda conexA?o do cliente
TPErase;
TPWrite "Aguardando conexA?o no endereA?o: " + server_ip +", porta: " Num := TCP_Port;
SocketListen Server_Socket;
SocketAccept Server_Socket, Client_Socket ClientAddress := client_ip;
TPWrite "Conectado com sucesso a " + client_ip;
ENDPROC
!=========================================================================
!=========================================================================
PROC OpenDebugServerConnection()
! DescriA?A?o: Implementa uma conexA?o via TCP.
! Entradas: Nenhuma
! SaA-das: Nenhuma
! AlteraA?A?es: Tela do TP
!*************************************************************************
! Fecha eventuas conexA?es abertas
SocketClose ServerDebug_Socket;
SocketClose ClientDebug_Socket;
!Cria o socket serivor
SocketCreate ServerDebug_Socket;
SocketBind ServerDebug_Socket, server_ip, Debug_Port;
! Escuta e aguarda conexA?o do cliente
TPWrite "Aguardando conexA?o de depuraA?A?o no endereA?o: " + server_ip +", porta: " Num := Debug_Port;
SocketListen ServerDebug_Socket;
SocketAccept ServerDebug_Socket, ClientDebug_Socket ClientAddress := client_ip;
TPWrite "Conectado com sucesso a " + client_ip;
ENDPROC
!=========================================================================
!=========================================================================
PROC OpenTCPClientConnection()
! DescriA?A?o: Implementa uma conexA?o via TCP.
! Entradas: Nenhuma
! SaA-das: Nenhuma
! AlteraA?A?es: Tela do TP
!*************************************************************************
! Fecha eventuas conexA?es abertas
SocketClose Client_Socket;
!Cria o socket serivor
SocketCreate Client_Socket;
TPErase;
TPWrite "Aguardando conexA?o no endereA?o: 192.168.125.2, porta: " Num := TCP_Port;
SocketConnect Client_Socket, "192.168.125.2", TCP_Port;
ENDPROC
!=========================================================================
!=========================================================================
PROC OpenDebugClientConnection()
! DescriA?A?o: Implementa uma conexA?o via TCP.
! Entradas: Nenhuma
! SaA-das: Nenhuma
! AlteraA?A?es: Tela do TP
!*************************************************************************
! Fecha eventuas conexA?es abertas
SocketClose ClientDebug_Socket;
!Cria o socket serivor
SocketCreate ClientDebug_Socket;
TPWrite "Aguardando conexA?o de depuraA?A?o no endereA?o: 192.168.125.2, porta: " Num := Debug_Port;
SocketConnect ClientDebug_Socket, "192.168.125.2", 1026;
ENDPROC
!=========================================================================
0 -
Hallo Leonardolt.Last Friday I have return from ABB training and this topics interest me a lot.I want to write a TCP server on the robot side, which will send info about current production to a connected clients. Your code (I hope) I understand, but it seams to serve just one client and it is rectricted that the client must be connected. Am I understand is correctly? Do you know if is possible to start "new thread" after SocketAccept and serve more then one client?thxLubo0
-
Hello Lubo!
You are right, my code accepts only one client connection. It was made like this because in this process I must always have one, and only one, computer connected to the robot.
I don't know if it is possible to do multi-client connection, but in my application I actualy use 2 connections: one to control the process an onother one for debug purposes. Both are phisicaly connectad to only one PC, but a see no reason for it to be connected to more than one using a hub.
I don't know how you are planning to manage multi-client conncections, once you need to specify the connection you want to send or receive data and I'm not sure how it is possible to wait on a connection without pooling. Maybe, it would be simpler to estabilish a single connection to a client and after use this client to spread the connection to the others.
Sory for not plenty helping you. Feel free to keep this post alive if you have other questions.
Leo
0 -
Hallo.The meaning to have multiclient conectivity is just becouse of debug. Normaly my program connected with robot will catch the production info and store it in the database. Second connection was for connecting by telnet and monitor if production works properly.And other thing I will do it is to make on the robot side the client part and server on the PC. But one thing which I afraid is the blocking robot program if the PC will be not available.Do you know how to set some timeout for the socket?thanks a lot.Lubo0
-
Lubo, as I could check here, you can use a timeout on a client socket. By the way, I also checked for timeout in server socket, but I only find this option in client. Check page 477, Socket Connect instruction, of this doc: 3HAC16581-1_REVH_EN - Rapid Instructions.pdf. There are also some examples and tips for implementing sockets in there.
Best regards
Leo
0 -
Hallo leonardolt. Thanks for the document. This seams to help me a lot. This looks the basic Rapid Developer coocbook.Look what i found in the forum http://forums.robotstudio.com/forum_posts.asp?TID=4418. Here the guy looks doing the thinks i need to do. So it looks it must work like I mean.0
-
thanks a lot!!!
0
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)
- 800 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings