• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

633 USB Interrupt catching under Linux

znipah

New member
I am trying to catch interrupts from a 633 USB device under Linux (Debian, 2.6).
This is my C code to do it:

#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <pthread.h>

#define BAUDRATE B19200

main()
{
int fd;
int sig;
struct sigevent ev;
sigset_t set;
char buf[255];
struct termios oldtio, newtio;
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NONBLOCK);
if(fd < 0)
printf("Failed to open the device\n");
ev.sigev_notify = SIGEV_SIGNAL;
ev.sigev_signo = SIGIO;
sigemptyset(&set);
sigaddset(&set, SIGIO);
pthread_sigmask(SIG_BLOCK, &set, (sigset_t*)NULL);

if(fcntl(fd, F_SETOWN, getpid()) == -1)
printf("F_SETOWN error\n");
if(fcntl(fd, F_SETFL, FASYNC) == -1)
printf("F_SETOWN error\n");

tcgetattr(fd, &oldtio);
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
while(sigwait(&set, &sig) != -1) {
printf("INTERRUPT!\r\n");
}
tcsetattr(fd, TCSANOW, &oldtio);
}
Everything works when compiled like that, I get interrupts for all keypresses (both down up). The problem is that it doesn't work when the code is placed in any other function than main. For exampel, if I put exacly the same code in a function called test and then let main call test, I only get an interrupt when right arrow key is released.

Also, notice the struct sigevent ev that never is used, if I remove that one I won't receive any interrupts even in main. However, if I increase the size of char buf[255] it works again. This got me thinking the problem is caused by something going on with the stack.

Am I missing something?
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

marseillais

New member
633 USB under Linux don't work

Hello all,

I am new in the LCD experience so I know nothing about it !!!

I would be interested in a USB 633 but I just want to know if the single USB cable is enough or if we need to connect an cable for power to make it work under Linux ( Debian 2.6.5 ) that support the driver for USB and i have configure LCDproc 1.4.4 with:
-----------

[CFontz]
# CrystalFontz driver

# Select the output device to use [/dev/lcd]
#Device=/dev/ttyS0
Device=/dev/ttyUSB0 ##

# Select the LCD type (size) [20x4]
#Size=20x4
Size=16x2 ##

# Set the initial contrast [140]
Contrast=140

# The backlight brightness settings are retrieved
# from the serversection now. And can therefore be
# modified from the server menu now.

# Set the communication speed [9600]
# possible values: 1200, 2400, 4800, 9600, 19200
#Speed=9600
Speed=19200 ##

# Set the firmware version (New means >= 2.0) [no]
# if set, set Speed to 19200
#NewFirmware=no
NewFirmware=yes ##

# Reinitialize the LCD's BIOS [no]
# normally you shouldn't need this
Reboot=no

# This is using the USB->serial driver [no]
#USB=no
USB=yes
------------

but the CF-633 dosen't work!!!!!!!!!!

if someone can help a poor guy (such I am) it would be very very nice

Thanks a lot
 
USB LCD Displays - Graphic and Character LCDs with a Keypad
Top