/* * lightingcontrol * * Copyright (C) 2012 Jonathan McCrohan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // gcc lightingcontrol.c -o lightingcontrol -lm `pkg-config --libs --cflags libconfig` #ifndef VERSION_STRING #define VERSION_STRING "[undefined version]" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // handle SIGALRM by resetting it void minute_check (int signum) { syslog (LOG_DEBUG, "SIGALRM"); alarm (60); } int main (int argc, char *argv[]) { int SYSLOG_CONSOLE_OUTPUT = 0; int k; // check the argv array for strings matching -d for (k = 1; k < argc; k++) { if (strcmp (argv[k], "-d") == 0) { SYSLOG_CONSOLE_OUTPUT = LOG_PERROR; } } openlog ("lightingcontrol", SYSLOG_CONSOLE_OUTPUT | LOG_PID | LOG_CONS, LOG_USER); syslog (LOG_INFO, ""); syslog (LOG_INFO, "lightingcontrol [%s] starting", VERSION_STRING); syslog (LOG_INFO, ""); const char *configfile = "lightingcontrol.cfg"; config_t cfg; const char *serial_device_address; int serial_baud_rate; int serial_data_bits; const char *serial_parity; int serial_stop_bits; char *p; config_init (&cfg); // attempt to read config // loads entire file to memory and destroys file descriptor if (!config_read_file (&cfg, configfile)) { fprintf (stderr, "%s:%d - %s\n", config_error_file (&cfg), config_error_line (&cfg), config_error_text (&cfg)); config_destroy (&cfg); syslog (LOG_ERR, "Unable to find configfile"); return -1; } else { syslog (LOG_INFO, "configfile found successfully"); } // die if core config file options aren't there if (!(config_lookup_string (&cfg, "serial.device", &serial_device_address) && config_lookup_int (&cfg, "serial.baud", &serial_baud_rate) && config_lookup_int (&cfg, "serial.data_bits", &serial_data_bits) && config_lookup_string (&cfg, "serial.parity", &serial_parity) && config_lookup_int (&cfg, "serial.stop_bits", &serial_stop_bits))) { syslog (LOG_ERR,
# Kabel Berlin
# freq sr fec mod
C 394000000 6900000 NONE QAM64
C 113000000 6900000 NONE QAM64
C 466000000 6900000 NONE QAM64