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");
}

History

Removed an un-necessary cast. Important to note that this currently should be used in global scope. Objects that are added to the underlying linked list do not have a mechanism to be deleted. Therefore a memory leak would occur if used in local scope default tip

2013-05-22, by sam_grove [Wed, 22 May 2013 19:37:22 +0000] rev 9

Removed an un-necessary cast. Important to note that this currently should be used in global scope. Objects that are added to the underlying linked list do not have a mechanism to be deleted. Therefore a memory leak would occur if used in local scope


Removed nested dependencies. Was getting outta control

2013-05-14, by sam_grove [Tue, 14 May 2013 23:04:09 +0000] rev 8

Removed nested dependencies. Was getting outta control


Updated LogUtil dependency

2013-05-01, by sam_grove [Wed, 01 May 2013 03:51:44 +0000] rev 7

Updated LogUtil dependency


Just updates to dependencies

2013-04-26, by sam_grove [Fri, 26 Apr 2013 06:28:23 +0000] rev 6

Just updates to dependencies


nothing notable

2013-04-10, by sam_grove [Wed, 10 Apr 2013 06:19:52 +0000] rev 5

nothing notable


Moving include to .cpp didnt resolve include at main. Moved to .h. Requires less user awareness

2013-04-10, by sam_grove [Wed, 10 Apr 2013 04:49:02 +0000] rev 4

Moving include to .cpp didnt resolve include at main. Moved to .h. Requires less user awareness


Added include for LogUtil.h to CommHandler.cpp. Link broken when encapsulating the libs

2013-04-10, by sam_grove [Wed, 10 Apr 2013 04:46:29 +0000] rev 3

Added include for LogUtil.h to CommHandler.cpp. Link broken when encapsulating the libs


re-organize to pull-in dependencies when importing with the online compiler

2013-04-10, by sam_grove [Wed, 10 Apr 2013 04:39:57 +0000] rev 2

re-organize to pull-in dependencies when importing with the online compiler


Test wrapping up library dependencies for seamless import

2013-04-10, by sam_grove [Wed, 10 Apr 2013 04:36:11 +0000] rev 1

Test wrapping up library dependencies for seamless import


Created helper class from a function pointer and linked list. Neatly parse ascii communication between devices.

2013-04-08, by sam_grove [Mon, 08 Apr 2013 22:27:42 +0000] rev 0

Created helper class from a function pointer and linked list. Neatly parse ascii communication between devices.