Hello and welcome to Chief Delphi. It sounds like you’re using a different system than we all use in our competition, but it’s likely that some people around here will still be able to help you.
If you use the documentation that Max linked to, you should be able to figure out a lot about the CMUcam2 protocol. From the work I’ve done with it, it’s pretty simple. Send a few bytes out your UART, terminate it with a carriage return, and you’ll get back an ACK and/or the data you requested. All of the commands are documented in the CMUcam2 manual, and on Kevin Watson’s site. As for the actual code to read and write to your UART, that’s beyond the scope of my knowledge. Somebody else around here may know, or you can poke around on Google. Once you’ve got that figured out, the CMUcam2 interface is pretty simple. (As somewhat of a side note, you can play around with the commands and see what they do by plugging the CMUcam2 into your computer, and then using a program like Hyperterminal to send and receive the data.)
Thanks for your reply
But what do you think about this code, any notes please.
/* A simple program that sends an order to the CMUcam2 camera and
reads back from it*/
:confused: :rolleyes: :]
#include <stdio.h>
#include <string.h>
int main ()
{
FILE* fp;
char prompt = 0;
int Written_Char;
fp = fopen ("/dev/uart1", "r+"); //Open the camera port for reading and writing.
if (fp)
{
Written_Char = fputc(":TC\r",fp); // writing a character to the UART.
prompt = getc(fp); // Get a character from the UART.
fprintf(fp, "Closing the UART file.
");
fclose (fp);
}
return 0;
}
i think you want to take the : out of that… you see a : before all the lines in the manual just because thats how hyperterm prompt is… take out the : and try that
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.: