View Single Post
  #6   Spotlight this post!  
Unread 20-03-2007, 18:16
Shinigami2057 Shinigami2057 is offline
Slackware Is Your New God (Mentor)
AKA: Harry Bock
FRC #1350 (Rambots)
Team Role: Programmer
 
Join Date: Oct 2006
Rookie Year: 2006
Location: Johnston, RI
Posts: 106
Shinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really niceShinigami2057 is just really nice
Re: C code to get information from CMUcam2

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.
__________________
One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.