Utility to manage ASCII communications. Register a header and event and then pass messages into the class and events are generated on a match

Dependents:   Waldo_Embed_V2

Example

#include "mbed.h"
#include "CommHandler.h"
  
DigitalOut myled(LED1);
CommHandler msgs;
  
char *one(char* msg)
{
    // you can parse msg here
    LOG("\n");
    return msg;
}
  
class Wrap
{
public:
    Wrap(){}
    char *two(char *msg)
    {
        // you can parse msg here
        LOG("\n");
        return msg;
    }
}obj;
  
char *three(char* msg)
{
    // you can parse msg here
    LOG("\n");
    return msg;
}
  
int main()
{
    char *tmp = 0;
  
    msgs.attachMsg("One", &one);
    msgs.attachMsg("Two", &obj, &Wrap::two);
    msgs.attachMsg("Three", &three);
      
    tmp = msgs.messageLookup(0);
    printf("0:%s\n", tmp);
    tmp = msgs.messageLookup(1);
    printf("1:%s\n", tmp);
    tmp = msgs.messageLookup(2);
    printf("2:%s\n", tmp);
    tmp = msgs.messageLookup(3);
    printf("3:%s\n", tmp);
    tmp = msgs.messageLookup(4);
    printf("4:%s\n", tmp);
         
    tmp = msgs.serviceMessage("Two-00-66-99-20133");
    printf("1: Found: %s\n", tmp);
    tmp = msgs.serviceMessage("One-99-60-1-339788354");
    printf("2: Found: %s\n", tmp);
    tmp = msgs.serviceMessage("Three-xx-xx-XX-XXXXXXX");
    printf("3: Found: %s\n", tmp);
      
    error("End of Test\n");
}

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Wed Apr 10 06:19:52 2013 +0000
Parent:
4:5d54100399b1
Child:
6:fc49b34fbac4
Commit message:
nothing notable

Changed in this revision

LinkedList.lib Show annotated file Show diff for this revision Revisions of this file
LogUtil.lib Show annotated file Show diff for this revision Revisions of this file
--- a/LinkedList.lib	Wed Apr 10 04:49:02 2013 +0000
+++ b/LinkedList.lib	Wed Apr 10 06:19:52 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/sam_grove/code/LinkedList/#c14e7a918e21
+http://mbed.org/users/sam_grove/code/LinkedList/#59b2aa82b517
--- a/LogUtil.lib	Wed Apr 10 04:49:02 2013 +0000
+++ b/LogUtil.lib	Wed Apr 10 06:19:52 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/sam_grove/code/LogUtil/#c54746c59ba4
+http://mbed.org/users/sam_grove/code/LogUtil/#9f20058284bd