hi all,
I have two C files one is ev_test.c and capture.c, the capture.c file is to capture the images from the camera sensor, Now, i need to access the capture.c file from ev_test.c,
NOTE:
The ev_test.c is key press event interrupt generator file, in that i configured the a key= "volumebutton", if i press the key "volumebutton" it must call the main function of the capture.c file and it must capture the images
Can any one help me on how to call the main function in this
NOTE:
If you want the C files i can send you for reference
THE MAIN FUNCTION OF ev_test.c is
int main (int argc, char **argv)
{
int fd, rd, i, j, k;
struct input_event ev[64];
int version;
unsigned short id[4];
unsigned long bit[EV_MAX][NBITS(KEY_MAX)];
char name[256] = "Unknown";
int abs[5];
if (argc < 2) {
printf("Usage: evtest /dev/input/eventX\n");
printf("Where X = input device number\n");
return 1;
}
if ((fd = open(argv[argc - 1], O_RDONLY)) < 0) {
perror("evtest");
return 1;
}
if (ioctl(fd, EVIOCGVERSION, &version)) {
perror("evtest: can't get version");
return 1;
}
printf("Input driver version is %d.%d.%d\n",
version >> 16, (version >> 8) & 0xff, version & 0xff);
ioctl(fd, EVIOCGID, id);
printf("Input device ID: bus 0x%x vendor 0x%x product 0x%x version 0x%x\n",
id[ID_BUS], id[ID_VENDOR], id[ID_PRODUCT], id[ID_VERSION]);
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
printf("Input device name: \"%s\"\n", name);
memset(bit, 0, sizeof(bit));
ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]);
printf("Supported events:\n");
for (i = 0; i < EV_MAX; i++)
if (test_bit(i, bit[0])) {
printf(" Event type %d (%s)\n", i, events[i] ? events[i] : "?");
if (!i) continue;
ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]);
for (j = 0; j < KEY_MAX; j++)
if (test_bit(j, bit[i])) {
printf(" Event code %d (%s)\n", j, names[i] ? (names[i][j] ? names[i][j] : "?") : "?");
if (i == EV_ABS) {
ioctl(fd, EVIOCGABS(j), abs);
for (k = 0; k < 5; k++)
if ((k < 3) || abs[k])
printf(" %s %6d\n", absval[k], abs[k]);
}
}
}
printf("Testing ... (interrupt to exit)\n");
while (1) {
rd = read(fd, ev, sizeof(struct input_event) * 64);
if (rd < (int) sizeof(struct input_event)) {
printf("yyy\n");
perror("\nevtest: error reading");
return 1;
}
printf("OVIYA RD=%d SIZE=%d\n",rd, sizeof(struct input_event));
for (i = 0; i < rd / sizeof(struct input_event); i++)
if (ev[i].type == KEY_VOLUMEDOWN) {
printf("Event: time %ld.%06ld, -------------- %s ------------\n",
ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].code ? "Config Sync" : "Report Sync" );
} else if (ev[i].type == EV_MSC && (ev[i].code == MSC_RAW || ev[i].code == MSC_SCAN)) {
printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %02x\n",
ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type,
events[ev[i].type] ? events[ev[i].type] : "?",
ev[i].code,
names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?",
ev[i].value);
} else {
printf("OVIYA CHECK3--------------\n");
printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n",
ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type,
events[ev[i].type] ? events[ev[i].type] : "?",
ev[i].code,
names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?",
ev[i].value);
}
}
}
Thanks
shan
[Edit]Code block added and shouting from title removed[/Edit]