# Send Position as a String

**URL:** <https://tech-community.robotics.abb.com/t/send-position-as-a-string/7124>\
**Category:** RobotStudio\
**Tags:** socket, labview, cpos, crobt\
**Created:** [April 29, 2016, 4:39pm UTC](https://tech-community.robotics.abb.com/t/send-position-as-a-string/7124 "2016-04-29T16:39:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMob](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/stevemob/32/1600_2.png) [@SteveMob](https://tech-community.robotics.abb.com/u/SteveMob)\
**Post date:** [April 29, 2016, 4:39pm UTC](https://tech-community.robotics.abb.com/t/send-position-as-a-string/7124/1 "2016-04-29T16:39:55Z")

</div>

Hello,

I have a current RAPID program that is communicating with LabVIEW. I want the RAPID program to send LV a string of it’s current position, with tool and axis configurations as well as the robtarget name, once the robot has reached a position.

This is my code:  
MODULE Module1  
CONST robtarget Home:=[[374,0,630],[0.707106781,0,0.707106781,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];  
CONST robtarget Target\_10:=[[526.3896,0,477.5962],[0.707106781,0,0.707106781,0],[0,0,0,1],[9E9,9E9,9E9,9E9,9E9,9E9]];  
CONST robtarget Target\_10\_2:=[[526.3896,190.5,528.3962],[0.707106781,0,0.707106781,0],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]];

VAR socketdev client\_socket;  
VAR socketdev RS;  
VAR num retry\_no:=0;  
VAR rawbytes parse\_data;  
VAR num peek\_value:=0;  
VAR num bytes\_available:=0;  
VAR byte command:=255;  
VAR num i;  
VAR num MoveNext:=0;

PROC Path\_10()  
SocketClose client\_socket;  
Socketcreate client\_socket;  
SocketConnect client\_socket,“192.168.125.5”,3333;  
!127.0.0.1 for self  
SocketSend client\_socket\Str:=“Connection Successful, you are the server, I am the client!”\NoOfBytes:=59;  
IF ERRNO=ERR\_SOCK\_TIMEOUT THEN  
ENDIF  
! Clear the port of any data  
ClearRawBytes parse\_data;  
i:=1;  
WHILE i=1 DO  
peek\_value:=SocketPeek(client\_socket);  
IF peek\_value\>=1 THEN

ClearRawBytes parse\_data;  
SocketReceive client\_socket\RawData:=parse\_data\Time:=25;  
bytes\_available:=RawBytesLen(parse\_data);  
SocketSend client\_socket\RawData:=parse\_data;  
IF bytes\_available\>=1 THEN  
UnpackRawBytes parse\_data,1,command\Hex1;  
IF command=105 THEN  
command:=0;  
Incr MoveNext;  
IF MoveNext=1 THEN  
SocketSend client\_socket\Str:=“FALSE”,\NoOfBytes:=5;  
! MoveJ Home,v100,z10,tool0\WObj:=wobj0;  
! WaitTime 1;  
SocketSend client\_socket\Str:=“TRUE”,\NoOfBytes:=4;  
ENDIF  
IF MoveNext=2 THEN  
SocketSend client\_socket\Str:=“FALSE”,\NoOfBytes:=5;  
MoveJ Target\_10,v100,z10,tool0\WObj:=wobj0;  
WaitTime 1;  
SocketSend client\_socket\Str:=“TRUE”,\NoOfBytes:=4;  
SocketSend client\_socket\Data:=Current\_Pos;  
ENDIF  
IF MoveNext=3 THEN  
SocketSend client\_socket\Str:=“FALSE”,\NoOfBytes:=5;  
MoveJ Target\_10\_2,v100,z10,tool0\WObj:=wobj0;  
WaitTime 1;  
SocketSend client\_socket\Str:=“TRUE”,\NoOfBytes:=4;  
ENDIF  
:  
:  
:  
IF MoveNext\>=27000 THEN  
SocketSend client\_socket\Str:=“FALSE”,\NoOfBytes:=5;  
MoveNext:=0;  
SocketSend client\_socket\Str:=“TRUE”,\NoOfBytes:=4;  
ENDIF  
IF ERRNO\>0 THEN  
IF ERRNO=ERR\_SOCK\_TIMEOUT THEN  
ELSE  
i:=0;  
ENDIF  
ENDIF  
WaitTime 1;  
ENDIF  
ENDIF  
ENDIF  
ENDWHILE  
ENDPROC  
ENDMODULE

I looked into the Cpos and CRobT functions in the manual, but it didn’t really help me. Essentially I just need to take the current position, convert it to a string, and send that string to LV for each position. The problem is I have a ton of positions so I can’t just go in and say “your at position # 5,267”, that would take too long. If someone has done this before, I would greatly appreciate any examples or pointers!

Thanks in advance for any help!  
SM
