Hilscher Gesellschaft fuer Systemautomation mbH
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.
Hilscher Gesellschaft fuer Systemautomation mbH
This is the complete block, the callback functions at the end and the declaration part at the front I let out here.
TThomasTLR_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.
Hilscher Gesellschaft fuer Systemautomation mbH
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
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
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:
Please submit the complete *_Process module. Otherwise we will search the needle in the haycock.