Fixed compile errors on FreeBSD related to cfmakeraw and friends on the

serial port side.  Also fixed problems with ioperm on the parallel port
side.

Added --waittime option to the server to specify how long the server
should leave a screen up before changing to the next screen.
This commit is contained in:
ppokorny
2001-07-18 22:30:12 +00:00
parent cc73d8e28a
commit e7316389e8
16 changed files with 191 additions and 83 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ AC_TYPE_UID_T
dnl Checks for library functions. dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_FUNCS(select socket strdup strerror strtol uname) AC_CHECK_FUNCS(select socket strdup strerror strtol uname cfmakeraw ioperm)
dnl Check for various defines and features dnl Check for various defines and features
+17 -5
View File
@@ -139,14 +139,26 @@ CFontz_init (lcd_logical_driver * driver, char *args)
} }
//else fprintf(stderr, "CFontz_init: opened device %s\n", device); //else fprintf(stderr, "CFontz_init: opened device %s\n", device);
tcgetattr (fd, &portset); tcgetattr (fd, &portset);
// This is necessary in Linux, but does not exist in irix.
#ifndef IRIX // We use RAW mode
#ifndef SOLARIS #ifdef HAVE_CFMAKERAW
// The easy way
cfmakeraw( &portset ); 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 #endif
#endif
// Set port speed
cfsetospeed (&portset, speed); cfsetospeed (&portset, speed);
cfsetispeed (&portset, speed); cfsetispeed (&portset, B0);
// Do it...
tcsetattr (fd, TCSANOW, &portset); tcsetattr (fd, TCSANOW, &portset);
// Set display-specific stuff.. // Set display-specific stuff..
+18 -5
View File
@@ -84,6 +84,7 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
int contrast = 140; int contrast = 140;
char device[256] = "/dev/lcd"; char device[256] = "/dev/lcd";
int speed = B19200; int speed = B19200;
MtxOrb_type = MTXORB_LKD ; // Assume it's an LCD w/keypad
MtxOrb = driver; MtxOrb = driver;
@@ -170,14 +171,26 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
} }
//else fprintf(stderr, "MtxOrb_init: opened device %s\n", device); //else fprintf(stderr, "MtxOrb_init: opened device %s\n", device);
tcgetattr (fd, &portset); tcgetattr (fd, &portset);
// This is necessary in Linux, but does not exist in irix.
#ifndef IRIX // We use RAW mode
#ifndef SOLARIS #ifdef HAVE_CFMAKERAW
// The easy way
cfmakeraw( &portset ); 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 #endif
#endif
// Set port speed
cfsetospeed (&portset, speed); cfsetospeed (&portset, speed);
cfsetispeed (&portset, speed); cfsetispeed (&portset, B0);
// Do it...
tcsetattr (fd, TCSANOW, &portset); tcsetattr (fd, TCSANOW, &portset);
// Set display-specific stuff.. // Set display-specific stuff..
+19 -6
View File
@@ -408,15 +408,28 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
tcflush(fd, TCIOFLUSH); tcflush(fd, TCIOFLUSH);
// This is necessary in Linux, but does not exist in irix. // We use RAW mode
bzero(&portset, sizeof(portset)); #ifdef HAVE_CFMAKERAW
portset.c_iflag = IGNPAR; // The easy way
portset.c_oflag = 0; cfmakeraw( &portset );
portset.c_cflag = B9600|CS8|CREAD|CLOCAL; #else
portset.c_lflag = 0; // 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
portset.c_cc[VTIME] = 0; // Don't use the timer, no workee portset.c_cc[VTIME] = 0; // Don't use the timer, no workee
portset.c_cc[VMIN] = 1; // Need at least 1 char portset.c_cc[VMIN] = 1; // Need at least 1 char
// Set port speed
cfsetospeed(&portset, B9600);
cfsetispeed(&portset, B0);
// Do it...
tcsetattr(fd, TCSANOW, &portset); tcsetattr(fd, TCSANOW, &portset);
tcflush(fd, TCIOFLUSH); tcflush(fd, TCIOFLUSH);
+19 -10
View File
@@ -45,13 +45,13 @@ GLKDisplay *
struct termios new ; struct termios new ;
GLKDisplay * retval ; GLKDisplay * retval ;
if( name == NULL || (speed & CBAUD) == 0 ) { if( name == NULL || speed == 0 ) {
/* Invalid arguments */ /* Invalid arguments */
errno = EINVAL ; errno = EINVAL ;
return( NULL ); return( NULL );
}; };
fd = open( name, O_RDWR | O_NOCTTY | O_SYNC ); fd = open( name, O_RDWR | O_NOCTTY );
if( fd < 0 ) { if( fd < 0 ) {
return( NULL ); return( NULL );
}; };
@@ -76,20 +76,29 @@ GLKDisplay *
retval->flow = GLKFLOW_OK ; retval->flow = GLKFLOW_OK ;
/* Make new settings */ /* Make new settings */
/* We use RAW mode, and select two stop bits
* to slow things down 10%. Therefore, we IGNORE /* We use RAW mode */
* framing errors incase the module transmits back #ifdef HAVE_CFMAKERAW
* to back with only one stop bit. /* The easy way */
*/ cfmakeraw( &new );
new.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | IGNPAR | ISTRIP #else
/* The hard way */
new.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON ); | INLCR | IGNCR | ICRNL | IXON );
new.c_oflag &= ~OPOST; new.c_oflag &= ~OPOST;
new.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN ); new.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
new.c_cflag &= ~( CBAUD | CSIZE | PARENB | CRTSCTS ); new.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
new.c_cflag |= speed | CS8 | CREAD | CLOCAL | CSTOPB ; new.c_cflag |= CS8 | CREAD | CLOCAL ;
#endif
/* Set default MIN and TIMEOUT values */
new.c_cc[VMIN] = 0 ; new.c_cc[VMIN] = 0 ;
new.c_cc[VTIME] = GLK_TIMEOUT ; new.c_cc[VTIME] = GLK_TIMEOUT ;
/* Set the out and in speeds */
cfsetospeed( &new, speed );
cfsetispeed( &new, B0 ); /* Input equals output speed */
/* Configure the port */ /* Configure the port */
tcflush( fd, TCIOFLUSH ); tcflush( fd, TCIOFLUSH );
if( tcsetattr( fd, TCSANOW, &new ) < 0 ) { if( tcsetattr( fd, TCSANOW, &new ) < 0 ) {
+1 -2
View File
@@ -40,7 +40,6 @@
#include "port.h" #include "port.h"
#include "shared/str.h" #include "shared/str.h"
#include <sys/perm.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -83,7 +82,7 @@ hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver
for (i = 0; i < argc; ++i) { for (i = 0; i < argc; ++i) {
if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0) { if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0) {
extIF = 1; extIF = 1;
if ((ioperm (port + 2, 1, 255)) == -1) { if (port_access (port + 2)) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno)); fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
return -1; return -1;
} }
+1 -2
View File
@@ -33,7 +33,6 @@
#include "port.h" #include "port.h"
#include "lcd_sem.h" #include "lcd_sem.h"
#include <sys/perm.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -66,7 +65,7 @@ hd_init_ext8bit (HD44780_functions * hd44780_functions, lcd_logical_driver * dri
hd44780_functions->senddata = lcdtime_HD44780_senddata; hd44780_functions->senddata = lcdtime_HD44780_senddata;
if ((ioperm (port + 2, 1, 255)) == -1) { if (port_access (port + 2)) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno)); fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
return -1; return -1;
} }
+8
View File
@@ -27,6 +27,10 @@
* COPYING file distributed with this package. * COPYING file distributed with this package.
*/ */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "hd44780-serialLpt.h" #include "hd44780-serialLpt.h"
#include "port.h" #include "port.h"
@@ -53,6 +57,10 @@ hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * d
int displayID = EN1 | EN2; int displayID = EN1 | EN2;
lp = port; lp = port;
if (port_access (lp) || port_access (lp +1)) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
return( -1 );
};
hd44780_functions->senddata = lcdserLpt_HD44780_senddata; hd44780_functions->senddata = lcdserLpt_HD44780_senddata;
+1 -2
View File
@@ -36,7 +36,6 @@
#include "port.h" #include "port.h"
#include "shared/str.h" #include "shared/str.h"
#include <sys/perm.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@@ -73,7 +72,7 @@ hd_init_winamp (HD44780_functions * hd44780_functions, lcd_logical_driver * driv
if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0) if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0)
extIF = 1; extIF = 1;
if ((ioperm (lptPort + 2, 1, 255)) == -1) { if (port_access (lptPort + 2) || port_access (lptPort)) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno)); fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
return -1; return -1;
} }
+2 -2
View File
@@ -36,10 +36,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/perm.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include "port.h"
// Uncomment one of the lines below to select your desired delay generation // Uncomment one of the lines below to select your desired delay generation
// mechanism. If both defines are commented, the original I/O read timing // mechanism. If both defines are commented, the original I/O read timing
@@ -254,7 +254,7 @@ HD44780_init (lcd_logical_driver * driver, char *args)
} }
#endif #endif
// Set up io port correctly, and open it... // Set up io port correctly, and open it...
if ((ioperm (port, 1, 255)) == -1) { if (port_access (port)) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno)); fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
return -1; return -1;
} }
+17 -5
View File
@@ -146,14 +146,26 @@ int LB216_init(lcd_logical_driver *driver, char *args)
} }
//else fprintf(stderr, "LB216_init: opened device %s\n", device); //else fprintf(stderr, "LB216_init: opened device %s\n", device);
tcgetattr(fd, &portset); tcgetattr(fd, &portset);
// This is necessary in Linux, but does not exist in irix or solaris.
#ifndef IRIX // We use RAW mode
#ifndef SOLARIS #ifdef HAVE_CFMAKERAW
// The easy way
cfmakeraw( &portset ); 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 #endif
#endif
// Set port speed
cfsetospeed (&portset, speed); cfsetospeed (&portset, speed);
cfsetispeed(&portset, speed); cfsetispeed (&portset, B0);
// Do it...
tcsetattr(fd, TCSANOW, &portset); tcsetattr(fd, TCSANOW, &portset);
+37 -3
View File
@@ -1,3 +1,5 @@
#ifndef PORT_H
#define PORT_H
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* port.h (by damianf@wpi.edu) * port.h (by damianf@wpi.edu)
* Low level I/O functions taken from led-stat.txt * Low level I/O functions taken from led-stat.txt
@@ -9,9 +11,8 @@
*/ */
/* #define DOS */ /* #define DOS */
#ifdef HAVE_CONFIG_H
#ifndef PORT_H # include "config.h"
#define PORT_H
#endif #endif
#ifndef DOS #ifndef DOS
@@ -30,6 +31,38 @@ port_out (unsigned short int port, unsigned char val)
__asm__ volatile ("outb %0,%1\n"::"a" (val), "d" (port) __asm__ volatile ("outb %0,%1\n"::"a" (val), "d" (port)
); );
} }
/***
*** Get access to a specific port
***/
#ifdef HAVE_IOPERM
/* Assume this is a LINUX system with ioperm */
#include <sys/io.h>
static inline int
port_access (unsigned short int port)
{
return ioperm( port, 1, 255);
}
#else
/* Assume this is a BSD system */
#include <stdio.h>
FILE * port_access_handle = NULL ;
static inline int
port_access (unsigned short int port)
{
if( port_access_handle
|| (port_access_handle = fopen("/dev/io", "rw")) != NULL ) {
return( 0 ); /* Success */
} else {
return( -1 ); /* Failure */
};
}
#endif
#else #else
#include <pc.h> #include <pc.h>
@@ -49,3 +82,4 @@ port_out (unsigned int port, unsigned char val)
#endif #endif
/**** END OF FILE ****/ /**** END OF FILE ****/
#endif
+22 -2
View File
@@ -11,6 +11,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "lcd.h" #include "lcd.h"
#include "wirz-sli.h" #include "wirz-sli.h"
#include "drv_base.h" #include "drv_base.h"
@@ -108,11 +113,26 @@ sli_init (lcd_logical_driver * driver, char *args)
} }
//else fprintf(stderr, "sli_init: opened device %s\n", device); //else fprintf(stderr, "sli_init: opened device %s\n", device);
tcgetattr (fd, &portset); tcgetattr (fd, &portset);
// This is necessary in Linux, but does not exist in irix.
#ifndef IRIX // We use RAW mode
#ifdef HAVE_CFMAKERAW
// The easy way
cfmakeraw( &portset ); 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 #endif
// Set port speed
cfsetospeed (&portset, speed); cfsetospeed (&portset, speed);
cfsetispeed (&portset, B0);
// Do it...
tcsetattr (fd, TCSANOW, &portset); tcsetattr (fd, TCSANOW, &portset);
/* Initialize SLI using autobaud detection, and then turn off cursor /* Initialize SLI using autobaud detection, and then turn off cursor
+15 -31
View File
@@ -36,18 +36,6 @@ char *version = VERSION;
char *protocol_version = PROTOCOL_VERSION; char *protocol_version = PROTOCOL_VERSION;
char *build_date = __DATE__; char *build_date = __DATE__;
/* no longer needed
static screen_size sizes[] =
{
{"16x2", 16, 2},
{"16x4", 16, 4},
{"20x2", 20, 2},
{"20x4", 20, 4},
{"40x2", 40, 2},
{"40x4", 40, 4},
{NULL , 0, 0},
};
*/
// This is currently only a list of available arguments, but doesn't // This is currently only a list of available arguments, but doesn't
// really *do* anything. It just helps to figure out which parameters // really *do* anything. It just helps to figure out which parameters
@@ -59,6 +47,7 @@ static parameter args[] = {
{"-f", "--foreground"}, {"-f", "--foreground"},
{"-b", "--backlight"}, {"-b", "--backlight"},
{"-i", "--serverinfo"}, {"-i", "--serverinfo"},
{"-w", "--waittime"},
{NULL, NULL}, {NULL, NULL},
}; };
@@ -75,7 +64,6 @@ main (int argc, char **argv)
int disable_server_screen = 1; int disable_server_screen = 1;
screen *s = NULL; screen *s = NULL;
char *str, *ing; // strings for commandline handling char *str, *ing; // strings for commandline handling
// screen_size *size = &sizes[0]; // No longer needed
// Ctrl-C will cause a clean exit... // Ctrl-C will cause a clean exit...
signal (SIGINT, exit_program); signal (SIGINT, exit_program);
@@ -175,24 +163,6 @@ main (int argc, char **argv)
lcd.hgt = hgt; lcd.hgt = hgt;
} }
/* no longer needed
int j=0, valid=0;
i++;
for(j=0; sizes[j].size; j++)
{
if(0 == strcmp(sizes[j].size, argv[i]))
{
valid = 1;
size = &sizes[j];
lcd.wid = size->wid;
lcd.hgt = size->hgt;
}
}
if(!valid)
{
fprintf(stderr, "LCDd: Invalid lcd size \"%s\". Using 20x4.\n", argv[i]);
}
*/
} }
} else if (0 == strcmp (argv[i], "-i") || 0 == strcmp (argv[i], "--serverinfo")) { } else if (0 == strcmp (argv[i], "-i") || 0 == strcmp (argv[i], "--serverinfo")) {
if (i + 1 > argc) if (i + 1 > argc)
@@ -204,6 +174,20 @@ main (int argc, char **argv)
if (0 == strcmp (argv[i], "on")) if (0 == strcmp (argv[i], "on"))
disable_server_screen = 0; disable_server_screen = 0;
} }
} else if (0 == strcmp (argv[i], "-w") || 0 == strcmp (argv[i], "--waittime")) {
if (i + 1 > argc)
HelpScreen ();
else {
int tmp ;
i++;
tmp = atoi( argv[i] );
if ( tmp < 16 || tmp > 10000 ) {
printf ("Wait time should be between 16 and 10000 (1/8ths of second), not %s\n", argv[i]);
HelpScreen ();
} else {
default_duration = tmp ;
};
}
} else { } else {
// otherwise... Get help! // otherwise... Get help!
printf ("Invalid parameter: %s\n", argv[i]); printf ("Invalid parameter: %s\n", argv[i]);
+5 -2
View File
@@ -12,6 +12,9 @@
#include "screenlist.h" #include "screenlist.h"
#include "screen.h" #include "screen.h"
int default_priority = 128 ;
int default_duration = 64 ; // About 8 seconds
screen * screen *
screen_create () screen_create ()
{ {
@@ -25,8 +28,8 @@ screen_create ()
s->id = NULL; s->id = NULL;
s->name = NULL; s->name = NULL;
s->priority = 128; // Default priority s->priority = default_priority ;
s->duration = 32; // Default duration (~ 8 seconds) s->duration = default_duration ;
s->heartbeat = 1; s->heartbeat = 1;
s->wid = lcd.wid; s->wid = lcd.wid;
s->hgt = lcd.hgt; s->hgt = lcd.hgt;
+3
View File
@@ -16,6 +16,9 @@ typedef struct screen {
client *parent; client *parent;
} screen; } screen;
extern int default_duration ;
extern int default_priority ;
screen *screen_create (); screen *screen_create ();
int screen_destroy (screen * s); int screen_destroy (screen * s);