PCSDK Messaging Domain

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:usersdocumentsvisual 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()

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:
http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=../RobotCommunicationAppManual/doc27.html

Note that you can test a command if it requires specific rights and if you have those at the moment.
http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=../RobotCommunicationAppManual/doc23.html

I will log a case that the doc topic should be tested and updated.

That solved my problem! :wink:

How could you see from the callstack that it was a logon missing:frowning:?

Peeked into the source maybe?

I think we should have throw a proper exception, for example a AuthenticationException…

[QUOTE=bme]That solved my problem! :wink:[/QUOTE]
Glad to be of service.

[QUOTE=Niklas Skoglund]

How could you see from the callstack that it was a logon missing:frowning:?

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… :sunglasses:

Agreed on the proper exception, sigh, I will log another case then… :clown_face:

The links above are no good anymore :-/