PCSDK Messaging Domain
bme
✭
I am having trouble sending messages from an PC SDK application to an IRC5 queue. In order to ensure that I am doing everything right, I have made a small test application that is more or less identical to the messaging example in the PC SDK manual. The IRC5 virtual controller's task has been setup properly according to the manual as well.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.Messaging;
namespace MsgTest
{
class Program
{
private static Controller c;
private static IpcQueue tRob1Queue;
private static IpcQueue myQueue;
private static IpcMessage sendMessage;
private static IpcMessage recMessage;
static void Main(string[] args)
{
//initiation code, eg in constructor
c = new Controller(Guid.Parse("611d8508-7286-417c-8112-a474fc93b788"));
//get T_ROB1 queue to send msgs to RAPID task
tRob1Queue = c.Ipc.GetQueue("RMQ_T_ROB1");
//create my own PC SDK queue to receive msgs
if (c.Ipc.Exists("PC_SDK_Q"))
{
myQueue = c.Ipc.GetQueue("PC_SDK_Q");
c.Ipc.DeleteQueue(myQueue.QueueId);
}
myQueue = c.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE);
myQueue = c.Ipc.GetQueue("PC_SDK_Q");
//Create IpcMessage objects for sending and receiving
sendMessage = new IpcMessage();
recMessage = new IpcMessage();
//in an event handler, eg. button_Click
SendMessage(true);
CheckReturnMsg();
}
public static void SendMessage(bool boolMsg)
{
Byte[] data = null;
//Create message data
if (boolMsg)
{
data = new UTF8Encoding().GetBytes("bool;TRUE");
}
else
{
data = new UTF8Encoding().GetBytes("bool;FALSE");
}
//Place data and sender information in message
sendMessage.SetData(data);
sendMessage.Sender = myQueue.QueueId;
//Send message to the RAPID queue
tRob1Queue.Send(sendMessage);
}
private static void CheckReturnMsg()
{
IpcReturnType ret = IpcReturnType.Timeout;
string answer = string.Empty;
int timeout = 5000;
//Check for msg in the PC SDK queue
ret = myQueue.Receive(timeout, recMessage);
if (ret == IpcReturnType.OK)
{
//convert msg data to string
answer = new UTF8Encoding().GetString(recMessage.Data);
Console.WriteLine(answer);
//MessageBox should show: string;"Acknowledged"
}
else
{
Console.WriteLine("Timeout!");
}
}
}
}
However, when trying to send the message, an null reference exception occur with the following stack trace:
Am I doing something wrong?
at ABB.Robotics.Controllers.SDKBase.UpdateCallContext(Controller controller)
at ABB.Robotics.Controllers.SDKBase.UpdateCallContext(IController controller)
at ABB.Robotics.Controllers.Messaging.IpcQueue.Send(Int32 Sender, Int32 Cmd, Int32 UserDef, Int32 UserData, Byte[] Data)
at ABB.Robotics.Controllers.Messaging.IpcQueue.Send(IpcMessage Message)
at MsgTest.Program.SendMessage(Boolean boolMsg) in c:users*****documentsvisual studio 2010ProjectsMsgTestMsgTestProgram.cs:line 56
at MsgTest.Program.Main(String[] args) in c:users*****documentsvisual studio 2010ProjectsMsgTestMsgTestProgram.cs:line 37
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
John Wiberg2013-03-01 14:07:57
0
Comments
-
Hi bme.Looks like there is a logon missing there.All the code that directly do something with the controller needs to be logged on with the correct user rights.You could try out with this.c.Logon(UserInfo.DefaultUser); and see if that is sufficient. (Dont forget to logout as well).Maybe you can find something interesting by doing this one:Note that you can test a command if it requires specific rights and if you have those at the moment.I will log a case that the doc topic should be tested and updated.John
Developer Center0 -
That solved my problem!0
-
How could you see from the callstack that it was a logon missing?
Peeked into the source maybe?I think we should have throw a proper exception, for example a AuthenticationException...0 -
[QUOTE=bme]That solved my problem! [/QUOTE]Glad to be of service.
How could you see from the callstack that it was a logon missing?
Peeked into the source maybe?I think we should have throw a proper exception, for example a AuthenticationException...[/QUOTE]For the callstack I cheated and got help from R&D...Agreed on the proper exception, sigh, I will log another case then...
John Wiberg2013-03-05 13:35:32John
Developer Center0 -
The links above are no good anymore :-/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