I'm trying to read the messages sent by the Oscilloscope sample
application from C.
I generated the C .h and .c file using mig, using the following Makefile
rule:
oscilloscope_msg.h oscilloscope_msg.c: ../Oscilloscope.h
mig -target=null c ../Oscilloscope.h oscilloscope -o $@
I got a range of functions, like:
uint16_t oscilloscope_version_get(tmsg_t *msg);
so far so good. I started to work from source code of prettylisten.c, as
that already connects to the serial forwarder. basically I added the
following function:
void oscilloscope_print(tmsg_t *msg) {
unsigned int version;
unsigned int interval;
unsigned int id;
unsigned int count;
version = oscilloscope_version_get(msg);
interval = oscilloscope_interval_get(msg);
id = oscilloscope_id_get(msg);
count = oscilloscope_count_get(msg);
printf("version: %u, interval: %u, id: %u, count: %u\n",
version, interval, id, count);
}
and call it after hexprint():
printf("dest %u, src %u, length %u, group %u, type %u\n ",
spacket_header_dest_get(msg),
spacket_header_src_get(msg),
spacket_header_length_get(msg),
spacket_header_group_get(msg),
spacket_header_type_get(msg));
hexprint((uint8_t *)tmsg_data(msg) + spacket_data_offset(0),
tmsg_length(msg) - spacket_data_offset(0));
putchar('\n');
oscilloscope_print(msg);
it all compiles fine. so far so good.
but when I actually run the application, the data that gets printed is
bogus:
$ ./oscilloscope localhost 9002
dest 65535, src 65535, length 28, group 0, type 147
00 10 01 00 00 01 00 bb 04 fe 04 6e 04 6e 04 ca 04 ca 04 f5 04 f5 05
0e 05 0e 04 64
version: 65535, interval: 65535, id: 7168, count: 37632
dest 65535, src 65535, length 28, group 0, type 147
00 10 01 00 00 01 00 bc 04 68 04 55 04 55 04 c9 04 c9 05 08 01 26 02
80 02 80 01 32
version: 65535, interval: 65535, id: 7168, count: 37632
dest 65535, src 65535, length 28, group 0, type 147
00 10 01 00 00 01 00 bd 05 6e 03 86 03 86 04 e1 04 e1 05 69 05 69 04
fa 04 fa 05 62
version: 65535, interval: 65535, id: 7168, count: 37632
whereas the interval used is 256, the id of the mote is 1, the count is
much much lower, etc.
I tried to call oscilloscope_print() with a similar pointer magic as
hexprint() is called, but then I get a segfault.
what am I doing wrong here?
Akos
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help