From 743643052cdb61b6e025266bb9e43abdce6f6d83 Mon Sep 17 00:00:00 2001 From: marschap Date: Sun, 14 Oct 2007 10:47:50 +0000 Subject: [PATCH] hd44780-serial: adapt detection of ConnectionType to new infrastructure --- server/drivers/hd44780-serial.c | 26 +++++++++----------------- server/drivers/hd44780-serial.h | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/server/drivers/hd44780-serial.c b/server/drivers/hd44780-serial.c index 95cc9eb..3b06666 100644 --- a/server/drivers/hd44780-serial.c +++ b/server/drivers/hd44780-serial.c @@ -140,36 +140,28 @@ hd_init_serial(Driver *drvthis) /* READ CONFIG FILE */ /* Get interface type */ - int counter; - char conf_serialif[SERIALIF_NAME_LENGTH]; + int i; - strncpy(conf_serialif, drvthis->config_get_string(drvthis->name, "connectiontype", 0, ""), SERIALIF_NAME_LENGTH); - conf_serialif[SERIALIF_NAME_LENGTH-1] = '\0'; p->serial_type = 0; - for (counter = 0; counter < (sizeof(serial_interfaces)/sizeof(SerialInterface)); counter++) { - if (strcasecmp(conf_serialif, serial_interfaces[counter].name) == 0) { - p->serial_type = counter; + for (i = 0; serial_interfaces[i].connectiontype != HD44780_CT_UNKNOWN; i++) { + if (p->connectiontype == serial_interfaces[i].connectiontype) { + p->serial_type = i; break; } } - if (p->serial_type != counter) { - report(RPT_ERR, "HD44780: serial: serial interface %s unknown", conf_serialif); - report(RPT_ERR, "HD44780: serial: available interfaces:"); - for (counter = 0; counter < (sizeof(serial_interfaces)/sizeof(SerialInterface)); counter++) - report(RPT_ERR, " %s", serial_interfaces[counter].name); + if (p->serial_type != i) { + report(RPT_ERR, "HD44780: serial: unknown connection type"); return -1; } - report(RPT_INFO,"HD44780: serial: device type: %s", SERIAL_IF.name); - /* Check if user knows the capabilities of his hardware ;-) */ if (p->have_keypad && !(SERIAL_IF.keypad)) { - report(RPT_ERR, "HD44780: serial: keypad is not supported by %s", SERIAL_IF.name); + report(RPT_ERR, "HD44780: serial: keypad is not supported by connection type"); report(RPT_ERR, "HD44780: serial: check your configuration file and disable it"); return -1; } if (p->have_backlight && !(SERIAL_IF.backlight)) { - report(RPT_ERR, "HD44780: serial: backlight control is not supported by %s", SERIAL_IF.name); + report(RPT_ERR, "HD44780: serial: backlight control is not supported by connection type"); report(RPT_ERR, "HD44780: serial: check your configuration file and disable it"); return -1; } @@ -179,7 +171,7 @@ hd_init_serial(Driver *drvthis) size_t bitrate; conf_bitrate = drvthis->config_get_int(drvthis->name, "Speed", 0, SERIAL_IF.default_bitrate); - if (conf_bitrate==0) + if (conf_bitrate == 0) conf_bitrate = SERIAL_IF.default_bitrate; if (convert_bitrate(conf_bitrate, &bitrate)) { report(RPT_ERR, "HD44780: serial: invalid configured bitrate speed"); diff --git a/server/drivers/hd44780-serial.h b/server/drivers/hd44780-serial.h index 23c6ba1..4526eda 100644 --- a/server/drivers/hd44780-serial.h +++ b/server/drivers/hd44780-serial.h @@ -2,13 +2,14 @@ #define HD44780_SERIAL_H #include "lcd.h" /* for Driver */ +#include "hd44780-low.h" #define SERIALIF_NAME_LENGTH 20 #define DEFAULT_DEVICE "/dev/lcd" typedef struct SerialInterface { - char name[SERIALIF_NAME_LENGTH]; + int connectiontype; char instruction_escape; char data_escape; char data_escape_min; /* escaped data lower limit */ @@ -34,13 +35,14 @@ typedef struct SerialInterface { /* List of connectiontypes managed by this driver, if you change something here, remember also to change hd44780-drivers.h */ static const SerialInterface serial_interfaces[] = { - /* name instr data v ^ bitrate bits K esc B Besc Boff Bon Multi End */ - { "picanlcd", 0x11, 0x12, 0x00, 0x20, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, - { "lcdserializer", 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, - { "los-panel", 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFF, 0, 0, 0, 0 }, - { "vdr-lcd", 0xFE, 0, 0x00, 0x00, 9600, 4, 0, 0x00, 0, 0, 0, 0, 0, 0 }, - { "vdr-wakeup", 0xC0, 0xC4, 0xC0, 0xD0, 9600, 4, 0, 0x00, 1, 0, 0xC9, 0xC8, 1, 0xCF }, - { "pertelian", 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 1, 0xFE, 0x02, 0x03, 0, 0 } + /* type instr data v ^ bitrate bits K esc B Besc Boff Bon Multi End */ + { HD44780_CT_PICANLCD, 0x11, 0x12, 0x00, 0x20, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { HD44780_CT_LCDSERIALIZER, 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { HD44780_CT_LOS_PANEL, 0xFE, 0, 0x00, 0x00, 9600, 4, 1, 0xFE, 1, 0xFF, 0, 0, 0, 0 }, + { HD44780_CT_VDR_LCD, 0xFE, 0, 0x00, 0x00, 9600, 4, 0, 0x00, 0, 0, 0, 0, 0, 0 }, + { HD44780_CT_VDR_WAKEUP, 0xC0, 0xC4, 0xC0, 0xD0, 9600, 4, 0, 0x00, 1, 0, 0xC9, 0xC8, 1, 0xCF }, + { HD44780_CT_PERTELIAN, 0xFE, 0, 0x00, 0x00, 9600, 8, 0, 0x00, 1, 0xFE, 0x02, 0x03, 0, 0 }, + { HD44780_CT_UNKNOWN, 0x00, 0, 0x00, 0x00, 0, 0, 0, 0, 0, 0x00, 0x00, 0x00, 0, 0 } }; /* initialize this particular driver */