summaryrefslogtreecommitdiff
path: root/irman.c
diff options
context:
space:
mode:
authorchatty1999-01-25 17:48:34 +0000
committerchatty1999-01-25 17:48:34 +0000
commit1856a89741061f3ab838f00e415dae1245764a39 (patch)
treefc49a5b0024a29a4f920a7ef71294a70a393d9ea /irman.c
parentfb242b482a81baa20d5cb4b8a563880b16aebdee (diff)
downloadirbox-1856a89741061f3ab838f00e415dae1245764a39.zip
irbox-1856a89741061f3ab838f00e415dae1245764a39.tar.gz
irbox-1856a89741061f3ab838f00e415dae1245764a39.tar.bz2
irbox-1856a89741061f3ab838f00e415dae1245764a39.tar.xz
Prepared for version 1.0:
- headers updated - renamed irman.c into irbox.c - added options at launch - added functions to read tables from a directory and its index - created a utility for creating tables - created files for launch at boot time
Diffstat (limited to 'irman.c')
-rw-r--r--irman.c137
1 files changed, 0 insertions, 137 deletions
diff --git a/irman.c b/irman.c
deleted file mode 100644
index 9f70163..0000000
--- a/irman.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- *
- * IRBOX, an Ivy driver for infra-red remote controls
- *
- * Copyright 1998-1999
- * Centre d'Etudes de la Navigation Aerienne
- *
- * Main file
- *
- * $Id$
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "timer.h"
-#include "ivy.h"
-#include "ivychannel.h"
-
-#include "irdev.h"
-#include "irtable.h"
-
-#define DEFAULT_DEVICE "/dev/ttyS1"
-
-typedef struct {
- int num;
- int state; /* State */
- int period[2]; /* time on, time off */
- TimerId timerid; /* TimerId */
-} Button;
-
-static const char* app_name;
-static IrState *ir;
-
-
-static void
-Handle (Channel channel, int fd, void *data)
-{
- IrState *ir = (IrState*) data;
- IrIntr (ir);
-}
-
-static void*
-IrTimeout (IrTimerCallback cb, long value, void *data )
-{
- return TimerRepeatAfter (1, value, (TimerCb) cb, ir);
-}
-
-static void
-IrUntimeout (void *id)
-{
- TimerRemove ((TimerId) id);
-}
-
-static void
-IrEventCb (IrState *ir, const unsigned char* code)
-{
- IrTable* t;
- const char* key;
- if (IrTableTranslateCode (code, &t, &key)) {
- IvySendMsg ("%s Down control=%s button=%s", app_name, t->name, key);
- } else {
- IvySendMsg ("%s unknown code %.3d %.3d %.3d %.3d %.3d %.3d", app_name, code[0], code[1],code[2],code[3],code[4],code[5]);
- fprintf (stderr, "unknown code %.3d %.3d %.3d %.3d %.3d %.3d\n", code[0], code[1],code[2],code[3],code[4],code[5]);
- }
-}
-
-static void
-IrFailCb (IrState* ir)
-{
- fprintf(stderr,"IR box not responding.\n");
- IvySendMsg ("%s Failed", app_name);
- IvyStop ();
-}
-
-int
-main (int argc, char *argv[])
-{
- unsigned short bport = DEFAULT_BUS;
- int c;
- const char* dev = DEFAULT_DEVICE;
- const char* domains = 0;
- static char app_name_buf [1024];
-
- while ((c = getopt(argc, argv, "s:b:n:")) != EOF)
- switch (c) {
- case 'b':
- bport = atoi(optarg) ;
- break;
- case 's':
- dev = optarg;
- break;
- case 'd':
- domains = optarg;
- break;
- case 'n':
- app_name = optarg;
- break;
- }
-
- if (!app_name) {
- gethostname (app_name_buf, 1024);
- strcat (app_name_buf, ".IRBOX");
- app_name = app_name_buf;
- }
-
- ir = IrOpen (dev);
- if (!ir) {
- fprintf (stderr, "Can't open %s\n", dev);
- return -1;
- }
-
- if (!IrInit (ir, IrEventCb, IrFailCb, IrTimeout, IrUntimeout))
- return -1;
-
- IrTableReadFile ("tables/akaiVCR1.ir");
- IrTableReadFile ("tables/akaiVCR2.ir");
- IrTableReadFile ("tables/rcaTV1.ir");
- IrTableReadFile ("tables/rcaVCR1.ir");
- IrTableReadFile ("tables/sonyTV.ir");
- IrTableReadFile ("tables/sonyVCR1.ir");
-
- IvyInit (app_name, bport, 0, 0, 0, 0, 0);
- IvyChannelSetUp (IrGetFd (ir), ir, 0, Handle);
-
- IvyStart (domains);
- IvyMainLoop (0);
-
- return 0 ;
-}