That works fairly well - it looks like you're using a UNIX-based system. I believe you'd be better off using the read/write syscalls for the UART interface on your device, i.e.:
Code:
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
typedef struct track {
uint8_t mx, my;
uint8_t x1, y1;
uint8_t x2, y2;
uint8_t pixels, confidence;
} track_t;
int main()
{
track_t camtrack;
char buffer[64] = "tc\r";
int fd = open("/dev/uart1", O_RDWR);
if(fd == -1) {
fprintf(stderr, "Error opening UART");
/* do something */
}
write(fd, buffer, strlen(buffer));
read(fd, &camtrack, sizeof(track_t));
close(fd);
return 0;
}
Or something like that.