Author Topic: Creating a new Task  (Read 38685 times)

Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Creating a new Task
« on: March 30, 2008, 12:54:03 AM »
in TaskConfig.h i added...

extern void fnMINE(TTASKTABLE *);

Then under const UTASK_TASK ctNodes[] i added mine here,

TASK_APPLICATION,                                                      // application task
TASK_DEBUG,                                                            // maintenance task
TASK_MINE,

and...

{ "Mine",       fnMINE,        MEDIUM_QUE,  (DELAY_LIMIT)(0.10 * SEC), 0, UTASKER_STOP},


and lastly....

void fnMINE(TTASKTABLE *ptrTaskTable)
{

   printf("System is Up\r\n");

}


yet, it never fires, what else do i need to do to kick start it ?
and, do tasks need to be in a while(1) statemnt like below ?


void fnMINE(TTASKTABLE *ptrTaskTable)
{
    while(1)
    {
   printf("System is Up\r\n");
    }
}



Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #1 on: March 30, 2008, 01:08:00 AM »
Hi

I don't see how you have defined TASK_MINE.
It should be #define TASK_MINE 'M' so that it matches with the first letter of the task name string.

However there is a task with this define - #define TASK_SNMP               'M'

If you have SNMP active it shouldn't have the same. I don't expect you to have SNMP active so I am assuming you have a different define which is not matching.

Regards

Mark

Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Creating a new Task
« Reply #2 on: March 30, 2008, 01:10:23 AM »
Opps, sorry i forgot to add that when i posted.

#define TASK_MINE            'z'

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Creating a new Task
« Reply #3 on: March 31, 2008, 12:43:06 AM »
-seulater-------------------------------------
Opps, sorry i forgot to add that when i posted.

#define TASK_MINE            'z'
---------------------------------------------

So as Mark said, the Task name string in quotes as below should begin with the same letter you've defined for your task.


{ "zMine",       fnMINE,        MEDIUM_QUE,  (DELAY_LIMIT)(0.10 * SEC), 0, UTASKER_STOP},

Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Creating a new Task
« Reply #4 on: March 31, 2008, 02:05:23 AM »
thanks, i have decided to wait to use it until there is a manual, which explains all the features and give short examples for each.
i dont have the time to search through the forum for my answers and look through pages of code to see how things work.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #5 on: March 31, 2008, 11:44:43 AM »
Hi

Pages 4 and 5 of the "uTasker - Operating System Basics" - http://www.utasker.com/docs/uTasker/uTaskerV1.3.PDF should contain most information.

The following should contain most other details and examples:
http://www.utasker.com/forum/index.php?topic=32.0

Another reference for creating 'real' applications can be found at:
http://www.utasker.com/forum/index.php?topic=171.0

I will review this later today and possibly convert it into a new manual. Any inputs as to what extra information is needed to save users' time are welcome.

Regards

Mark

Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Creating a new Task
« Reply #6 on: March 31, 2008, 12:31:55 PM »
since you asked...
Please remember that people going to try your code out dont know jack about it. so when creating a manual you have to look at it from their point of view. Many times i see that the documents dont keep this in mind. they have it all in their head and assume too much.

#1) all functions need to be in the document, and listed in order.
#2) each function needs a description of what it is and what it does and its return values if any.
#3) a bonus feature would be to have the function name, the description and then a short example with comments of how to use it.
#4) also, it would be nice to tell us where to add our code at, I.E. make a example of a task running say "hello World" every second.

the more you put in the documents, the better off you will be. Most guys i know that try new things out are just like me, can it do bla...bla...bla... and they want to know that answer right away before learning the whole thing. Many times just to find out it wont. So people today want results quick to determine if it will work for them. The better the docs the more people will be willing to give it a try.  When no docs are there, many people just turn and go onto the next guy who does.

I just happen to take the time to mention this because i think you have the potential for something good here, and i would like it to become popular.

 

« Last Edit: March 31, 2008, 12:33:42 PM by seulater »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #7 on: April 02, 2008, 12:49:14 AM »
Hi

I have added a first draft of a new guide to the use of the scheduling features in the uTasker. It can be found here:
http://www.utasker.com/docs/uTasker/uTaskerV1.3_user_guide.PDF (users guide - first steps for new users)

It takes quite a long time to get such a document written and reviewed but I have put it on-line immediately, even if there may be some more things to be added and some tidying up before it is absolutely complete. This should enable you to continue with your tests without losing any time. I have based it on the use of debug outputs and the "Hello, World!" example but with some interesting variations so I hope that you will find it fun too!!

Below is the main source of the code examples so that you do not have to type them in. All examples have been checked for accuracy using the uTasker simulator so they should also work without any hick-ups if the document is followed.

Note that I have added an overview of the routines used in the examples in the appendix but I haven't elaborated there. The reason is that the examples use only a few of the available functions (but possibly most common and useful ones) and so going in to more detail in this introduction seemed to be detracting from the actual goal of it. What I am looking into is a more general solution for the complete project which should be more usable, based on automatic documentation generation (something like doxygen) to put the complete routines in a browsable on-line form. I will need to do some more work on this but I already believe that it will result in the best solution with optimum maintenance capabilities.

Good luck

Regards

Mark



Code: [Select]
#define OWN_TASK        TASK_MY_FIRST_TASK
#define E_TIMER_PERIODIC    1
extern void fnMyFirstTask(TTASKTABLE *ptrTaskTable)
{
    static unsigned char ucCounter = 0;
    QUEUE_HANDLE        PortIDInternal = ptrTaskTable->TaskID;           // queue ID for task input
    unsigned char       ucInputMessage[HEADER_LENGTH];                   // reserve space for receiving simple messages

    while ( fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH )) {   // check input queue
        switch ( ucInputMessage[MSG_SOURCE_TASK] ) {                     // switch depending on message source
        case TIMER_EVENT:
            if (E_TIMER_PERIODIC == ucInputMessage[MSG_TIMER_EVENT]) {
                fnDebugMsg("Test number ");
                fnDebugDec(ucCounter++, 0, 0);
                fnDebugMsg("\r\n");
                if (ucCounter == 10) {
                    fnDebugMsg("Work done!!\r\n");
                    ucCounter = 0;
                }
                else {
                    uTaskerMonoTimer( OWN_TASK, (DELAY_LIMIT)(1*SEC), E_TIMER_PERIODIC );
                }
            }
            break;

        case INTERRUPT_EVENT:
            if (WAKE_UP_LITTLE_BABY == ucInputMessage[MSG_INTERRUPT_EVENT]) {
                fnDebugMsg("Hello World!!\r\n");
                uTaskerMonoTimer( OWN_TASK, (DELAY_LIMIT)(6*SEC), E_TIMER_PERIODIC );
            }
        }
    }
}


// Application task kick-off code (not all used together)
uTaskerStateChange(TASK_MY_FIRST_TASK, UTASKER_ACTIVATE);
uTaskerMonoTimer( TASK_MY_FIRST_TASK, (DELAY_LIMIT)(3 * SEC), 0 );
fnInterruptMessage(TASK_MY_FIRST_TASK, WAKE_UP_LITTLE_BABY);

// The task configuration
extern void fnMyFirstTask(TTASKTABLE *ptrTaskTable);                        // prototype
#define TASK_MY_FIRST_TASK      'x'                                      // my first task's reference
{ "x marks my first task!!", fnMyFirstTask, NO_QUE,(DELAY_LIMIT)(5 * SEC), (DELAY_LIMIT)(2 * SEC),  UTASKER_STOP},      // my first task (runs after a delay of 5s and then periodically every 2s)



Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Creating a new Task
« Reply #8 on: April 02, 2008, 01:23:42 AM »
Now thats what i am talking about, great job and perfict examples. ;D

now all that is really left is a pdf for all the function calls, that we can use like fnDebugMsg and so on.

with an example of using each. then it will allow anyone to quickly try it out.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #9 on: April 02, 2008, 01:29:57 AM »
Hi

It will certainly follow... (as I said possibly/probably in an on-line browsable form... to be decided).

But first I have to sleep again (it very quickly becomes early morning when working in such stuff!!).

In return I would love your comments on the use of the uTasker simulator, which you promised (is that overstated?) to try out.

Cheers

Mark

Offline seulater

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Creating a new Task
« Reply #10 on: April 02, 2008, 01:33:17 AM »
Quote
In return I would love your comments on the use of the uTasker simulator, which you promised (is that overstated?) to try out.

No, i did say that, but... so much of my work is with SPI, I2C, UART, Address & Data bus, i dont see how it will help, since it cannot mimic thoes things.

Actually, this pdf came in the nick of time for me. I was trying out lwip which i got working, but their web page strategy is idiotic. they expect everyone to know perl and have it to convert the web site over, talk about a dumb idea!!!

« Last Edit: April 02, 2008, 01:40:55 AM by seulater »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #11 on: April 02, 2008, 02:12:45 AM »
Hi

The simulator does I2C (it contains various I2C devices - presently DS1621, DS1307 RTC, DS3640 RTC and secure memory, Wolfson WM8510 Audio Codec, 24C01 EEPROM, MAX543X Digital Potentiometer, NATIONAL LM80 Microprocessor System Hardware Monitor, PHILIPS PCF8574 Port Expander), also SPI FLASH devices, UARTs (mapped to PC's COM ports), Ethernet Controller (Mapped to PC's NIC), CAN controller (mapped to TCP<->Eval board link - only Coldfire and presently not active in project though..).

It can do ports but limited in real-time capability - although it supports new script files to play in sequences over interfaces and ports which should allows quite complicated tests to be possible (very new in project, without that much experience just yet).

Therefore my conclusion is that you will only really know when you have given it a quick try....  ;-) A 20 minute investment could enable you to save hugh amounts of development time, who knows..?

Regards

Mark


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #12 on: April 02, 2008, 02:54:51 PM »
Hi

An even faster method to see the simulator in action is to try the executables - there are various examples on the web site at
http://www.utasker.com/Demos/exes/exes.html

No set up or installation needed. Just download LPC2378 and LPC210X for example. (only a few kBytes so almost zero download time). Put all contents to a local directory and double click uTaskerV1-3_LPC2378.exe and then uTaskerV1-3_LPC2101_2_3_PLCC44.exe.

You can establish a connection with your web browser to the LPC2378 [activate NIC in menu LAN | Select Working NIC] or via Telnet, and communicate via COM1 with LPC210X - responds with menu (same interface as the TELNET one to the LPC2378).
This works within seconds - but does have the restriction that COM1 is fixed and also the initial IP settings for the LPC2378 are fixed... more info here: http://www.utasker.com/forum/index.php?topic=133.0

Regards

Mark
« Last Edit: April 02, 2008, 04:17:32 PM by mark »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: Creating a new Task
« Reply #13 on: April 05, 2008, 10:16:17 PM »
Hi

After evaluating doxygen as a method of generating automatic documentation of the software functions I have decided against using it. Not that it is not good, but the project really has to be built up respecting the doxygen conventions in the first place, otherwise it needs a lot of work to get it into the right form (mainly adding documentation and labels to the code).

It is possible to use it on any project, even when the labels have not been prepared, and it produces html pages with links between functions, defines, struct, variables etc. which is very impressive. But, without the proper control through properly set labels and document comments it produces vast amount of stuff which doesn't seem to really help in using the code.

However I still think that a web based solution would be very suitable. It allows descriptions, examples, etc to be continuously added and updated. The on-line version is always up to date, and links between descriptions, functions, examples, and other relevent information are possible.

I also realise that it represents a lot of work to do, so I have started and put it on-line immediately (with a warning that it is experimental and under construction). It will take some time before it is complete, and also some time before it is ready to even add first content, but one has to start somewhere and, as can be seen, the first step has been taken.

http://www.utasker.com/docs/Code.html

The link to this side is via the documents page (http://www.utasker.com/docs/documentation.html).

Regards

Mark


Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Creating a new Task
« Reply #14 on: April 06, 2008, 11:39:09 AM »
Hi Mark,

I think this is an excellent idea to consolidate all the various bits of help and documentation into one online resource, it would be good to allow this resource to also be available off line too.

We use a product called Help and Manual from ec-software http://www.ec-software.com/index.html this allows us to have one single source for PDF manuals windows CHM files and online HTML files. Its not the cheapest product out there but it is very good. Just thought I'd let you know about this product in case you hadn't come across it.

Cheers

Martin