RobotStudio event

IPC Messaging Code example problems / questions...

Options
Hi,

I'm trying to get an IPC message to come across using the example in the PC SDK Manual (3HAC03657-001 Rev A).  

There is an odd section that I can't make sense of, and I can't find better documentation.

In the example code, there is this line in the example:

//create my own PC SDK queue to receive msgs
if (!c.Ipc.Exists("RAB_Q"))
{
myQueue = c.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE);
myQueue = c.Ipc.GetQueue("PC_SDK_Q");
}


Am I crazy, or is it checking for some random queue name "RAB_Q", then only creating or connecting "myQueue" up to "PC_SDK_Q" if RAB_Q does not exist???  RAB_Q is not mentioned in any of the 4 manuals that have anything to do with IPC message queues that I've seen.  My best guess is that this is the code you really want:

            If aController.Ipc.Exists("PC_SDK_Q") Then
                myQueue = aController.Ipc.GetQueue("PC_SDK_Q") ' Get the one that already exists.
            Else
                myQueue = aController.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE) ' Create our own queue to receive messages from the controller.
            End If

Essentially, see if the queue exists, if it does, get the queue by name, if not, create it.

So, after that change, I'm able to create the queue, and I can fill it up from the robot side just fine, but when I run:

myQueue.Receive(timeout,recMessage), I get instant timeout.

Somehow in all my playing around I managed to get one message one time, but nothing since then.  

Anyone have any suggestions?  Does the manual example work for anyone else?
Tagged:

Comments

  • Evanmj
    Options
    Following up...

    I pulled this code from another person's question.... and converted to VB, but you get the idea:

                If aController.Ipc.Exists("PC_SDK_Q") Then
                    Console.WriteLine("PC_SDK_Q Exists.")
                    myQueue = aController.Ipc.GetQueue("PC_SDK_Q")
                    aController.Ipc.DeleteQueue(myQueue.QueueId)
                End If
                myQueue = aController.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE)
                myQueue = aController.Ipc.GetQueue("PC_SDK_Q")


    This makes way more sense, although the bottom line is useless, as with the example... why get the queue you just created when the creation of the queue returns the new queue?