linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Connect with various serial devices
@ 2003-12-10 20:33 Albert Cervera Areny
  2003-12-11  1:38 ` whitnl73
  0 siblings, 1 reply; 11+ messages in thread
From: Albert Cervera Areny @ 2003-12-10 20:33 UTC (permalink / raw)
  To: linux-serial

Hi,
	I need to use various external devices which include (just in case
somebody has been able to do it already) an omron Card reader (V2X) and a
note dispenser.
The thing is that I've been able to use the note dispenser with the
following code:

fd = open( tty.ascii(), O_RDWR|O_NOCTTY);
bzero( &t, sizeof(t) );
t.c_cflag = B4800 | CS7 | CLOCAL | CREAD | PARENB;
t.c_iflag = IGNPAR | ICRNL;
t.c_oflag = 0;
t.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&t);

But when I try to connect with the Omron Card Reader (and other devices) I
cant contact them. I've configured CS, parity and speed as they should,
but there seems to be some other reason for these no to work.
The thing is that, those periferals work ok with a program in Windows2000
with Visual C++ where the code to initialize looks something like this for
one periferal:

hCom = CreateFile((char *)sCom,GENERIC_READ | GENERIC_WRITE,  0,  NULL,
OPEN_EXISTING, 0, (long) 0);

if(hCom == INVALID_HANDLE_VALUE) {
	dwError = GetLastError();
	printf(bufrec,"Error:%d\n", dwError);
	Close();
}

fSuccess = GetCommState(hCom, &dcbPort);
if(!fSuccess) {
	Close();
}
dcbPort.BaudRate = 9600;
dcbPort.ByteSize = 8;
dcbPort.Parity = NOPARITY;
dcbPort.StopBits = TWOSTOPBITS;
fSuccess = SetCommState(hCom, &dcbPort);
if(!fSuccess) {
	Close();
}

The same periferal I try to inicialize it with Linux with:

bzero( &t, sizeof(t) );
t.c_cflag = B9600 | CS8 | CLOCAL | CREAD | CSTOPB;
t.c_iflag = IGNPAR | IGNBRK;
t.c_oflag = 0;
t.c_lflag =  ICANON;
tcflush( fd, TCIFLUSH );
tcsetattr( fd, TCSANOW, &t );

Can somebody see a reason why this shouldn't work for Linux or why it is
different from the windows code? The device seems to receive something as
a led shows it but doesn't do what it should, so it seems as the data
received must be garbage. If the device receives a command it doesn't
understand should send a NACK.

I send information using (no error returned):
write( fd, s.ascii(), s.length() )

And receive with (it waits forever):
read( fd, c, 1 )

Sorry for this long e-mail, but I'm really desperate. Hope somebody can help!

Thanks in advance!

Albert

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-12-16  7:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-10 20:33 Connect with various serial devices Albert Cervera Areny
2003-12-11  1:38 ` whitnl73
2003-12-11  8:14   ` Albert Cervera Areny
2003-12-11  9:33     ` Michael Westermann
2003-12-11 12:12       ` Albert Cervera Areny
2003-12-11 12:29         ` Michael Westermann
2003-12-11 13:08           ` Albert Cervera Areny
2003-12-11 13:27             ` Michael Westermann
2003-12-15 19:00               ` Albert Cervera Areny
2003-12-16  7:23                 ` Michael Westermann
2003-12-11 14:47             ` Gerald Emig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).