sending more than 80 characters at a time
Hello,I have to send a message with socketSend to a tcp server in python. I create my string so that I can read it in JSON.All of this is working correctly, but my message is too long for a string.So i want to know if ther is another way to do it or a way to up the number of characteres in the send function.
Thanks and here a part of my code
string_to_send:=("{"+ByteToStr(34\Char)+"status"+ByteToStr(34\Char)+": "+ByteToStr(34\Char)+"rec_pos"+ByteToStr(34\Char)+ByteToStr(34\Char)+"name"+ByteToStr(34\Char)+" :"+name+ByteToStr(34\Char)+"x"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.x,3)+ByteToStr(34\Char)+"y"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.y,3)+ByteToStr(34\Char)+"z"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.z,3)+"}");
SocketSend my_socket\Str:=string_to_send;
Thanks and here a part of my code
string_to_send:=("{"+ByteToStr(34\Char)+"status"+ByteToStr(34\Char)+": "+ByteToStr(34\Char)+"rec_pos"+ByteToStr(34\Char)+ByteToStr(34\Char)+"name"+ByteToStr(34\Char)+" :"+name+ByteToStr(34\Char)+"x"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.x,3)+ByteToStr(34\Char)+"y"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.y,3)+ByteToStr(34\Char)+"z"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.z,3)+"}");
SocketSend my_socket\Str:=string_to_send;
0
Answers
-
Hi...You could work with \Data instead of \Str this way you would have 1024 'characters' instead of 80.Like this ...
PROC Send() CONST num MAX_BYTE_ARRAY:=1024; VAR socketdev mySocketL; VAR byte sendByteL{MAX_BYTE_ARRAY}; VAR string strSendL; ! CODE ... ! .... IF string THEN ! If it is a string, it must contain only 80 characters ... strSendL:="{"+ByteToStr(34\Char)+"status"+ByteToStr(34\Char)+": "+ByteToStr(34\Char)+"rec_pos"+ByteToStr(34\Char)+ByteToStr(34\Char)+"name"+ByteToStr(34\Char)+" :"+name+ByteToStr(34\Char)+"x"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.x,3)+ByteToStr(34\Char)+"y"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.y,3)+ByteToStr(34\Char)+"z"+ByteToStr(34\Char)+" :"+numToStr(tooltempo.tframe.trans.z,3)+"}"; FOR id FROM 1 TO MAX_BYTE_ARRAY DO sendByteL{id}:=StrToByte(strSendL\Char); ENDFOR ! ... IF Byte THEN ! If your string is coming in bytes, you can use it like this ... SocketReceive mySocketL\Data:=sendByteL; ! CODE ... SocketSend mySocketL\Data:=sendByteL; ENDPROC
... I haven't tested it, but maybe it will help.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)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings