linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to use an USB<->serial adapter?
@ 2003-08-21 12:44 Boszormenyi Zoltan
  2003-08-21 17:08 ` Greg KH
  2003-08-21 23:18 ` Daniel Egger
  0 siblings, 2 replies; 8+ messages in thread
From: Boszormenyi Zoltan @ 2003-08-21 12:44 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2162 bytes --]

Hi,

I am experimenting with a Prolific USB<->RS232 adaptor. We have
in-house developments that need serial communication and there
are more and more mainboards that provide only one RS232 connector.
(We would need more in one machine...)
So we decided to try an usb-serial converter. The one we bought
was happily recognized by a RedHat 9 system but I couldn't get
two-way communication over this converter.
The null-modem cable is working both ways, in fact I tested it
with my machine's two real 16550s.
lsmod shows usbserial and pl2303, dmesg shows this:

usb.c: registered new driver serial
usbserial.c: USB Serial support registered for Generic
usbserial.c: USB Serial Driver core v1.4
usbserial.c: USB Serial support registered for PL-2303
usbserial.c: PL-2303 converter detected
usbserial.c: PL-2303 converter now attached to ttyUSB0 \
(or usb/tts/0 for devfs)
pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.9

I use the attached sources (serial.h, [posix|win32]-serial.c)
in my MinGW/Linux dual platform programs for low-level serial
communication. Here are two testprograms that I used.

serialtest2 just listens and waits for incoming bytes.
If it receives one, the answer is the byte it got + 1.
serialtest1 iterates 10 times writing a byte and expecting
the answer.

I tried using /dev/ttyUSB0 and /dev/usb/ttyUSB0 (chmod was needed
to open them by an ordinary user, open(2) and tcsetattr(3)
succeeded. What I found is that I can write to /dev/ttyUSB0
with serialtest1 and serialtest2 successfully reads it from
/dev/ttyS0. But the answer from serialtest2 cannot be read
by serialtest1. If these programs both use a real serial port
(ttyS0 and ttyS1) the communication is successful both ways.

setserial produces an error:

# setserial /dev/ttyUSB0
Cannot get serial info: Invalid argument

And to be sure:

# setserial /dev/ttyUSB1
/dev/ttyUSB1: No such device

as expected.

I have the kernel-smp-2.4.20-19.9 (not the very latest) errata kernel
and all user space errata packages installed/upgraded.

-- 
Best regards,
Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.


[-- Attachment #2: serial.h --]
[-- Type: text/plain, Size: 712 bytes --]

/*
 * Közös fejléc a Win32/POSIX soros programozáshoz
 */

#include <sys/types.h>

#ifndef NEED_WINDOWS_H
#include <termios.h>
#else
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif

extern char *serial_names[];

typedef struct {
#ifdef NEED_WINDOWS_H
	HANDLE		fd;
	DCB		olddcb, newdcb;
	COMMTIMEOUTS	oldto, newto;
	size_t		err;
#else
	int		fd;
	struct termios	oldtio, newtio;
	ssize_t		err;
#endif
} serial_t;

serial_t *serial_open(const char *devname);
void	serial_setup(serial_t *serport);
void	serial_close(serial_t *serport);
void	serial_write(serial_t *serport, const char *buffer, size_t n);
void	serial_read(serial_t *serport, char *buffer, size_t n, int wait);
void	serial_delay(int ms);


[-- Attachment #3: posix-serial.c --]
[-- Type: text/plain, Size: 2313 bytes --]

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <malloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "serial.h"

char *serial_names[10] = {
	"",
	"/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3",
	"/dev/usb/ttyUSB0", "/dev/usb/ttyUSB1", "/dev/usb/ttyUSB2", "/dev/usb/ttyUSB3",
	NULL };

serial_t *serial_open(const char *devname) {
	serial_t	*serport;

	serport = malloc(sizeof(serial_t));

	serport->fd = open(devname, O_RDWR|O_NOCTTY|O_NONBLOCK /*|O_SYNC*/);
	if (serport->fd < 0) {
		free(serport);
		return NULL;
	}

	return serport;
}

void	serial_setup(serial_t *serport) {
	struct termios	*tio1, *tio2;
	int		ret = 0;

	tio1 = &(serport->oldtio);
	tio2 = &(serport->newtio);

	if (tcgetattr(serport->fd, tio1))
		ret = -1;
	memcpy(tio2, tio1, sizeof(struct termios));
	cfmakeraw(tio2);
	cfsetospeed(tio2, B115200);
	cfsetispeed(tio2, B115200);
#if 0
	tio2->c_cflag |= CRTSCTS;
#endif
	tio2->c_cflag |= CREAD|CLOCAL;
	tcflush(serport->fd, TCIOFLUSH);
	if (tcsetattr(serport->fd, TCSANOW, tio2))
		ret = -1;
#if 0
	tcflow(serport->fd, TCOON); tcflow(serport->fd, TCION);
#endif
	serport->err = ret;
}

void	serial_close(serial_t *serport) {
	tcflush(serport->fd, TCIOFLUSH);
	tcsetattr(serport->fd, TCSANOW, &(serport->oldtio));
	close(serport->fd);
	free(serport);
}

void	serial_write(serial_t *serport, const char *buffer, size_t n) {
	int	i;

	serport->err = write(serport->fd, buffer, n);
	tcdrain(serport->fd);
}

void serial_read(serial_t *serport, char *buffer, size_t n, int wait) {
	int pos = 0;
	int err = 0;
	struct timeval tv;
	fd_set set;

	if (wait) {
		FD_ZERO(&set);
		FD_SET(serport->fd, &set);
		tv.tv_sec = 0;
		tv.tv_usec = 250000;
		serport->err = select(serport->fd+1, &set, NULL, NULL, &tv);
		if (serport->err <= 0)
			return;
	}

	while(n--) {
again:
		if (wait) {
			FD_ZERO(&set);
			FD_SET(serport->fd, &set);
			tv.tv_sec = 0;
			tv.tv_usec = 100000;
			serport->err = select(serport->fd+1, &set, NULL, NULL, &tv);
			if (serport->err <= 0)
				return;
		}
		serport->err = read(serport->fd, &buffer[pos++], 1);
		if (serport->err == 0)
			goto again;
		if (serport->err == -1)
			break;
	}
	if (serport->err != -1)
		serport->err = pos;
}

void	serial_delay(int ms) {
	usleep(ms*1000);
}


[-- Attachment #4: win32-serial.c --]
[-- Type: text/plain, Size: 4547 bytes --]

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>

#include <malloc.h>
#include <gdk/gdkwin32.h>
#include <gtk/gtk.h>

#include "serial.h"

char *serial_names[10] = {
	"",
	"COM1:", "COM2:", "COM3:", "COM4:",
	"COM5:", "COM6:", "COM7:", "COM8:",
	NULL };

extern GtkWidget *foablak;

serial_t *serial_open(const char *devname) {
	serial_t *serport;
	HANDLE	fd;
	DWORD	dwError;

	serport = malloc(sizeof(serial_t));

	serport->fd = CreateFile(devname, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
		FILE_FLAG_WRITE_THROUGH, NULL);
	dwError = GetLastError();
	if (dwError == ERROR_FILE_NOT_FOUND) {
		free(serport);
		return NULL;
	}
	return serport;
}

void	serial_setup(serial_t *serport) {
	DCB		*dcb1, *dcb2;
	COMMTIMEOUTS	*to1, *to2;
	DWORD		dwError;

	to1 = &(serport->oldto);
	to2 = &(serport->newto);

	/* Initialize the DCBlength member. */
	dcb1 = &(serport->olddcb);
	dcb2 = &(serport->newdcb);

	serport->olddcb.DCBlength = sizeof (DCB); 

	/* Get the default port setting information. */
	GetCommState(serport->fd, dcb1);
	memcpy(dcb2, dcb1, sizeof(DCB));

	/* Change the DCB structure settings. */
	dcb2->BaudRate = 115200;            /* Current baud */
	dcb2->fBinary = TRUE;               /* Binary mode; no EOF check */
	dcb2->fParity = TRUE;               /* Enable parity checking */
	dcb2->fOutxCtsFlow = FALSE;         /* No CTS output flow control */
	dcb2->fOutxDsrFlow = FALSE;         /* No DSR output flow control */
	dcb2->fDtrControl = DTR_CONTROL_DISABLE /* DTR_CONTROL_ENABLE */;
	                                      /* DTR flow control type */
	dcb2->fDsrSensitivity = FALSE;      /* DSR sensitivity */
	dcb2->fTXContinueOnXoff = TRUE;     /* XOFF continues Tx */
	dcb2->fOutX = FALSE;                /* No XON/XOFF out flow control */ 
	dcb2->fInX = FALSE;                 /* No XON/XOFF in flow control */
	dcb2->fErrorChar = FALSE;           /* Disable error replacement */
	dcb2->fNull = FALSE;                /* Disable null stripping */
	dcb2->fRtsControl = RTS_CONTROL_ENABLE;
	                                      /* RTS flow control */
	dcb2->fAbortOnError = FALSE;        /* Do not abort reads/writes error */
	dcb2->ByteSize = 8;                 /* Number of bits/byte, 4-8 */
	dcb2->Parity = NOPARITY;            /* 0-4=no,odd,even,mark,space */ 
	dcb2->StopBits = ONESTOPBIT;        /* 0,1,2 = 1, 1.5, 2 */

	/* Configure the port according to the specifications of the DCB structure. */
	if (!SetCommState (serport->fd, dcb2)) {
		/* Could not configure the serial port. */
		serport->err = -1;
		return;
	}

	/* Retrieve the time-out parameters for all read and write operations
	   on the port. */
	to1 = &(serport->oldto);
	to2 = &(serport->newto);

	GetCommTimeouts (serport->fd, to1);
	memcpy(to2, to1, sizeof(COMMTIMEOUTS));

	/* Change the COMMTIMEOUTS structure settings. */
	to2->ReadIntervalTimeout = 250;
	to2->ReadTotalTimeoutMultiplier = 0;
	to2->ReadTotalTimeoutConstant = 250;
	to2->WriteTotalTimeoutMultiplier = 0;
	to2->WriteTotalTimeoutConstant = 0;

	/* Set the time-out parameters for all read and write operations
	   on the port. */
	if (!SetCommTimeouts (serport->fd, to2))
	{
		/* Could not set the time-out parameters. */
		serport->err = -1;
		return;
	}
}

void serial_close(serial_t *serport) {
	SetCommState (serport->fd, &(serport->olddcb));
	SetCommTimeouts (serport->fd, &(serport->oldto));
	CloseHandle(serport->fd);
	free(serport);
}

void serial_write(serial_t *serport, const char *buffer, size_t n) {
	DWORD	dwNumBytesWritten;
	int	i;

	serport->err = 0;
	for (i = 0; i < n; i++) {
		WriteFile (serport->fd,	/* Port handle */
			&buffer[i],	/* Pointer to the data to write */
			1,		/* Number of bytes to write */
			&dwNumBytesWritten,/* Pointer to the number of bytes written */
			NULL);		/* Must be NULL for Windows CE */
		serport->err += dwNumBytesWritten;
	}
	if (serport->err != n)
		serport->err = -1;
}

void serial_read(serial_t *serport, char *buffer, size_t n, int wait) {
	DWORD dwBytesTransferred;
	int	i;

	serport->err = 0;
	for (i = 0; i < n; i++) {
		ReadFile (serport->fd,	/* Port handle */
          	&buffer[i],		/* Pointer to data to read */
		1,			/* Number of bytes to read */
		&dwBytesTransferred,	/* Pointer to number of bytes read */
		NULL);			/* Must be NULL for Windows CE */
		serport->err += dwBytesTransferred;
		if (!dwBytesTransferred) {
			serport->err = -1;
			break;
		}
	}
	if (serport->err != n)
		serport->err = -1;
}

void	serial_delay(int ms) {
	Sleep(ms);
}


[-- Attachment #5: serialtest1.c --]
[-- Type: text/plain, Size: 677 bytes --]

/*
 *  serialtest1
 */

#include <stdio.h>
#include "serial.h"

serial_t	*sp;
unsigned char	c1, c2;
int		i;

int main(int argc, char **argv) {
	if (argc != 2)	{
		printf("give device name\n");
		return 1;
	}

	sp = serial_open(argv[1]);
	if (!sp) {
		printf("cannot open %s\n", argv[1]);
		return 1;
	}

	serial_setup(sp);
	if (sp->err < 0) {
		printf("cannot setup %s\n", argv[1]);
	}

	for (i = 0; i < 10; i++) {
		c1 = i;

		serial_write(sp, &c1, 1);

		serial_delay(20);

		serial_read(sp, &c2, 1, 1);

		if (sp->err <= 0)
		printf("written: 0x%02x, couldn't read\n", c1);
			else
		printf("written: 0x%02x, read: 0x%02x\n", c1, c2);
	}

	serial_close(sp);

	return 0;
}



[-- Attachment #6: serialtest2.c --]
[-- Type: text/plain, Size: 668 bytes --]

/*
 *  serialtest2
 */

#include <stdio.h>
#include <stdlib.h>
#include "serial.h"

serial_t	*sp;
unsigned char	c1, c2;
int		i;

void myexit(void) {
	serial_close(sp);
}

int main(int argc, char **argv) {
	if (argc != 2) {
		printf("give device name\n");
		return 1;
	}

	sp = serial_open(argv[1]);
	if (!sp) {
		printf("cannot open %s\n", argv[1]);
		return 1;
	}

	serial_setup(sp);
	if (sp->err < 0) {
		printf("cannot setup %s\n", argv[1]);
	}

	atexit(myexit);

	while (1) {
again:
		serial_read(sp, &c1, 1, 1);
		if (sp->err <= 0)
			goto again;

		c2 = c1+1;

		serial_write(sp, &c2, 1);
		printf("read: 0x%02x, written: 0x%02x\n", c1, c2);

	}

	return 0;
}



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

* Re: How to use an USB<->serial adapter?
  2003-08-21 12:44 How to use an USB<->serial adapter? Boszormenyi Zoltan
@ 2003-08-21 17:08 ` Greg KH
  2003-08-22  7:02   ` Boszormenyi Zoltan
  2003-08-22 12:05   ` Boszormenyi Zoltan
  2003-08-21 23:18 ` Daniel Egger
  1 sibling, 2 replies; 8+ messages in thread
From: Greg KH @ 2003-08-21 17:08 UTC (permalink / raw)
  To: Boszormenyi Zoltan; +Cc: linux-kernel

On Thu, Aug 21, 2003 at 02:44:18PM +0200, Boszormenyi Zoltan wrote:
> Hi,
> 
> I am experimenting with a Prolific USB<->RS232 adaptor. We have
> in-house developments that need serial communication and there
> are more and more mainboards that provide only one RS232 connector.
> (We would need more in one machine...)
> So we decided to try an usb-serial converter. The one we bought
> was happily recognized by a RedHat 9 system but I couldn't get
> two-way communication over this converter.

Which kernel version are you using?

I didn't run your test programs, but are you sure you got the hardware
flow control settings correct?  How about testing the device with
minicom, as that is a program that is known to work properly with these
devices (along with lots of other ones, but that's a good place to
start.)

> setserial produces an error:
> 
> # setserial /dev/ttyUSB0
> Cannot get serial info: Invalid argument

Yes, setserial does not work with the majority of the usb-serial
drivers, patches gladly accepted to fix this :)

thanks,

greg k-h

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

* Re: How to use an USB<->serial adapter?
  2003-08-21 12:44 How to use an USB<->serial adapter? Boszormenyi Zoltan
  2003-08-21 17:08 ` Greg KH
@ 2003-08-21 23:18 ` Daniel Egger
  2003-08-25  6:24   ` Boszormenyi Zoltan
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Egger @ 2003-08-21 23:18 UTC (permalink / raw)
  To: Boszormenyi Zoltan; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

Am Don, 2003-08-21 um 14.44 schrieb Boszormenyi Zoltan:

> usb.c: registered new driver serial
> usbserial.c: USB Serial support registered for Generic
> usbserial.c: USB Serial Driver core v1.4
> usbserial.c: USB Serial support registered for PL-2303
> usbserial.c: PL-2303 converter detected
> usbserial.c: PL-2303 converter now attached to ttyUSB0 \
> (or usb/tts/0 for devfs)
> pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.9

Works for me, even on PowerPC. I'm typically using minicom and ckermit
but mgetty and others work fine, too.

> setserial produces an error:

What do you need this relic from former times for?

-- 
Servus,
       Daniel

[-- Attachment #2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: How to use an USB<->serial adapter?
  2003-08-21 17:08 ` Greg KH
@ 2003-08-22  7:02   ` Boszormenyi Zoltan
  2003-08-22 12:05   ` Boszormenyi Zoltan
  1 sibling, 0 replies; 8+ messages in thread
From: Boszormenyi Zoltan @ 2003-08-22  7:02 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Greg KH wrote:
> On Thu, Aug 21, 2003 at 02:44:18PM +0200, Boszormenyi Zoltan wrote:
> 
>>Hi,
>>
>>I am experimenting with a Prolific USB<->RS232 adaptor. We have
>>in-house developments that need serial communication and there
>>are more and more mainboards that provide only one RS232 connector.
>>(We would need more in one machine...)
>>So we decided to try an usb-serial converter. The one we bought
>>was happily recognized by a RedHat 9 system but I couldn't get
>>two-way communication over this converter.
> 
> 
> Which kernel version are you using?

RH9 errata kernel 2.4.20-19.9, I also tried 2.6.0-test3-mm3.
On a sidenote, I also tried its driver on W98SE, WinXP.
Same result with the MinGW compiled test programs.

> I didn't run your test programs, but are you sure you got the hardware
> flow control settings correct?  How about testing the device with

Hmm, how comes the same settings *work* on real 16550?
Even under Win*, with the MinGW compiled testprograms...

> minicom, as that is a program that is known to work properly with these
> devices (along with lots of other ones, but that's a good place to
> start.)

I tried it now, thanks. Same thing happens. I set up two different
minirc, /etc/minirc.dfl using /dev/ttyS0 and /etc/minirc.usb
for /dev/ttyUSB0. In one terminal, I typed 'minicom', in another
'minicom usb'. In the 'minicom usb' what I type, appears in the
other window, but keys typed in the 'minicom' do not appear in
'minicom usb'.

I am starting to be convinced that it is a hardware flaw.
I will try to replace it.

>>setserial produces an error:
>>
>># setserial /dev/ttyUSB0
>>Cannot get serial info: Invalid argument
> 
> 
> Yes, setserial does not work with the majority of the usb-serial
> drivers, patches gladly accepted to fix this :)

I wasn't prepared to this answer. ;-)

> 
> thanks,
> 
> greg k-h

-- 
Best regards,
Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.


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

* Re: How to use an USB<->serial adapter?
  2003-08-21 17:08 ` Greg KH
  2003-08-22  7:02   ` Boszormenyi Zoltan
@ 2003-08-22 12:05   ` Boszormenyi Zoltan
  1 sibling, 0 replies; 8+ messages in thread
From: Boszormenyi Zoltan @ 2003-08-22 12:05 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Hi,

here's the test programs output and I also set the module option
debug=1 in pl2303.

The testprograms' sources are still in my first mail.

In one terminal I started the listener test, it shows that
it received bytes on ttyS0, tried to write the answer:

$ ./serialtest2 /dev/ttyS0
read: 0x00, written: 0x01
read: 0x01, written: 0x02
read: 0x02, written: 0x03
read: 0x03, written: 0x04
read: 0x04, written: 0x05
read: 0x05, written: 0x06
read: 0x06, written: 0x07
read: 0x07, written: 0x08
read: 0x08, written: 0x09
read: 0x09, written: 0x0a
read: 0x00, written: 0x01
read: 0x01, written: 0x02
read: 0x02, written: 0x03
read: 0x03, written: 0x04
read: 0x04, written: 0x05
read: 0x05, written: 0x06
read: 0x06, written: 0x07
read: 0x07, written: 0x08
read: 0x08, written: 0x09
read: 0x09, written: 0x0a

In another terminal, I started the initiator test twice:

$ ./serialtest1 /dev/usb/ttyUSB0
written: 0x00, read: 0x00           <- sometimes I get one zero byte
written: 0x01, couldn't read
written: 0x02, couldn't read
written: 0x03, couldn't read
written: 0x04, couldn't read
written: 0x05, couldn't read
written: 0x06, couldn't read
written: 0x07, couldn't read
written: 0x08, couldn't read
written: 0x09, couldn't read
$ ./serialtest1 /dev/usb/ttyUSB0
written: 0x00, couldn't read
written: 0x01, couldn't read
written: 0x02, couldn't read
written: 0x03, couldn't read
written: 0x04, couldn't read
written: 0x05, couldn't read
written: 0x06, couldn't read
written: 0x07, couldn't read
written: 0x08, couldn't read
written: 0x09, couldn't read

During the session, the kernel log contains this:

usb.c: USB disconnect on device 00:04.2-2 address 3
pl2303.c: pl2303_shutdown
usbserial.c: PL-2303 converter now disconnected from ttyUSB0
hub.c: new USB device 00:04.2-2, assigned address 4
usbserial.c: PL-2303 converter detected
usbserial.c: PL-2303 converter now attached to ttyUSB0 (or usb/tts/0 for 
devfs)
pl2303.c: pl2303_open -  port 0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0x40:0x1:0x404:0x0  0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8383:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0x40:0x1:0x404:0x1  0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8383:0x0  1 - 0
pl2303.c: 0x40:0x1:0x0:0x1  0
pl2303.c: 0x40:0x1:0x1:0xc0  0
pl2303.c: 0x40:0x1:0x2:0x4  0
pl2303.c: pl2303_set_termios -  port 0, initialized = 0
pl2303.c: 0xa1:0x21:0:0  7 - 0 0 0 0 0 0 0
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 9600
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: pl2303_open - submitting read urb
pl2303.c: pl2303_open - submitting interrupt urb
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_ioctl (0) cmd = 0x540b
pl2303.c: pl2303_ioctl not supported = 0x540b
pl2303.c: pl2303_ioctl (0) cmd = 0x5402
pl2303.c: pl2303_ioctl not supported = 0x5402
pl2303.c: pl2303_set_termios -  port 0, initialized = 1
pl2303.c: pl2303_read_int_callback - length = 10, data = a1 20 00 00 00 
00 02 00 83 00
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 115200
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 0 c2 1 0 0 0 8
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 00
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_read_bulk_callback - port 0
pl2303.c: pl2303_read_bulk_callback - length = 1, data = 00
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 01
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 02
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 03
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 04
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 05
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 06
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 07
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 08
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 09
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_ioctl (0) cmd = 0x540b
pl2303.c: pl2303_ioctl not supported = 0x540b
pl2303.c: pl2303_ioctl (0) cmd = 0x5402
pl2303.c: pl2303_ioctl not supported = 0x5402
pl2303.c: pl2303_set_termios -  port 0, initialized = 1
pl2303.c: 0xa1:0x21:0:0  7 - 0 c2 1 0 0 0 8
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 9600
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_close - port 0
pl2303.c: set_control_lines - value = 0, retval = 0
pl2303.c: pl2303_close - shutting down urbs
pl2303.c: pl2303_close - usb_unlink_urb (write_urb) failed with reason: -19
pl2303.c: pl2303_read_bulk_callback - port 0
pl2303.c: pl2303_read_bulk_callback - urb->status = -2
pl2303.c: pl2303_read_bulk_callback - port is closed, exiting.
pl2303.c: pl2303_open -  port 0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0x40:0x1:0x404:0x0  0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8383:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0x40:0x1:0x404:0x1  0
pl2303.c: 0xc0:0x1:0x8484:0x0  1 - 0
pl2303.c: 0xc0:0x1:0x8383:0x0  1 - 0
pl2303.c: 0x40:0x1:0x0:0x1  0
pl2303.c: 0x40:0x1:0x1:0xc0  0
pl2303.c: 0x40:0x1:0x2:0x4  0
pl2303.c: pl2303_set_termios -  port 0, initialized = 1
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 9600
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: pl2303_open - submitting read urb
pl2303.c: pl2303_open - submitting interrupt urb
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_ioctl (0) cmd = 0x540b
pl2303.c: pl2303_ioctl not supported = 0x540b
pl2303.c: pl2303_ioctl (0) cmd = 0x5402
pl2303.c: pl2303_ioctl not supported = 0x5402
pl2303.c: pl2303_set_termios -  port 0, initialized = 1
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 115200
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 0 c2 1 0 0 0 8
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 00
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 01
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 02
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 03
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 04
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 05
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 06
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 07
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 08
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_write - port 0, 1 bytes
pl2303.c: pl2303_write - length = 1, data = 09
pl2303.c: pl2303_write_bulk_callback - port 0
pl2303.c: pl2303_ioctl (0) cmd = 0x540b
pl2303.c: pl2303_ioctl not supported = 0x540b
pl2303.c: pl2303_ioctl (0) cmd = 0x5402
pl2303.c: pl2303_ioctl not supported = 0x5402
pl2303.c: pl2303_set_termios -  port 0, initialized = 1
pl2303.c: 0xa1:0x21:0:0  7 - 0 c2 1 0 0 0 8
pl2303.c: 0x40:1:0:1  0
pl2303.c: pl2303_set_termios - data bits = 8
pl2303.c: pl2303_set_termios - baud = 9600
pl2303.c: pl2303_set_termios - stop bits = 1
pl2303.c: pl2303_set_termios - parity = none
pl2303.c: 0x21:0x20:0:0  7
pl2303.c: set_control_lines - value = 3, retval = 0
pl2303.c: 0xa1:0x21:0:0  7 - 80 25 0 0 0 0 8
pl2303.c: pl2303_ioctl (0) cmd = 0x5401
pl2303.c: pl2303_ioctl not supported = 0x5401
pl2303.c: pl2303_close - port 0
pl2303.c: set_control_lines - value = 0, retval = 0
pl2303.c: pl2303_close - shutting down urbs
pl2303.c: pl2303_close - usb_unlink_urb (write_urb) failed with reason: -19
pl2303.c: pl2303_read_bulk_callback - port 0
pl2303.c: pl2303_read_bulk_callback - urb->status = -2
pl2303.c: pl2303_read_bulk_callback - port is closed, exiting.

I also tried some different baud rates (2400, 19200) besides
the fastest 115200 that was default in the testprograms.

Now what?

Oh, did I mention that the pinout of the cable (that I use to loopback
the USB<->serial cable into the same PC) is

DB9 <-> DB9
1,6 <-> 4
2   <-> 3
3   <-> 2
4   <-> 1,6
5   <-> 5
7   <-> 8
8   <-> 7

-- 
Best regards,
Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.


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

* Re: How to use an USB<->serial adapter?
  2003-08-21 23:18 ` Daniel Egger
@ 2003-08-25  6:24   ` Boszormenyi Zoltan
  2003-08-25 10:19     ` Daniel Egger
  0 siblings, 1 reply; 8+ messages in thread
From: Boszormenyi Zoltan @ 2003-08-25  6:24 UTC (permalink / raw)
  To: Daniel Egger; +Cc: linux-kernel

Daniel Egger wrote:
> Am Don, 2003-08-21 um 14.44 schrieb Boszormenyi Zoltan:
> 
> 
>>usb.c: registered new driver serial
>>usbserial.c: USB Serial support registered for Generic
>>usbserial.c: USB Serial Driver core v1.4
>>usbserial.c: USB Serial support registered for PL-2303
>>usbserial.c: PL-2303 converter detected
>>usbserial.c: PL-2303 converter now attached to ttyUSB0 \
>>(or usb/tts/0 for devfs)
>>pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.9
> 
> 
> Works for me, even on PowerPC. I'm typically using minicom and ckermit
> but mgetty and others work fine, too.

What product is this? Mine is a Wiretek UN8BE, based on Prolific 2303.

# lsusb -s 001:002
Bus 001 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial 
Port
   Language IDs: none (invalid length string descriptor 63; len=7)
Device Descriptor:
   bLength                18
   bDescriptorType         1
   bcdUSB               1.10
   bDeviceClass            0 Interface
   bDeviceSubClass         0
   bDeviceProtocol         0
   bMaxPacketSize0         8
   idVendor           0x067b Prolific Technology, Inc.
   idProduct          0x2303 PL2303 Serial Port
   bcdDevice            2.02
   iManufacturer           0   <--- should'nt these two be set?
   iProduct                0   <--- (or not, it is optional)
   iSerial                 0
   bNumConfigurations      1
   Configuration Descriptor:
     bLength                 9
     bDescriptorType         2
     wTotalLength           39
     bNumInterfaces          1
     bConfigurationValue     1
     iConfiguration          0
     bmAttributes         0xa0
       Remote Wakeup
     MaxPower              100mA
     Interface Descriptor:
       bLength                 9
       bDescriptorType         4
       bInterfaceNumber        0
       bAlternateSetting       0
       bNumEndpoints           3
       bInterfaceClass       255 Vendor Specific Class
       bInterfaceSubClass      0
       bInterfaceProtocol      0
       iInterface              0
       Endpoint Descriptor:
         bLength                 7
         bDescriptorType         5
         bEndpointAddress     0x81  EP 1 IN
         bmAttributes            3
           Transfer Type            Interrupt
           Synch Type               none
         wMaxPacketSize         10
         bInterval               1
       Endpoint Descriptor:
         bLength                 7
         bDescriptorType         5
         bEndpointAddress     0x02  EP 2 OUT
         bmAttributes            2
           Transfer Type            Bulk
           Synch Type               none
         wMaxPacketSize         64
         bInterval               0
       Endpoint Descriptor:
         bLength                 7
         bDescriptorType         5
         bEndpointAddress     0x83  EP 3 IN
         bmAttributes            2
           Transfer Type            Bulk
           Synch Type               none
         wMaxPacketSize         64
         bInterval               0
   Language IDs: none (invalid length string descriptor 63; len=7)

In the shop they said this one cannot be used as a null-link but works
with external serial devices, e.g. modems. I have yet to verify this
statement myself.

>>setserial produces an error:
> 
> 
> What do you need this relic from former times for?

I tried to query the USB serial line's current parameters.
Is there any other utilities that can do this for me?

-- 
Best regards,
Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.


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

* Re: How to use an USB<->serial adapter?
  2003-08-25  6:24   ` Boszormenyi Zoltan
@ 2003-08-25 10:19     ` Daniel Egger
  2003-08-27  9:33       ` Boszormenyi Zoltan
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Egger @ 2003-08-25 10:19 UTC (permalink / raw)
  To: Boszormenyi Zoltan; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3195 bytes --]

Am Mon, 2003-08-25 um 08.24 schrieb Boszormenyi Zoltan:

> What product is this? Mine is a Wiretek UN8BE, based on Prolific 2303.

Mine is from STLAB.

Bus 002 Device 003: ID 7b06:0323
  Language IDs: none (invalid length string descriptor 63; len=7)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB              10.01
  bDeviceClass            0 Interface
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x7b06
  idProduct          0x0323
  bcdDevice            2.02
  iManufacturer           0
  iProduct                0
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               none
        wMaxPacketSize         10
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize         64
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize         64
        bInterval               0
  Language IDs: none (invalid length string descriptor 63; len=7)

Hrm, lsusb seems to have an endianess problem, the vendorid is garbled.

> In the shop they said this one cannot be used as a null-link but works
> with external serial devices, e.g. modems. I have yet to verify this
> statement myself.

Doesn't really make sense to me. RS232 is specified electrically, the
adapter doesn't know which kind of device it is talking to. I'm using
mine to connect to a TTL-RS232 adapter which sits on a DSL-router, so
it's like a "null-link".

> I tried to query the USB serial line's current parameters.
> Is there any other utilities that can do this for me?

Why do you need this, don't you know what you set it to? :)
There are ioctls for it and probably a terminal program will know how to
read and write it.

-- 
Servus,
       Daniel

[-- Attachment #2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: How to use an USB<->serial adapter?
  2003-08-25 10:19     ` Daniel Egger
@ 2003-08-27  9:33       ` Boszormenyi Zoltan
  0 siblings, 0 replies; 8+ messages in thread
From: Boszormenyi Zoltan @ 2003-08-27  9:33 UTC (permalink / raw)
  To: Daniel Egger; +Cc: linux-kernel, Greg KH

Daniel Egger wrote:
> Am Mon, 2003-08-25 um 08.24 schrieb Boszormenyi Zoltan:
> 
> 
>>What product is this? Mine is a Wiretek UN8BE, based on Prolific 2303.
> 
> 
> Mine is from STLAB.
> ...
> 
>>In the shop they said this one cannot be used as a null-link but works
>>with external serial devices, e.g. modems. I have yet to verify this
>>statement myself.
> 
> 
> Doesn't really make sense to me. RS232 is specified electrically, the
> adapter doesn't know which kind of device it is talking to. I'm using
> mine to connect to a TTL-RS232 adapter which sits on a DSL-router, so
> it's like a "null-link".

Now, I was able to get an external modem. No workee...
The modem RD/TD LEDs are flashing, DTR is lit on permanently
so the modem is receiving and *tries to send*. Maybe the shop
went this far in testing to say that the cable works. :-(
But the PC isn't receiving. E.g. in WinXX, the modem is not found,
in RH9, no dialing out.

At least it is consistent with my findings with the null-link cable.
Back to the shop and sorry for the noise.

-- 
Best regards,
Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.


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

end of thread, other threads:[~2003-08-27  9:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-21 12:44 How to use an USB<->serial adapter? Boszormenyi Zoltan
2003-08-21 17:08 ` Greg KH
2003-08-22  7:02   ` Boszormenyi Zoltan
2003-08-22 12:05   ` Boszormenyi Zoltan
2003-08-21 23:18 ` Daniel Egger
2003-08-25  6:24   ` Boszormenyi Zoltan
2003-08-25 10:19     ` Daniel Egger
2003-08-27  9:33       ` Boszormenyi Zoltan

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).