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:
+1
-1
@@ -86,7 +86,7 @@ AC_TYPE_UID_T
|
||||
dnl Checks for library functions.
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
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
|
||||
|
||||
|
||||
+18
-6
@@ -139,14 +139,26 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
||||
}
|
||||
//else fprintf(stderr, "CFontz_init: opened device %s\n", device);
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw (&portset);
|
||||
#endif
|
||||
|
||||
// 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 port speed
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
|
||||
// Do it...
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
// Set display-specific stuff..
|
||||
|
||||
+19
-6
@@ -84,6 +84,7 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
||||
int contrast = 140;
|
||||
char device[256] = "/dev/lcd";
|
||||
int speed = B19200;
|
||||
MtxOrb_type = MTXORB_LKD ; // Assume it's an LCD w/keypad
|
||||
|
||||
MtxOrb = driver;
|
||||
|
||||
@@ -170,14 +171,26 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
||||
}
|
||||
//else fprintf(stderr, "MtxOrb_init: opened device %s\n", device);
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw (&portset);
|
||||
#endif
|
||||
|
||||
// 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 port speed
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
|
||||
// Do it...
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
// Set display-specific stuff..
|
||||
|
||||
+19
-6
@@ -408,15 +408,28 @@ int bayrad_init(struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
bzero(&portset, sizeof(portset));
|
||||
portset.c_iflag = IGNPAR;
|
||||
portset.c_oflag = 0;
|
||||
portset.c_cflag = B9600|CS8|CREAD|CLOCAL;
|
||||
portset.c_lflag = 0;
|
||||
// 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
|
||||
|
||||
portset.c_cc[VTIME] = 0; // Don't use the timer, no workee
|
||||
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);
|
||||
tcflush(fd, TCIOFLUSH);
|
||||
|
||||
|
||||
+19
-10
@@ -45,13 +45,13 @@ GLKDisplay *
|
||||
struct termios new ;
|
||||
GLKDisplay * retval ;
|
||||
|
||||
if( name == NULL || (speed & CBAUD) == 0 ) {
|
||||
if( name == NULL || speed == 0 ) {
|
||||
/* Invalid arguments */
|
||||
errno = EINVAL ;
|
||||
return( NULL );
|
||||
};
|
||||
|
||||
fd = open( name, O_RDWR | O_NOCTTY | O_SYNC );
|
||||
fd = open( name, O_RDWR | O_NOCTTY );
|
||||
if( fd < 0 ) {
|
||||
return( NULL );
|
||||
};
|
||||
@@ -76,20 +76,29 @@ GLKDisplay *
|
||||
retval->flow = GLKFLOW_OK ;
|
||||
|
||||
/* Make new settings */
|
||||
/* We use RAW mode, and select two stop bits
|
||||
* to slow things down 10%. Therefore, we IGNORE
|
||||
* framing errors incase the module transmits back
|
||||
* to back with only one stop bit.
|
||||
*/
|
||||
new.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | IGNPAR | ISTRIP
|
||||
|
||||
/* We use RAW mode */
|
||||
#ifdef HAVE_CFMAKERAW
|
||||
/* The easy way */
|
||||
cfmakeraw( &new );
|
||||
#else
|
||||
/* The hard way */
|
||||
new.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
|
||||
| INLCR | IGNCR | ICRNL | IXON );
|
||||
new.c_oflag &= ~OPOST;
|
||||
new.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
|
||||
new.c_cflag &= ~( CBAUD | CSIZE | PARENB | CRTSCTS );
|
||||
new.c_cflag |= speed | CS8 | CREAD | CLOCAL | CSTOPB ;
|
||||
new.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
|
||||
new.c_cflag |= CS8 | CREAD | CLOCAL ;
|
||||
#endif
|
||||
|
||||
/* Set default MIN and TIMEOUT values */
|
||||
new.c_cc[VMIN] = 0 ;
|
||||
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 */
|
||||
tcflush( fd, TCIOFLUSH );
|
||||
if( tcsetattr( fd, TCSANOW, &new ) < 0 ) {
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "port.h"
|
||||
|
||||
#include "shared/str.h"
|
||||
#include <sys/perm.h>
|
||||
#include <stdio.h>
|
||||
#include <string.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) {
|
||||
if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0) {
|
||||
extIF = 1;
|
||||
if ((ioperm (port + 2, 1, 255)) == -1) {
|
||||
if (port_access (port + 2)) {
|
||||
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "port.h"
|
||||
|
||||
#include "lcd_sem.h"
|
||||
#include <sys/perm.h>
|
||||
#include <stdio.h>
|
||||
#include <string.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;
|
||||
|
||||
if ((ioperm (port + 2, 1, 255)) == -1) {
|
||||
if (port_access (port + 2)) {
|
||||
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
* COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "hd44780-serialLpt.h"
|
||||
#include "port.h"
|
||||
|
||||
@@ -53,6 +57,10 @@ hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * d
|
||||
int displayID = EN1 | EN2;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "port.h"
|
||||
|
||||
#include "shared/str.h"
|
||||
#include <sys/perm.h>
|
||||
#include <stdio.h>
|
||||
#include <string.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)
|
||||
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));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/perm.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "port.h"
|
||||
|
||||
// Uncomment one of the lines below to select your desired delay generation
|
||||
// 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
|
||||
// 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));
|
||||
return -1;
|
||||
}
|
||||
|
||||
+19
-7
@@ -146,14 +146,26 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
||||
}
|
||||
//else fprintf(stderr, "LB216_init: opened device %s\n", device);
|
||||
tcgetattr(fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix or solaris.
|
||||
#ifndef IRIX
|
||||
#ifndef SOLARIS
|
||||
cfmakeraw(&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
|
||||
#endif
|
||||
cfsetospeed(&portset, speed);
|
||||
cfsetispeed(&portset, speed);
|
||||
|
||||
// Set port speed
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
|
||||
// Do it...
|
||||
tcsetattr(fd, TCSANOW, &portset);
|
||||
|
||||
|
||||
|
||||
+37
-3
@@ -1,3 +1,5 @@
|
||||
#ifndef PORT_H
|
||||
#define PORT_H
|
||||
/*-----------------------------------------------------------------------------
|
||||
* port.h (by damianf@wpi.edu)
|
||||
* Low level I/O functions taken from led-stat.txt
|
||||
@@ -9,9 +11,8 @@
|
||||
*/
|
||||
|
||||
/* #define DOS */
|
||||
|
||||
#ifndef PORT_H
|
||||
#define PORT_H
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#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)
|
||||
);
|
||||
}
|
||||
|
||||
/***
|
||||
*** 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
|
||||
#include <pc.h>
|
||||
|
||||
@@ -49,3 +82,4 @@ port_out (unsigned int port, unsigned char val)
|
||||
#endif
|
||||
|
||||
/**** END OF FILE ****/
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lcd.h"
|
||||
#include "wirz-sli.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);
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
cfmakeraw (&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
|
||||
|
||||
// Set port speed
|
||||
cfsetospeed (&portset, speed);
|
||||
cfsetispeed (&portset, B0);
|
||||
|
||||
// Do it...
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
/* Initialize SLI using autobaud detection, and then turn off cursor
|
||||
|
||||
+15
-31
@@ -36,18 +36,6 @@ char *version = VERSION;
|
||||
char *protocol_version = PROTOCOL_VERSION;
|
||||
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
|
||||
// really *do* anything. It just helps to figure out which parameters
|
||||
@@ -59,6 +47,7 @@ static parameter args[] = {
|
||||
{"-f", "--foreground"},
|
||||
{"-b", "--backlight"},
|
||||
{"-i", "--serverinfo"},
|
||||
{"-w", "--waittime"},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -75,7 +64,6 @@ main (int argc, char **argv)
|
||||
int disable_server_screen = 1;
|
||||
screen *s = NULL;
|
||||
char *str, *ing; // strings for commandline handling
|
||||
// screen_size *size = &sizes[0]; // No longer needed
|
||||
|
||||
// Ctrl-C will cause a clean exit...
|
||||
signal (SIGINT, exit_program);
|
||||
@@ -175,24 +163,6 @@ main (int argc, char **argv)
|
||||
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")) {
|
||||
if (i + 1 > argc)
|
||||
@@ -204,6 +174,20 @@ main (int argc, char **argv)
|
||||
if (0 == strcmp (argv[i], "on"))
|
||||
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 {
|
||||
// otherwise... Get help!
|
||||
printf ("Invalid parameter: %s\n", argv[i]);
|
||||
|
||||
+5
-2
@@ -12,6 +12,9 @@
|
||||
#include "screenlist.h"
|
||||
#include "screen.h"
|
||||
|
||||
int default_priority = 128 ;
|
||||
int default_duration = 64 ; // About 8 seconds
|
||||
|
||||
screen *
|
||||
screen_create ()
|
||||
{
|
||||
@@ -25,8 +28,8 @@ screen_create ()
|
||||
|
||||
s->id = NULL;
|
||||
s->name = NULL;
|
||||
s->priority = 128; // Default priority
|
||||
s->duration = 32; // Default duration (~ 8 seconds)
|
||||
s->priority = default_priority ;
|
||||
s->duration = default_duration ;
|
||||
s->heartbeat = 1;
|
||||
s->wid = lcd.wid;
|
||||
s->hgt = lcd.hgt;
|
||||
|
||||
@@ -16,6 +16,9 @@ typedef struct screen {
|
||||
client *parent;
|
||||
} screen;
|
||||
|
||||
extern int default_duration ;
|
||||
extern int default_priority ;
|
||||
|
||||
screen *screen_create ();
|
||||
int screen_destroy (screen * s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user