/* ss-hw/main.c * * Entry point of the Smartshelf hardware interface program. * * Copyright (C) 2003, 2004 * Andy Goth * * This code is available under the GNU General Public License; see COPYING. */ #include #include #include #include #include #include #include #include "evlist/evlist.h" #include "ss-hw/user.h" #include "ss-hw/pressure.h" #include "ss-hw/rfid.h" static evlist_t el; static void sig_cleanup(int sig) { signal(sig, SIG_DFL); evlist_loop_exit(&el); } int main(int argc, char** argv) { extern char** environ; device_t user, pressure, rfid; evlist_init(&el); /* Smartshelf core (the "user" program). */ device_init(&user, "Smartshelf core"); fd_init(&user, "stdin/stdout", STDIN_FILENO, STDOUT_FILENO); user_init(&user, &rfid); evlist_device_add(&el, &user); /* Pressure sensor. */ device_init(&pressure, "pressure sensor"); /* null_init(&pressure); */ /* child_init(&pressure, "misc/randpres 500", environ, O_RDONLY); */ serial_init(&pressure, "/dev/ttyS1", CS8, 0, 0, B9600, 0, 0); pressure_init(&pressure, &user); evlist_device_add(&el, &pressure); /* RFID tag reader. */ device_init(&rfid, "RFID tag reader"); /* null_init(&rfid); */ /* child_init(&rfid, "misc/hex > log", environ, O_WRONLY); */ serial_init(&rfid, "/dev/ttyS0", CS8, 0, PARENB, B38400, 0, 0); rfid_init(&rfid, &user); evlist_device_add(&el, &rfid); /* Main event loop. */ signal(SIGINT, sig_cleanup); signal(SIGTERM, sig_cleanup); evlist_loop(&el); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); /* Cleanup. */ evlist_cleanup(&el ); device_cleanup(&user ); device_cleanup(&pressure); device_cleanup(&rfid ); return EXIT_SUCCESS; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */