industrialNETworXnetx

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 28.11.2006 | 12:04 | 3 replies

TLR_TASK_STATE_CANCELED while executing a function

TThomas wrote:
Hello,

I have a task that should communicate with a UART task similar that from the rcx_UART_example. At the point of receiving a packet for giving out text the UART task starts the function "TaskCommand_rcX_UART_CommandOut" to send the data of my packet to the UART.
Now my problem is that at the entrance to the function the task state is RUNNING but with the first F10 step the ptRsc->tLoc.eTskState changes to TLR_TASK_STATE_CANCELED and there is just the local error variable initialized.
What could be the reason for this change? Could it be that the OS changes this variable?

Thanks,
TThomas

Hi,

it is hard for me to say, what is your problem, without any code snippet.

I assume, that you forgot to add the "break;" command in the switch - case block from the *_Process.c. If you have a look into the NXSB100_rcX_2Task-Demo_Ver.1.0.zip example you will see, that there are the break is set.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 28.11.2006 | 13:15

TThomas wrote:
Hello,

within the TLR_QUE_WAITFORPACKET loop I have the following switch case for the desired packet:

switch(((TLR_PACKET_HEADER_T*)pvPck)->ulCmd)
{
case RCX_UART__CMD_COMMAND_OUT_REQ:
{
//Command output request
TaskCommand_rcX_UART_CommandOut(ptRsc,pvPck,hUrt);
break;
}

The TaskCommand_rcX_UART_CommandOut function begins with:

TLR_RESULT
TaskCommand_rcX_UART_CommandOut(RCX_UART__RSC_T FAR* ptRsc,
RCX_UART__PACKET_COMMAND_OUT_REQ_T FAR* ptPck,
RX_HANDLE hUrt)
{
TLR_RESULT eRslt;

if((ptPck->tHead.ulLen == 0x00000000L )||
(ptPck->tHead.ulLen > UART__PACKET_COMMAND_OUT_MAX_LENGTH )||
(ptPck->tData.szCommand[ptPck->tHead.ulLen - 1] != 0x00))
{
/*Invalid packet*/
eRslt = TLR_E_FAIL;
}
.
.
.

Now, when the TaskCommand_rcX_UART_CommandOut function is entered the variable changes their value like I described in my first post. I have no idea what changes the value of tLoc.eTskState, but I can see the change taking place when "TLR_RESULT eRslt;" is executed.

TThomas

Hi,

with your code snippet I am unable to see, why you run into a canceled state.

In the posted code I am unable to see:

Quote:
case TLR_CMD_END_PROCESS_REQ:
{
/* process end request */
ptRsc->tLoc.eTskState = TLR_TASK_STATE_CANCELED;
break;
}

Please submit the complete *_Process module. Otherwise we will search the needle in the haycock.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 28.11.2006 | 13:48

TThomas wrote:
This is the complete block, the callback functions at the end and the declaration part at the front I let out here.
TThomas

TLR_RESULT
TaskProcess_rcX_UART(RCX_UART__RSC_T FAR* ptRsc)
{
TLR_RESULT eRslt;
//RX_RESULT erXRes;
RX_URT_HANDLER_UN unHdlr;
TLR_HANDLE hQue; // process queue short cut
TLR_VOID* pvPck; // packet


// initialize local variables
hQue = ptRsc->tLoc.hQue;
eRslt = TLR_S_OK;

eRslt = Drv_UrtIdentifyUart("VERBOSE", 0, &hUrt);
if( eRslt!=RX_OK ) {
return eRslt;
}


// Create first of all the UART as Peripheral and install the Callback functions
eRslt = Drv_UrtInitializeUart( hUrt,
UartIO_CharRxReady,
UartIO_CharTxReady,
UartIO_Exception,
//&sensorAnswerData,//handing over pointer to memory variable
ptRsc,//task resource for handling data to be saved
TRUE,
&unHdlr);
if( eRslt!=RX_OK ) {
return eRslt;
}


// Check for the corresponding interrupt
eRslt = Drv_IntIdentifyInterrupt("VERBOSE", 0, &hUrtInt);
if( eRslt!=RX_OK) {
return eRslt;
}

// Initialize the interrupt routine
/*erXRes = Drv_IntInitializeInterrupt( hUrtInt,
unHdlr.fnIrq,
NULL );
if( erXRes!=RX_OK ) {
return(erXRes);
}*/


// Enable now UART port reception
Drv_UrtSetReceiveMode(hUrt);

// Enable now the Interrupt for the UART
Drv_IntEnableInterrupt(hUrtInt);

UINT8 bTestUrt = 0;

for(bTestUrt=0;bTestUrt<=5;){
if(
(RX_OK == Drv_UrtSendCharacter(hUrt, \'t\')) &&
(RX_OK == Drv_UrtSetTransmitMode(hUrt)) )
bTestUrt++;
}


//////////////////////////////////////////////////////////////////
//this does not work anyway neither with the syssleep nor without

//rX_VbsPrintf(" *** rcX-UART Test ***\\n\\r");
//rX_SysSleepTask(100);
//////////////////////////////////////////////////////////////////

do
{
do
{
// wait for packet
eRslt = TLR_QUE_WAITFORPACKET(hQue, &pvPck, TLR_INFINITE);

if(eRslt != TLR_S_OK)
{
//No packet received
continue;
}

switch(((TLR_PACKET_HEADER_T*)pvPck)->ulCmd)
{
case RCX_UART__CMD_COMMAND_OUT_REQ:
{
//Command output request
TaskCommand_rcX_UART_CommandOut(ptRsc,pvPck,hUrt);
break;
}

case RCX_APO__CMD_REPLY_RES:
{
// Reply response
Taskcommand_rcX_UART_ReplyRes(ptRsc,pvPck);
break;
}


case TLR_CMD_END_PROCESS_REQ:
{
// process end request
ptRsc->tLoc.eTskState = TLR_TASK_STATE_CANCELED;
break;
}

default:
{
// unknown command
TaskCommand_rcX_UART_Unknown(ptRsc, pvPck);
break;
}
}

} while(ptRsc->tLoc.eTskState != TLR_TASK_STATE_CANCELED);

//
// process of task is canceled
// check number of outstanding requests
// if all confirmations received, stop the process

} while(ptRsc->tLoc.uCntOut != 0);

return eRslt;
}

Mh.... I think I found out your problem.

TLR_RESULT
TaskProcess_rcX_UART(RCX_UART__RSC_T FAR* ptRsc)
{
TLR_RESULT eRslt;
//RX_RESULT erXRes;
RX_URT_HANDLER_UN unHdlr;
TLR_HANDLE hQue; // process queue short cut
TLR_VOID* pvPck; // packet

// initialize local variables
hQue = ptRsc->tLoc.hQue;
eRslt = TLR_S_OK;

Here I am missing the change to "TLR_TASK_STATE_RUNNING" like:

TLR_RESULT
TaskProcess_rcX_UART(RCX_UART__RSC_T FAR* ptRsc)
{
TLR_RESULT eRslt;
//RX_RESULT erXRes;
RX_URT_HANDLER_UN unHdlr;
TLR_HANDLE hQue; // process queue short cut
TLR_VOID* pvPck; // packet

// initialize local variables
hQue = ptRsc->tLoc.hQue;
eRslt = TLR_S_OK;

/* process */
ptRsc->tLoc.eTskState = TLR_TASK_STATE_RUNNING;

If you do not change the status to running, the setting is by default set to Canceled.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 17.08.2009 | 15:59

TThomas wrote:
that\'s it', 'hola,

this was the reason, I did not thought in not having it pushed to the running state yet, because it was already doing something. I learned a lot,
thank you very much
TThomas

Login