Hello people,

I think I'm in the right way. Is it true?
Before send data to serial port, I have to protocol the data.
So, I've tried the following snippet of code:

        char i, idx = 1;
        char packet[4];
        memset(packet, idx++, 4); // data

        tmsg_t *msg = new_tmsg(packet + 1, 4 - 1); // protocol
        spacket_header_dest_set(msg, 0);
        spacket_header_src_set(msg, 1);
        spacket_header_length_set(msg, 2);
        spacket_header_group_set(msg, 0);
        spacket_header_type_set(msg, 9);
        for (i = 0; i < 4; i++) {
                spacket_data_set(msg, i, packet[i]);
        }

        int ok = write_serial_packet(src, msg, sizeof(msg));

But, the mote doesn't read the data. What is wrong?

Can anyone send me a snippet of code or buffer?
My data is an array of 4 bytes.
the mote works fine using SerialForwarder and my TestSerial application (java).

Thanks all,
Daniel Patrick


On Tue, Jun 17, 2008 at 9:46 AM, Daniel Pereira <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> Based on ./tinyos-2.x/support/sdk/c directory, I've developed an
> application to write data in the serial port.
> So, I connect the mote in the serial port, but the mote dont receive data.
> I guess I have the protocol the data.
> See My code:
>
>        // open serial port
>        src = open_serial_source(DEVICE, 57600, 1, stderr_msg);
>        if (!src) {
>                fprintf(stderr, "Couldn't open serial port at %s:%d\n", 
> DEVICE, 57600);
>                exit(1);
>        }
>
>       char idx = 1;
>       char packet[4];
>       while (1) {
>                memset(packet, idx++, 4);
>                int ok = write_serial_packet(src, packet, 4);
>
>                printf("Packet: %d\n", packet[0]);
>                if (ok < 0)
>                exit(2);
>                if (ok > 0)
>                fprintf(stderr, "Note: write failed\n");
>                sleep(2);
>        }
>
> Should I protocol the data (packet[4])?
>
> Thanks all
> Daniel Patrick
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to