11 #include <linux/serial.h>
12 #include <sys/ioctl.h>
13 #include <sys/types.h>
26 #if defined(__i386__) || defined(__ia64__) || defined(__amd64__)
33 :
BitMeter( parent, getTitle(device),
"LSR bits(0-7), MSR bits(0-7)", 16){
54 std::cerr <<
"SerialMeter::SerialMeter() : "
55 <<
"xosview must be suid root to use the serial meter." << std::endl;
62 return ioperm(port, 1, 1) != -1;
80 static const char *names[] = {
"ttyS0",
"ttyS1",
"ttyS2",
"ttyS3",
81 "ttyS4",
"ttyS5",
"ttyS6",
"ttyS7",
87 static const char *names[] = {
"serial0",
"serial1",
91 "serial8",
"serial9" };
97 static const char *deviceFile[] = {
"/dev/ttyS0",
110 if (!strncasecmp(res,
"True", 5)){
112 struct serial_struct serinfo;
115 if ((fd = open(deviceFile[dev], O_RDONLY|O_NONBLOCK)) < 0) {
116 std::cerr <<
"SerialMeter::SerialMeter() : "
117 <<
"failed to open " << deviceFile[dev] <<
"." <<std::endl;
120 if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0) {
121 std::cerr <<
"Failed to detect port base for " << deviceFile[dev]
132 std::istringstream istrm(s);
133 unsigned short int tmp = 0;
134 istrm >> std::hex >> tmp;
void setBits(int startbit, unsigned char values)
void checkResources(void)
unsigned short int getPortBase(Device dev) const
SerialMeter(XOSView *parent, Device device)
static const char * getResourceName(Device dev)
void checkResources(void)
const char * getTitle(Device dev) const
bool getport(unsigned short int port)
unsigned long allocColor(const char *name)
const char * getResource(const char *name)