Hi,
On Wednesday 09 May 2007 03:59, Micfox Micfox wrote:
> I have the following problem I need to solve and hope I can get some
> advice from this mailing list.
> Let me say I have a program called A (in C language). It can generate
> some output (denoted as B). I need to pass B to the motes through serial
> port. However, the packets from the PC to motes are sent through Java
> program. How can I make B to be passed to mote? (B is a dynamic variable
> and changing as A goes).
TinyOS 2.x has a C SDK (it might exist for tos1 too?). The PC can open a
serial port directly, to which a mote running BaseStation or something like
it is connected. The PC can read and write packets to/from the serial port,
with the connected mote forwarding them between the PC and sensor network.
The SDK can handle active messages.
If memory serves, running make in $TOSROOT/support/sdk/c creates
serialpacket.c and serialpacket.h, then builds libmote.a. The lib contains
everything you need to do active message packet exchange via the serial port
(plus the code in sfsource.o, which you don't need).
To open and close the serial port:
handle = open_serial_source(name,
platform_baud_rate(baud), 0, stderr_msg)
close_serial_source(handle)
Reading packets from the serial port:
pktPtr = read_serial_source(handle, &pktLen)
/* skip sync byte for tmsg */
msg = new_tmsg(pktPtr + 1, pktLen - 1)
spacket_* and tmsg_read_* functions read data
from buffer
To write, it's something like this:
char buffer[big_enough];
/* sync byte added by write_serial_packet */
tmsg_t* msg = new_tmsg(buffer + 1, sizeof(buffer) - 1)
memset(buffer, 0, sizeof(buffer));
spacket_header* and tmsg_write* functions write
data to buffer
write_serial_packet(handle, buffer, sizeof(buffer))
free_tmsg(msg);
The SDK deals with the serial header/footer, helps with the packet envelope,
and provides functions to read and write values adjusting between native and
nx formats as necessary.
Hope this helps,
Steve
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help