This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details. xdc.runtime.Error.raise: terminating execution CC3200

Other Parts Discussed in Thread: CC3200, SYSBIOS

Hi,

I want to execute the following code (every few microseconds):

Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
Report("sl_Send_Status = %d. Data sent: %s. sizeof(RawData):%d.\n\r",Status,RawData,sizeof(RawData));

if(Status < 0)
{
UART_PRINT("Transmition Failed!\r\n");
sl_Close(socket_descriptor);
}

that is, to send a packet in the stack bypass mode using a CC3200.

How can I do that? if possible, please provide a working example. Thanks!

So far I am creating a clock and on the rising edge I execute the code above. The complete code is:

Void clk0Fxn(UArg arg0);
Void clk1Fxn(UArg arg0);

...

in the main

// Configure and start clock
Clock_Params clkParams;

/* Create a periodic Clock Instance with period = 5 system time units */
Clock_Params_init(&clkParams);
clkParams.period = 10000; //10s
clkParams.startFlag = TRUE;
Clock_create(clk0Fxn, 10000, &clkParams, NULL); 

/* Create an one-shot Clock Instance with timeout = 11 system time units */
clkParams.period = 0;
clkParams.startFlag = FALSE;
clk2 = Clock_create(clk1Fxn, 11000, &clkParams, NULL);

Clock_start(clk2);

...

Void clk0Fxn(UArg arg0)
{

Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
Report("sl_Send_Status = %d. Data sent: %s. sizeof(RawData):%d.\n\r",Status,RawData,sizeof(RawData));

if(Status < 0)
{
UART_PRINT("Transmition Failed!\r\n");
sl_Close(socket_descriptor);
}

}

But when I debug the code I get the following error in the console after 10s:

ti.sysbios.gates.GateMutex: line 99: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
xdc.runtime.Error.raise: terminating execution

I guess because I am using a mutex (or GateMutex) inside a SWI. What can I do?

  • I'm not sure which of the function calls you're making in the Clock function is trying to enter the GateMutex, but one way around this is to move all this Clock function code into a high priority Task thread that is blocked on a Semaphore_pend(). The Clock function would then call Semaphore_post() which would immediately unblock the task thread that could safely enter the GateMutex.

    Alan

  • Thanks Alan!

    The line causing the error is:

    Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);

    The current error mentions that must be called from a Task:

    ti.sysbios.knl.Semaphore: line 289: assertion failure: A_badContext: bad calling context. Must be called from a Task.
    xdc.runtime.Error.raise: terminating execution

    How should I modify the code? please include an example or where can I get one. Thanks!

  • Move your clock function code into a Task function surrounded by a Semaphore_pend():

    myTask()
    {
       while (TRUE) {
            Semaphore_pend(mySem, BIOS_WAIT_FOREVER);
            Status= sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
            Report("sl_Send_Status = %d. Data sent: %s. sizeof(RawData):%d.\n\r",Status,RawData,sizeof(RawData));
            if(Status < 0)
            {
                 UART_PRINT("Transmition Failed!\r\n");
                 sl_Close(socket_descriptor);
           }
       }
    }

    Have your clock function post the Semaphore that the Task is blocked on:

    Void clk0Fxn(UArg arg0)
    {
        Semaphore_post(mySem);
    }