Hi All,

Hi All,

I have a struct to send data through serial port.
My java application works fine sending data to mote, but I'd like to
use a C language to do this.
I know that in the makefile we have the mig to generate my
StructMsg.java, but what should I
do to generate it in C?
I took the struct in the C file, but it doesn't work. See the code below.

#define DEVICE "/dev/ttyUSB1"

typedef struct data_id_serial_msg {
  char data_id[BUF];
} data_id_serial_msg_t;

data_id_serial_msg_t data;
int mote_fd = open(DEVICE, O_RDWR, 0);
if (mote_fd == -1) {
        perror("mote - open device");
}
teste = &data;

while(1) {
        idx++;
        for (k = 0; k < BUF; k++) {
                teste->data_id[k] = idx;
        }
        write(mote_fd, (void*)teste, sizeof(data_id_serial_msg_t));
        sleep(2);
}


What is wrong? Is there a header?

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