Proximity-card reader: no data when app window out of focus

Hello. I can't get it work :frowning:
My application receives data from em-marin reader only being active. Switching to another app makes the port become silent.
MarinReader works in another thread.
Port reading is going while the app is inactive (tested).
Env: Ubuntu 9.04, Gnome, Qt (i've tryed pure open and fopen - the same result)
Please, help anybody!

bool MarinReader::read_port(QFile* file)
{
	char first_char = '\0';
	file->getChar(&first_char);
	if (first_char == ':')
	{
		QByteArray bres = file->readAll();
		QString s(bres);
		s.resize(10);
		emit CardProcessed(s);
	}
	tcflush(file->handle(), TCIOFLUSH);
	return true;
}

void MarinReader::run()
{
	emit Message("opening port " + port_name);
	struct termios Posix_CommConfig;
	QFile* Posix_File = new QFile(port_name);
	if (!Posix_File->open(QIODevice::ReadOnly))
	{
		emit Error("open file error"); exit(-1); return;
	}
/* doesn't solve the problem
	struct flock fl;
	fl.l_type   = F_RDLCK;
	fl.l_whence = SEEK_SET;
	fl.l_start  = 0; 
	fl.l_len    = 0; 
	fl.l_pid    = getpid(); 
	fcntl(Posix_File->handle(), F_SETLK, &fl); 
*/
	tcgetattr(Posix_File->handle(), &Posix_CommConfig);
	Posix_CommConfig.c_cflag |= CREAD|CLOCAL;
	Posix_CommConfig.c_lflag &= (~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
	Posix_CommConfig.c_iflag &= (~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
	Posix_CommConfig.c_oflag &= (~OPOST);
	Posix_CommConfig.c_cc[VMIN] = 0;
	Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
	Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
	Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
	Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
	Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
	//speed
	cfsetispeed(&Posix_CommConfig, B9600);
	cfsetospeed(&Posix_CommConfig, B9600);
	//data bits
	Posix_CommConfig.c_cflag&=(~CSIZE);
	Posix_CommConfig.c_cflag|=CS8;
	//parity
	Posix_CommConfig.c_cflag&=(~PARENB);
	//stop bits
	Posix_CommConfig.c_cflag&=(~CSTOPB);
	//flow control
	Posix_CommConfig.c_cflag&=(~CRTSCTS);
	Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
	//timeout
	Posix_CommConfig.c_cc[VTIME] = 1;
	if (tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig) == -1)
	{
		emit Error("tcsetattr error"); exit(-1); return;
	}
	is_open = true;
	emit Message("port opened successfully");
	do
	{
		if (!read_port(Posix_File)) break;
	}
	while (!needClose);
	needClose = false;
	//fl.l_type = F_UNLCK;
	//fcntl(Posix_File->handle(), F_SETLK, &fl); 
	Posix_File->close();
	delete Posix_File;
	emit Message("port closed");
	is_open = false;
}

Can you not make the reader a separate process - a daemon - that raises a signal or otherwise sends something to your windowing code? An unblocked signal is never ignored, for example.

Regardless of focus.

With the following modification my windowing code gets all the counted signals:

bool MarinReader::read_port(QFile* file)
{
	static int i = 0;
	emit Message("debug message #" + QString::number(i++));
	char first_char = '\0';
	file->getChar(&first_char);
	if (first_char == ':')
	{
		QByteArray bres = file->readAll();
		QString s(bres);
		s.resize(10);
		emit CardProcessed(s);
	}
	tcflush(file->handle(), TCIOFLUSH);
	return true;
}

Signals CardProcessed and Message are identical, and the destination slots are in the same thread of main window (I can process these signals with the same slot).