From 2f4c1e5185296cc7c20d5e5eee66435d8f74210c Mon Sep 17 00:00:00 2001 From: mmdolze Date: Wed, 6 Jan 2010 17:23:02 +0000 Subject: [PATCH] Modify serial drivers to use cfmakeraw where applicable. Affects CFontz*, CwLnx, EyeboxOne, MtxOrb, hd44780-lis, and serialPOS. --- ChangeLog | 1 + server/drivers/CFontz.c | 32 ++++++++++++-------------------- server/drivers/CFontz633.c | 32 ++++++++++++-------------------- server/drivers/CFontzPacket.c | 32 ++++++++++++-------------------- server/drivers/CwLnx.c | 27 ++++++++++++++++++++------- server/drivers/EyeboxOne.c | 6 +++--- server/drivers/MtxOrb.c | 12 ++++++++---- server/drivers/hd44780-lis2.c | 6 ++++++ server/drivers/serialPOS.c | 6 +++--- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bee1ee..7843d29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ v.0.5dev (ongoing development) * Introduce shared/defines.h to collect commonly used macros + new driver: SureElec for devices made by SURE Electronics (Laurent Latil) * hd44780-4bit: Fix bug not checking for keypad rows 7-10 correctly + * Modify serial drivers to use cfmakeraw v0.5.3 + lcdexec: notification when called program finishes diff --git a/server/drivers/CFontz.c b/server/drivers/CFontz.c index 57e34b8..2d59855 100644 --- a/server/drivers/CFontz.c +++ b/server/drivers/CFontz.c @@ -216,29 +216,21 @@ CFontz_init(Driver *drvthis) tcgetattr(p->fd, &portset); /* We use RAW mode */ +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw(&portset); +#else + /* The hard way */ + portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + portset.c_oflag &= ~OPOST; + portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); + portset.c_cflag |= CS8 | CREAD | CLOCAL ; +#endif if (usb) { - /* The USB way */ - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL ; portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 3; - } else { -#ifdef HAVE_CFMAKERAW - /* The easy way */ - cfmakeraw(&portset); -#else - /* The hard way */ - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL ; -#endif } /* Set port speed */ diff --git a/server/drivers/CFontz633.c b/server/drivers/CFontz633.c index 02f28c9..80d350b 100644 --- a/server/drivers/CFontz633.c +++ b/server/drivers/CFontz633.c @@ -247,29 +247,21 @@ CFontz633_init (Driver *drvthis) tcgetattr(p->fd, &portset); /* We use RAW mode */ +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw(&portset); +#else + /* The hard way */ + portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + portset.c_oflag &= ~OPOST; + portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); + portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif if (p->usb) { - // The USB way - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL; portset.c_cc[VMIN] = 0; portset.c_cc[VTIME] = 0; - } else { -#ifdef HAVE_CFMAKERAW - /* The easy way */ - cfmakeraw(&portset); -#else - /* The hard way */ - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL; -#endif } /* Set port speed */ diff --git a/server/drivers/CFontzPacket.c b/server/drivers/CFontzPacket.c index 739a1d3..fca4101 100644 --- a/server/drivers/CFontzPacket.c +++ b/server/drivers/CFontzPacket.c @@ -310,29 +310,21 @@ CFontzPacket_init (Driver *drvthis) tcgetattr (p->fd, &portset); /* We use RAW mode */ +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw(&portset); +#else + /* The hard way */ + portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + portset.c_oflag &= ~OPOST; + portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); + portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif if (p->usb) { - // The USB way - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL; portset.c_cc[VMIN] = 0; portset.c_cc[VTIME] = 0; - } else { -#ifdef HAVE_CFMAKERAW - /* The easy way */ - cfmakeraw(&portset); -#else - /* The hard way */ - portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP - | INLCR | IGNCR | ICRNL | IXON ); - portset.c_oflag &= ~OPOST; - portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); - portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); - portset.c_cflag |= CS8 | CREAD | CLOCAL; -#endif } /* Set port speed */ diff --git a/server/drivers/CwLnx.c b/server/drivers/CwLnx.c index 64ddff6..69e15e1 100644 --- a/server/drivers/CwLnx.c +++ b/server/drivers/CwLnx.c @@ -326,15 +326,28 @@ static void Setup_Port(int fd, speed_t speed) struct termios portset; tcgetattr(fd, &portset); - cfsetospeed(&portset, speed); - cfsetispeed(&portset, speed); - portset.c_iflag = IGNBRK; - portset.c_lflag = 0; - portset.c_oflag = 0; - portset.c_cflag |= CLOCAL | CREAD; - portset.c_cflag &= ~CRTSCTS; + + /* We use RAW mode */ +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw(&portset); +#else + /* The hard way */ + portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP + | INLCR | IGNCR | ICRNL | IXON ); + portset.c_oflag &= ~OPOST; + portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); + portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); + portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif + /* Set timeouts */ portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 5; + + /* Set speed */ + cfsetospeed(&portset, speed); + cfsetispeed(&portset, speed); + tcsetattr(fd, TCSANOW, &portset); } diff --git a/server/drivers/EyeboxOne.c b/server/drivers/EyeboxOne.c index 5fdd9b0..a391c4c 100644 --- a/server/drivers/EyeboxOne.c +++ b/server/drivers/EyeboxOne.c @@ -274,9 +274,8 @@ EyeboxOne_init (Driver *drvthis) tcgetattr(p->fd, &portset); - // THIS ALL COMMENTED OUT BECAUSE WE NEED TO SET TIMEOUTS /* We use RAW mode */ -#ifdef HAVE_CFMAKERAW_NOT +#ifdef HAVE_CFMAKERAW /* The easy way */ cfmakeraw(&portset); #else @@ -287,9 +286,10 @@ EyeboxOne_init (Driver *drvthis) portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif + /* Set timeouts */ portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 3; -#endif /* Set port speed */ cfsetospeed(&portset, speed); diff --git a/server/drivers/MtxOrb.c b/server/drivers/MtxOrb.c index 8c9bef5..6e18bee 100644 --- a/server/drivers/MtxOrb.c +++ b/server/drivers/MtxOrb.c @@ -408,9 +408,8 @@ MtxOrb_init (Driver *drvthis) tcgetattr(p->fd, &portset); - // THIS ALL COMMENTED OUT BECAUSE WE NEED TO SET TIMEOUTS /* We use RAW mode */ -#ifdef HAVE_CFMAKERAW_NOT +#ifdef HAVE_CFMAKERAW /* The easy way */ cfmakeraw(&portset); #else @@ -421,16 +420,21 @@ MtxOrb_init (Driver *drvthis) portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif + /* Set timeouts */ portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 3; -#endif /* Set port speed */ cfsetospeed(&portset, speed); cfsetispeed(&portset, B0); /* Do it... */ - tcsetattr(p->fd, TCSANOW, &portset); + if (tcsetattr(p->fd, TCSANOW, &portset) == -1) { + report(RPT_ERR, "%s: failed to configure port (%s)", drvthis->name, strerror(errno)); + return -1; + } + /* Make sure the frame buffer is there... */ p->framebuf = (unsigned char *) calloc(p->width * p->height, 1); diff --git a/server/drivers/hd44780-lis2.c b/server/drivers/hd44780-lis2.c index 20ee7bb..f86a751 100644 --- a/server/drivers/hd44780-lis2.c +++ b/server/drivers/hd44780-lis2.c @@ -91,12 +91,18 @@ int hd_init_lis2(Driver *drvthis) /* Get serial device parameters */ tcgetattr(p->fd, &portset); +#ifdef HAVE_CFMAKERAW + /* The easy way */ + cfmakeraw(&portset); +#else portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON ); portset.c_oflag &= ~OPOST; portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); portset.c_cflag |= CS8 | CREAD | CLOCAL ; +#endif + /* Set timeouts */ portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 3; diff --git a/server/drivers/serialPOS.c b/server/drivers/serialPOS.c index eb2278b..4eeec3b 100644 --- a/server/drivers/serialPOS.c +++ b/server/drivers/serialPOS.c @@ -322,9 +322,8 @@ serialPOS_init (Driver *drvthis) tcgetattr(p->fd, &portset); - // THIS ALL COMMENTED OUT BECAUSE WE NEED TO SET TIMEOUTS /* We use RAW mode */ -#ifdef HAVE_CFMAKERAW_NOT +#ifdef HAVE_CFMAKERAW /* The easy way */ cfmakeraw(&portset); #else @@ -335,9 +334,10 @@ serialPOS_init (Driver *drvthis) portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS ); portset.c_cflag |= CS8 | CREAD | CLOCAL; +#endif + /* Set timeouts */ portset.c_cc[VMIN] = 1; portset.c_cc[VTIME] = 3; -#endif /* Set port speed */ cfsetospeed(&portset, speed);