I have some stuff. Files appear below. I use mig to generate C source
from my NesC code and from the CTP debug message file. Then I use ncg
to generate the AM IDs. This is automated by the ugliness in the
Makefile. In my case it's necessary because the AM IDs either appear in
a different file, or the constant name is guessed incorrectly.
Dima
Makefile:
COMPONENT=BlahAppC
BUILD_EXTRA_DEPS += serread
CLEAN_EXTRA = serread $(patsubst %, serread%, .c .h) $(patsubst %, ctpdbg%, .c
.h)
include $(MAKERULES)
TOSDIR = $(dir $(MAKERULES))/../..
serread: serread.o ctpdbg.o serreadmain.o
g++ -o $@ $(LDFLAGS) $^ -lmote
serread: CFLAGS += -I/opt/tinyos-2.x/support/sdk/c/sf -g --std=c99
serread: LDFLAGS += -L/opt/tinyos-2.x/support/sdk/c/sf -g
serread.o: serread.c
ctpdbg.o: ctpdbg.c
serread.c: Blah.h
mig -o serread.h c $^ BlahMsg
cat serread.h | sed "s/BLAHMSG_AM_TYPE = [0-9]*/`ncg c Blah.h
AM_BLAH_SERIAL_MSG | grep AM_BLAH_SERIAL_MSG`/" > serread.h.tmp
mv serread.h.tmp serread.h
ctpdbg.c: $(TOSDIR)/tos/lib/net/ctp/CtpDebugMsg.h
mig -o ctpdbg.h c $^ CollectionDebugMsg
cat ctpdbg.h | sed "s/COLLECTIONDEBUGMSG_AM_TYPE = -1/`ncg c Blah.h
AM_SERIAL_DBG_MSG | grep AM_SERIAL_DBG_MSG`/" > ctpdbg.h.tmp
mv ctpdbg.h.tmp ctpdbg.h
serreadmain.c:
#include <stdio.h>
#include "serread.h"
#include "ctpdbg.h"
#include "serialsource.h"
int main(void)
{
struct serial_source* port = open_serial_source("/dev/ttyUSB0", 9600,
0, NULL);
if(port == NULL)
{
fprintf(stderr, "Couldn't open port\n");
return -1;
}
while(1)
{
int len;
void* packet = read_serial_packet(port, &len);
if(packet == NULL)
break;
if(((unsigned char*)packet)[7] == AM_BLAH_SERIAL_MSG)
{
struct tmsg msg = {.data = packet+len-BLAHMSG_SIZE, .len = len};
printf("Count: %d\n", BlahMsg_blah_get(&msg)); // this is one of the
functions defined in the generated serread.h file
}
else if(((unsigned char*)packet)[7] == AM_SERIAL_DBG_MSG)
{
struct tmsg msg = {.data = packet+len-COLLECTIONDEBUGMSG_SIZE, .len =
len};
printf("DEBUG Type: %x\n",
CollectionDebugMsg_type_get(&msg));
}
}
close_serial_source(port);
return 0;
}
On Fri, 6 Jun 2008 13:52:50 -0400
"Eric Keller" <[EMAIL PROTECTED]> wrote:
> II was wondering
> if there are any clean examples of pc side programs written in
> c/c++, particularly ones that use MIG. I tried to use it and failed,
> ended up hardwiring my code to extract values from packets.
>
> I searched through the contrib package, and didn't find anything.
> Eric
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help