RobotStudio event

String delimiter for socket messaging

Dear all,

I'm currently programming an ABB robot to communicate trough socket messaging (TCP) with a computer. The computer sends string messages over socket to the ABB where the ABB functions as server for the connection. The string that the computer sends has a variable size and is delimited with a LF/CR (but this can be changed if necessary). The total message consists of several strings that eventually need to be separated. When the whole message is send in one go (each line  is send as a separate string, but after each other with no time delay in between), the ABB sees it as one long string (that eventually becomes too long and causes an error). When a delay is used (50ms) between sending the strings it all works correctly. This indicates that the ABB uses a pause in the message as a string delimiter. Is there any way to use a different ASCII character (such as CR) as a string delimiter so that the whole message can be send at once?

Thanks in advance,

Greetings Tom

Comments

  • Hello,

    I am just currently doing the same project using TCP connection between PLC and robot controller. I am using the instructions PackRawBytes and UnpackRawBytes and it doesn't seem to have any length issue. What instructions are you using for the connection?
  • At the moment I'm using a PC with Halcon vision software to send data over TCP to the robot. The TCP send function in Halcon has the following options to send data:

    Integer values:

    -> one byte = 8 bit, signed/unsigned
    -> two bytes = 16 bit, signed/unsigned
    -> four bytes = 32 bit, signed/unsigned
    -> eight bytes = 64 bit, signed/unsigned

    Float values:

    -> float, 4 bytes = 32 bit
    -> double, 8 bytes = 64 bit

    String values:

    -> string (default length 1024 bytes), padded with spaces
    -> string (default length 1024 bytes), padded with zeros and will be zero terminated when sending
    -> string with variable length, the length modifier specifies the maximum length (default length 1024 bytes)

    Eventually I want to send variable length strings to the robot (to get a message across in XML format). Normally I would use the option "string with variable length" and place a delimiter like "carriage return" or "line feed" at the end of the message which can then be detected by the robot so it knows the end of the string is reached. I did find a way to do it by using the following method:

    I use the function "string padded with spaces" in Halcon and define the length of the string to 60 bytes (which is more then enough for my purpose). This means that I will always send strings with the same length. If I want to send the message "hello world" to the robot, I delimit it with a special character like "#" and since I always send 60 characters it will be padded with spaces untill the message reaches this length. So basically I'm sending the message "hello world#       ". Then in the ABB I use: SocketReceive client_socket\Str:=InputString\ReadNoOfBytes:=60, so it receives the whole string. Then I use: FinalString:=StrPart(InputString,1,StrFind(InputString,1,"#")-1), to separate the usable part. This method seems to work, but eventually I'm sending more data than necessary.