From a8d9504a3c38cec9ecf9eb19511d0905004fe711 Mon Sep 17 00:00:00 2001 From: mmdolze Date: Mon, 10 Feb 2014 06:48:44 +0000 Subject: [PATCH] Fix several problems with data escape handling in hd44780-serial: 1. A bogus address calculation was done (spotted by G. Smith). 2. The displayID was added to the data escape character even if the connection type does not support multiple displays (spotted by G. Smith). 3. When calculation if data escape is necessary, the character 0xff could not be escaped. Changed an updates all connection types (M. Dolze). --- ChangeLog | 1 + server/drivers/hd44780-serial.c | 5 +++-- server/drivers/hd44780-serial.h | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 262e209..8a82de0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ v0.5dev (ongoing development) + glcd driver: 'picolcdgfx' for picoLCD 256x64 from Mini-Box.com (S. Meharg) * picolcd: Improvements to IR processing (M. Jones) + hd44780: Added 'spi' connection type (S. Dawson) + * hd55780/serial: Change data escape handling (G. Smith) v0.5.6 - Remove deprecated CFontz633 driver. Use CFontzPacket with Model=633 instead! diff --git a/server/drivers/hd44780-serial.c b/server/drivers/hd44780-serial.c index 42704f1..9362efe 100644 --- a/server/drivers/hd44780-serial.c +++ b/server/drivers/hd44780-serial.c @@ -280,9 +280,10 @@ serial_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char f /* Do we need a DATA indicator byte? */ if ((SERIAL_IF.data_escape != '\0') && (((ch >= SERIAL_IF.data_escape_min) && - (ch < SERIAL_IF.data_escape_max)) || + (ch <= SERIAL_IF.data_escape_max)) || (SERIAL_IF.multiple_displays && displayID != lastdisplayID))) { - write(p->fd, &SERIAL_IF.data_escape + displayID, 1); + unsigned char esc_ch = SERIAL_IF.data_escape + (SERIAL_IF.multiple_displays) ? displayID : 0; + write(p->fd, &esc_ch, 1); } write(p->fd, &ch, 1); } diff --git a/server/drivers/hd44780-serial.h b/server/drivers/hd44780-serial.h index 931fced..c0b48f9 100644 --- a/server/drivers/hd44780-serial.h +++ b/server/drivers/hd44780-serial.h @@ -23,7 +23,7 @@ struct hd44780_SerialInterface { unsigned char instruction_escape; /**< Instruction escape character. */ unsigned char data_escape; /**< Data escape character. */ unsigned char data_escape_min; /**< Escaped data lower limit (inclusive) */ - unsigned char data_escape_max; /**< Escaped data upper limit (exclusive) */ + unsigned char data_escape_max; /**< Escaped data upper limit (inclusive) */ /**@}*/ unsigned int default_bitrate; /**< Bitrate device is set to by default */ @@ -66,11 +66,11 @@ struct hd44780_SerialInterface { */ static const struct hd44780_SerialInterface serial_interfaces[] = { /* 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_PICANLCD, 0x11, 0x12, 0x00, 0x1F, 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, 0xFD, 0, 0xFF, 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_VDR_WAKEUP, 0xC0, 0xC4, 0xC0, 0xCF, 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 } };