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. =20
:o)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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&Item=3DGUC232A">=
http://www.iogear.com/main.php?loc=3Dproduct&Item=3DGUC232A</A>).&nbs=
p;=20
This puppy works fine when I use cat to read or write to the serial =
port. =20
However, when I run the code snippette pasted below, it will read =
but=20
not write and after I quit the executable the USBtoSerial converter =
stops=20
working entirely until I reset it by unplugging it and replugging =
it. 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. =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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> </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> =
_newtio.c_cc[VINTR] =3D=20
0; /* Ctrl-c */<BR> =20
_newtio.c_cc[VQUIT] =3D 0; /* =
Ctrl-\=20
*/<BR> _newtio.c_cc[VERASE] =3D =
0; /*=20
del */<BR> _newtio.c_cc[VKILL] =3D=20
0; /* @ */<BR> =20
_newtio.c_cc[VEOF] =3D =
4; /*=20
Ctrl-d */<BR> _newtio.c_cc[VTIME] =3D=20
0; /* inter-character timer unused */<BR> =20
_newtio.c_cc[VMIN] =3D =
1; /*=20
blocking read until 1 character arrives */<BR> =20
_newtio.c_cc[VSWTC] =3D 0; /* =
'\0'=20
*/<BR> _newtio.c_cc[VSTART] =3D =
0; /*=20
Ctrl-q */<BR> _newtio.c_cc[VSTOP] =3D=20
0; /* Ctrl-s */<BR> =20
_newtio.c_cc[VSUSP] =3D 0; /* =
Ctrl-z=20
*/<BR> _newtio.c_cc[VEOL] =3D=20
0; /* '\0' */<BR> _newtio.c_cc[VREPRINT] =
=3D=20
0; /* Ctrl-r */<BR> _newtio.c_cc[VDISCARD] =
=3D=20
0; /* Ctrl-u */<BR> =
_newtio.c_cc[VWERASE] =3D=20
0; /* Ctrl-w */<BR> =20
_newtio.c_cc[VLNEXT] =3D 0; /* =
Ctrl-v=20
*/<BR> _newtio.c_cc[VEOL2] =3D =
0; =20
/* '\0' */</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> tcflush( fd, TCIFLUSH =
);<BR> =20
tcsetattr( fd, TCSANOW, &_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> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks, PLUG'rs</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>-S Cook</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_00C2_01C50D29.CA8F0D00--