Events and timers


I’ve set up a timer to launch a handler. In the handler I have an adl_eventWait(). This returns ADL_RET_ERR_BAD_STATE however.
The ADL_User_Guide says this is because the function was called from Task 0 context. Surely you can generate an event from a timer in this way?
I have tried searching the docs to find more about task context but the relevent bits have escaped me so far. Is the timer event handler a new task? If not how do you go about launching a new task?
Any hints or pointers to relevent sections in the docs appreciated. I know it must be in there somewhere.



There’s a whole lot of things that you cannot do from within timers and interrupt handlers.

However, you CAN send messages (using adl_msgSend()) from these contexts. The message handler then runs in the normal execution context

Here’s what to do:

Define the appropriate number of different messages.
Set up a message handler to listen for messages to yourself, and handle the message types defined above.

From the Interupt or Timer Handler, send a message to yourself requesting that the appropriate action be undertaken.

Have a look at the adl_sendMsg() function in the ADL users guide.

ciao, Dave

(p.s. I’m working with Open AT 2.20 & OS R7.3).


Thanks for the thoughts. I’ve had a look at that. I would need to send a message to the handler, then one back once the processing is done. The event handler should be the way to do this though. If I explain better what I am trying to do, then some one could point to the best way to achieve it.
I have a input commands coming in from a number of sources, possibly simultaneously, I queue these with the adl queue system which will serialise the input. When a command arrives I want to launch an event to request the command be processed. Another task sits waiting for the event and once received, processes the command. Once the command is processed, the event is cleared and returns to waiting for the next command event.

I’m not entirely clear on how to set up the Wait For Event in a new task. I tried to do it by launching a timer handler, but there is probably a more direct way of doing this. (The Wait For Event handler did launch but I got the error in my openning post).

I’m searching for taskCreate, taskDelete type functions but not finding anything relevent. I’ve read ADL is all event driven but I haven’t got my head round it all yet. Any hints appreciated.


I’ve found the multi-tasking example now and the way of initialising tasks:

const adl_InitTasks_t adl_InitTasks [] =
{ MainTask, 3*1024, "MAIN", 3 },    // Main task
{ SubTask1, 3*1024, "SUB1", 2 },    // Sub task 1
{ SubTask2, 3*1024, "SUB2", 1 },    // Sub task 2
{ NULL, 0, NULL, 0 }

Trying to debug it now and see if anything is happening but the traces have all disappeared, :angry: it never ends! I’m using M2M, R7.3 . I’ve checked the trace settings, resynced, re-booted but no sign. They we’re there in earlier incarnations. Oh well back to the brick wall :frowning: Bang. Bang. Bang. Bang.


In fact the trace filters have disappeared. There are no flows listed so I can’t select them anymore. Where have they gone, how can I get them back ???


are you using m2m studio?

then when you’re connected you need to refresh the target info tree, then you can configure the remote traces.



I’m using the multitasking features of R7.3 to run a data logger. I have a number of device tasks (i.e. collect data from I/O), a event task that takes care of storing the data from the I/O tasks, and a couple of ancillary tasks for things like Data uploads, alarms etc.

All communications between tasks is done using the adl_msgSend() calls. It’s very asynchronous, but I’ve found it woks extremely well.

The basic layout of all my tasks is as follows:

MessageHandler(source, id, data)
        case MYMSGA:
            // process message A
        case MYMSGB:
            // process message B
            // ignore other messages

    // Set up task variables and states
    // this is called by the OpenAT multitasker.
    // This is the function that is in the Adl_InitTasks[] array.

Note that there is NO adl_main() function when using the multitasking. The first function called is the function with the highest priority in the Adl_InitTasks[] array.

ciao, Dave


Thanks for the input. I’ll bear messages in mind. The multi-tasking aspects are working now with events. :smiley: The init task table was the key. And not using adl_main().
My problems with the Trace are down to the serial-usb. I can get TMT to read the usb on an XP machine, but not with M2M on a Vista machine. Anyone else having issues with this?

PS> davidc you were a life saver on the WIP-bearer events, or lack of them, sorted with a adl_gprsSubcribe. Cheers!