RMQ error- invalide message
ting1013
✭
I'm trying to send messages to the controller through a c# program. Now, it will work several times and then randomly, a message will become invalid message and the error pops up. I really don't know why. I also emptied the queue every time I send a message, so I don't think it's the problem of queue size. The problem kind of happens randomly, sometime message A is invalid, sometime message B is invalid.
Is there anyway I can check inside what's going on? Or does anyone have any ideas about it?
Thanks a lot!
Is there anyway I can check inside what's going on? Or does anyone have any ideas about it?
Thanks a lot!
5
Comments
-
I attached my RAPID code here: What I'm trying to do is to send a message from c# program to the controller. And the controller will move as the message says. For example, I send "left", then the controller will move to the left by a distance. This will work the first couple of time and then the error appears. Is there anything wrong in my code?
Thanks a lot!MODULE COM_LVAR bool flag := FALSE;VAR bool clearFlag := FALSE;VAR string command;VAR intnum endnum;VAR intnum connectnum;CONST robtarget p11 := [ [600, -100, 800], [1, 0, 0, 0], [0, 0, 0,0], [ 9E9, 9E9, 9E9, 9E9, 9E9, 9E9] ];PROC main()RMQEmptyQueue;CONNECT endnum WITH endCommTrap;CONNECT connectnum WITH RABMsgs;IRMQMessage flag, connectnum;IRMQMessage command, endnum;WHILE flag = FALSE DO!do something, eg. normal processing...IF clearFlag = TRUE THENRMQEmptyQueue;clearFlag := FALSE;ENDIFWaitTime 3;ENDWHILE!PC SDK message received - do something...TPWrite "Message from PC SDK, will now...";IDelete connectnum;IDelete endnum;EXIT;ENDPROCTRAP endCommTrapVAR rmqmessage msg;VAR rmqheader header;VAR rmqslot rabclient;VAR num userdef;VAR string ack := "get command";VAR robtarget p1;VAR robtarget pl;VAR robtarget pr;VAR robtarget pu;VAR robtarget pd;VAR string in_com;RMQGetMessage msg;RMQGetMsgHeader msg \Header:=header\SenderId:=rabclient\UserDef:=userdef;!check data type and assign value to flag variableIF header.datatype = "string" THENRMQGetMsgData msg, in_com;!return receipt to sender! RMQSendMessage rabclient, ack;ELSETPWrite "Unknown data received in RABMsgs...";ENDIFStopMove;StorePath;p1 := CRobT();IF in_com = "endCom" THENflag := TRUE;ELSEIF in_com = "left" THENp1 := CRobT();pl := p1;pl.trans.x := p1.trans.x + 50;MoveL pl, v1000, fine, tool0;ELSEIF in_com = "right" THENp1 := CRobT();pr := p1;pr.trans.x := p1.trans.x - 50;MoveL pr, v1000, fine, tool0;ELSEIF in_com = "up123" THENp1 := CRobT();pu := p1;pu.trans.z := p1.trans.z + 50;MoveL pu, v1000, fine, tool0;ELSEIF in_com = "down" THENp1 := CRobT();pd := p1;pd.trans.x := p1.trans.x - 50;MoveL pd, v1000, fine, tool0;ENDIFRestoPath;StartMove;clearFlag := TRUE;ENDTRAP
ENDMODULE0 -
Does it matter if you are telling it to move "absolute" to the left, or "relative" to the left? Meaning if you tell it to move relative to the left 2 inches, it will move 2 inches every time you tell it. If you tell it to move absolute to the left 2 inches, it will move to the position that is 2 inches from whatever the origin is defined. Does any of that matter for what you're doing?
0 -
I had a similar problem just a few days ago.
In your C# Program, you need to make sure that the IpcMessage object is not one you used before for sending a message.
Because once you set data vid the SetData() Method, it seems like it also sets the length of the data in there.
If you reuse the same object again, then the length stays at the maximum size it was used with. The message Queue then expects a message with a certain size, the actual message unfortunately, is smaller than this certain size.
This would result in the following behaviour:
string sent by C# program: "string;left" -> works fine, overall length is 11
string sent by C# program: "string:right" -> works fine, overall length is 12
string sent by C# program: "string;up123" ->works fine, overall length is 12
string sent by C# program: "string;left" -> does not work because the overall length of your string is less (11) then the last one (12) you set.
If you keep your C# program running, and only reset the program pointer on your RAPID program, then restart it and try sending "string;up123" again from the C# program that you left running when the error occured, this message should work, because it has the right size.
What you could try to do is, in your C# program, whenever you are sending a new message, create a new IpcMessage object.
If this does not work, make sure all the strings are always the same size.
Would be great if you'd let me know if this was your problem, but I am fairly certain that this is the reason.1
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 783 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings