USB to Serial converter issue

Shawn Cook plug-devel@lists.PLUG.phoenix.az.us
Mon Feb 7 13:54:02 2005


This is a multi-part message in MIME format.

------=_NextPart_000_00C2_01C50D29.CA8F0D00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi there,
This is my first PLUG mailing list attempt, so please forgive me if I =
break some "email mailing list" etiquette.  :o)

I have an IOGear USB to Serail converter cable =
(http://www.iogear.com/main.php?loc=3Dproduct&Item=3DGUC232A).  This =
puppy works fine when I use cat to read or write to the serial port.  =
However, when I run the code snippette pasted below, it will read but =
not write and after I quit the executable the USBtoSerial converter =
stops working entirely until I reset it by unplugging it and replugging =
it.  I'm pretty sure it's not my code because I can change the device to =
a standard serial port and it reads/writes with no problems.  =20

Here's some system info:
Embedded Linux distro, kernel v2.6.5
Octagon XE800 Single Board Computer (detailed sys info: =
http://octagonsystems.com/CPUpages/xe800.html)
AMD GX-1 300MHz processor
USB 2.0

Code Snipette:
-------------------------------------------------------------------------=
-------------------------------------------
cComDev=3D"/dev/ttyUSB0";
..
_fd =3D open( cComDev, O_RDWR | O_NOCTTY );
..
_newtio.c_cflag =3D _iBaud | CRTSCTS | CS8 | CLOCAL | CREAD;
_newtio.c_iflag =3D IGNPAR | ICRNL;
_newtio.c_oflag =3D 0;
_newtio.c_lflag =3D ICANON;
  _newtio.c_cc[VINTR]    =3D 0;     /* Ctrl-c */
  _newtio.c_cc[VQUIT]    =3D 0;     /* Ctrl-\ */
  _newtio.c_cc[VERASE]   =3D 0;     /* del */
  _newtio.c_cc[VKILL]    =3D 0;     /* @ */
  _newtio.c_cc[VEOF]     =3D 4;     /* Ctrl-d */
  _newtio.c_cc[VTIME]    =3D 0;     /* inter-character timer unused */
  _newtio.c_cc[VMIN]     =3D 1;     /* blocking read until 1 character =
arrives */
  _newtio.c_cc[VSWTC]    =3D 0;     /* '\0' */
  _newtio.c_cc[VSTART]   =3D 0;     /* Ctrl-q */
  _newtio.c_cc[VSTOP]    =3D 0;     /* Ctrl-s */
  _newtio.c_cc[VSUSP]    =3D 0;     /* Ctrl-z */
  _newtio.c_cc[VEOL]     =3D 0;     /* '\0' */
  _newtio.c_cc[VREPRINT] =3D 0;     /* Ctrl-r */
  _newtio.c_cc[VDISCARD] =3D 0;     /* Ctrl-u */
  _newtio.c_cc[VWERASE]  =3D 0;     /* Ctrl-w */
  _newtio.c_cc[VLNEXT]   =3D 0;     /* Ctrl-v */
  _newtio.c_cc[VEOL2]    =3D 0;     /* '\0' */
  tcflush( fd, TCIFLUSH );
  tcsetattr( fd, TCSANOW, &_newtio );
..
status =3D read( _fd, data, bufsize );
..
status =3D write( _fd, data, bufsize );
-------------------------------------------------------------------------=
-------------------------------------------

Like I said before, all this jazz works fine for a standard serial port =
(cComDev=3D"/dev/ttyS0";), but when I change this line: =
cComDev=3D"/dev/ttyUSB0"; it gets all 'crappy'.

Thanks, PLUG'rs

-S Cook


------=_NextPart_000_00C2_01C50D29.CA8F0D00
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi there,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This is my first PLUG mailing list =
attempt, so=20
please forgive me if I break some "email mailing list" etiquette.&nbsp;=20
:o)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have an IOGear USB to Serail =
converter cable (<A=20
href=3D"http://www.iogear.com/main.php?loc=3Dproduct&amp;Item=3DGUC232A">=
http://www.iogear.com/main.php?loc=3Dproduct&amp;Item=3DGUC232A</A>).&nbs=
p;=20
This puppy works fine when I use cat to read or write to the serial =
port.&nbsp;=20
However, when I run the code snippette pasted below, it&nbsp;will read =
but=20
not&nbsp;write and after I quit the executable the USBtoSerial converter =
stops=20
working entirely until I reset it by unplugging it and replugging =
it.&nbsp; I'm=20
pretty sure it's not my code because I can change the device to a =
standard=20
serial port and it reads/writes with no problems.&nbsp;&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here's some system info:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Embedded Linux distro, kernel =
v2.6.5</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Octagon XE800 Single Board Computer =
(detailed sys=20
info: <A=20
href=3D"http://octagonsystems.com/CPUpages/xe800.html">http://octagonsyst=
ems.com/CPUpages/xe800.html</A>)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>AMD GX-1 300MHz processor</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>USB 2.0</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Code Snipette:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----------------------------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>cComDev=3D"/dev/ttyUSB0";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>_fd =3D open( cComDev, O_RDWR | =
O_NOCTTY=20
);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>_newtio.c_cflag =3D _iBaud | CRTSCTS | =
CS8 | CLOCAL |=20
CREAD;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>_newtio.c_iflag =3D IGNPAR | =
ICRNL;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>_newtio.c_oflag =3D 0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>_newtio.c_lflag =3D =
ICANON;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; =
_newtio.c_cc[VINTR]&nbsp;&nbsp;&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* Ctrl-c */<BR>&nbsp;=20
_newtio.c_cc[VQUIT]&nbsp;&nbsp;&nbsp; =3D 0;&nbsp;&nbsp;&nbsp;&nbsp; /* =
Ctrl-\=20
*/<BR>&nbsp; _newtio.c_cc[VERASE]&nbsp;&nbsp; =3D =
0;&nbsp;&nbsp;&nbsp;&nbsp; /*=20
del */<BR>&nbsp; _newtio.c_cc[VKILL]&nbsp;&nbsp;&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* @ */<BR>&nbsp;=20
_newtio.c_cc[VEOF]&nbsp;&nbsp;&nbsp;&nbsp; =3D =
4;&nbsp;&nbsp;&nbsp;&nbsp; /*=20
Ctrl-d */<BR>&nbsp; _newtio.c_cc[VTIME]&nbsp;&nbsp;&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* inter-character timer unused */<BR>&nbsp;=20
_newtio.c_cc[VMIN]&nbsp;&nbsp;&nbsp;&nbsp; =3D =
1;&nbsp;&nbsp;&nbsp;&nbsp; /*=20
blocking read until 1 character arrives */<BR>&nbsp;=20
_newtio.c_cc[VSWTC]&nbsp;&nbsp;&nbsp; =3D 0;&nbsp;&nbsp;&nbsp;&nbsp; /* =
'\0'=20
*/<BR>&nbsp; _newtio.c_cc[VSTART]&nbsp;&nbsp; =3D =
0;&nbsp;&nbsp;&nbsp;&nbsp; /*=20
Ctrl-q */<BR>&nbsp; _newtio.c_cc[VSTOP]&nbsp;&nbsp;&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* Ctrl-s */<BR>&nbsp;=20
_newtio.c_cc[VSUSP]&nbsp;&nbsp;&nbsp; =3D 0;&nbsp;&nbsp;&nbsp;&nbsp; /* =
Ctrl-z=20
*/<BR>&nbsp; _newtio.c_cc[VEOL]&nbsp;&nbsp;&nbsp;&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* '\0' */<BR>&nbsp; _newtio.c_cc[VREPRINT] =
=3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* Ctrl-r */<BR>&nbsp; _newtio.c_cc[VDISCARD] =
=3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* Ctrl-u */<BR>&nbsp; =
_newtio.c_cc[VWERASE]&nbsp; =3D=20
0;&nbsp;&nbsp;&nbsp;&nbsp; /* Ctrl-w */<BR>&nbsp;=20
_newtio.c_cc[VLNEXT]&nbsp;&nbsp; =3D 0;&nbsp;&nbsp;&nbsp;&nbsp; /* =
Ctrl-v=20
*/<BR>&nbsp; _newtio.c_cc[VEOL2]&nbsp;&nbsp;&nbsp; =3D =
0;&nbsp;&nbsp;&nbsp;&nbsp;=20
/* '\0' */</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; tcflush( fd, TCIFLUSH =
);<BR>&nbsp;=20
tcsetattr( fd, TCSANOW, &amp;_newtio );</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>status =3D read( _fd, data, bufsize =
);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>status =3D write( _fd, data, bufsize =
);</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----------------------------------------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Like I said before, all this jazz works =
fine for a=20
standard serial port (cComDev=3D"/dev/ttyS0";), but when I change this =
line:=20
cComDev=3D"/dev/ttyUSB0"; it gets all 'crappy'.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks, PLUG'rs</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-S Cook</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_00C2_01C50D29.CA8F0D00--