LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-08-2010, 07:38 PM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 166

Rep: Reputation: 15
Serial ports, USB-Serial adapters, and Linux


I have a tool that communicates with a robot via serial. My eventual goal is to build a man-in-the-middle box for the serial communication line, so that I can listen to the transmitted serial messages and modify them if desired, and then transmit them on. A small amount of latency introduced is not a problem. Can I do this with, say, a PC running Linux, and Perl? Is there a better way?

As a proof of concept, I figured I could use my laptop and two USB-to-Serial adapters.

As a first step, I plugged both serial adapters in, and connected them to each other through a null modem.

Now what? I figured I could just
Code:
 cat /dev/ttyX
, and then in a different terminal,
Code:
echo "blarg" >> /dev/ttyY
, and I would see "blarg" show up in the terminal that had cat running. The problem is figuring out what /dev/ttyX and /dev/ttyY are. My system has a bunch of tty device files, but how can I know which of them correspond to my two serial adapters?

Once upon a time, I had a perl script to communicated with a piece of lab equipment, and all I did was

Code:
open(MEOUT, ">>/dev/ttyUSB0");  
open(MEIN, "</dev/ttyUSB0");
print MEOUT "*rst\n"; #reset the tool
The trouble I'm having is I have two USB-Serial adapters plugged in and I only have one /dev/ttyUSB0.



Even though I plugged two serial adapters in, there is only the one /dev/ttyUSB0 when they are both plugged in.

Code:
chaz@singularity:~$ ls /dev/tty*
/dev/tty    /dev/tty16  /dev/tty24  /dev/tty32  /dev/tty40  /dev/tty49  /dev/tty57  /dev/tty8
/dev/tty0   /dev/tty17  /dev/tty25  /dev/tty33  /dev/tty41  /dev/tty5   /dev/tty58  /dev/tty9
/dev/tty1   /dev/tty18  /dev/tty26  /dev/tty34  /dev/tty42  /dev/tty50  /dev/tty59  /dev/ttyS0
/dev/tty10  /dev/tty19  /dev/tty27  /dev/tty35  /dev/tty43  /dev/tty51  /dev/tty6   /dev/ttyS1
/dev/tty11  /dev/tty2   /dev/tty28  /dev/tty36  /dev/tty44  /dev/tty52  /dev/tty60  /dev/ttyS2
/dev/tty12  /dev/tty20  /dev/tty29  /dev/tty37  /dev/tty45  /dev/tty53  /dev/tty61  /dev/ttyS3
/dev/tty13  /dev/tty21  /dev/tty3   /dev/tty38  /dev/tty46  /dev/tty54  /dev/tty62  /dev/ttyUSB0
/dev/tty14  /dev/tty22  /dev/tty30  /dev/tty39  /dev/tty47  /dev/tty55  /dev/tty63
/dev/tty15  /dev/tty23  /dev/tty31  /dev/tty4   /dev/tty48  /dev/tty56  /dev/tty7
chaz@singularity:~$

Last edited by Daravon; 09-08-2010 at 07:45 PM.
 
Old 09-08-2010, 10:19 PM   #2
Daravon
Member
 
Registered: Mar 2006
Posts: 166

Original Poster
Rep: Reputation: 15
I've discovered that while both USB-to-Serial adapters show up in lsusb, only one of them results in the creation of a /dev/ttyUSB* file. Any ideas on why the other one does not? Is it faulty?

Blue adapter:
Code:
chaz@singularity:~$ lsusb
Bus 002 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0c45:62c0 Microdia Sonix USB 2.0 Camera
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
chaz@singularity:~$
Code:
chaz@singularity:~$ ls /dev/*tty*
/dev/tty    /dev/tty16  /dev/tty24  /dev/tty32  /dev/tty40  /dev/tty49  /dev/tty57  /dev/tty8
/dev/tty0   /dev/tty17  /dev/tty25  /dev/tty33  /dev/tty41  /dev/tty5   /dev/tty58  /dev/tty9
/dev/tty1   /dev/tty18  /dev/tty26  /dev/tty34  /dev/tty42  /dev/tty50  /dev/tty59  /dev/ttyS0
/dev/tty10  /dev/tty19  /dev/tty27  /dev/tty35  /dev/tty43  /dev/tty51  /dev/tty6   /dev/ttyS1
/dev/tty11  /dev/tty2   /dev/tty28  /dev/tty36  /dev/tty44  /dev/tty52  /dev/tty60  /dev/ttyS2
/dev/tty12  /dev/tty20  /dev/tty29  /dev/tty37  /dev/tty45  /dev/tty53  /dev/tty61  /dev/ttyS3
/dev/tty13  /dev/tty21  /dev/tty3   /dev/tty38  /dev/tty46  /dev/tty54  /dev/tty62  /dev/ttyUSB0
/dev/tty14  /dev/tty22  /dev/tty30  /dev/tty39  /dev/tty47  /dev/tty55  /dev/tty63
/dev/tty15  /dev/tty23  /dev/tty31  /dev/tty4   /dev/tty48  /dev/tty56  /dev/tty7
chaz@singularity:~$

black adapter:
Code:
chaz@singularity:~$ lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 006: ID 9710:7715 MosChip Semiconductor Printer cable
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0c45:62c0 Microdia Sonix USB 2.0 Camera
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
chaz@singularity:~$
Code:
chaz@singularity:~$ ls /dev/*tty*
/dev/tty    /dev/tty16  /dev/tty24  /dev/tty32  /dev/tty40  /dev/tty49  /dev/tty57  /dev/tty8
/dev/tty0   /dev/tty17  /dev/tty25  /dev/tty33  /dev/tty41  /dev/tty5   /dev/tty58  /dev/tty9
/dev/tty1   /dev/tty18  /dev/tty26  /dev/tty34  /dev/tty42  /dev/tty50  /dev/tty59  /dev/ttyS0
/dev/tty10  /dev/tty19  /dev/tty27  /dev/tty35  /dev/tty43  /dev/tty51  /dev/tty6   /dev/ttyS1
/dev/tty11  /dev/tty2   /dev/tty28  /dev/tty36  /dev/tty44  /dev/tty52  /dev/tty60  /dev/ttyS2
/dev/tty12  /dev/tty20  /dev/tty29  /dev/tty37  /dev/tty45  /dev/tty53  /dev/tty61  /dev/ttyS3
/dev/tty13  /dev/tty21  /dev/tty3   /dev/tty38  /dev/tty46  /dev/tty54  /dev/tty62
/dev/tty14  /dev/tty22  /dev/tty30  /dev/tty39  /dev/tty47  /dev/tty55  /dev/tty63
/dev/tty15  /dev/tty23  /dev/tty31  /dev/tty4   /dev/tty48  /dev/tty56  /dev/tty7
chaz@singularity:~$
 
Old 09-09-2010, 06:31 AM   #3
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 492

Rep: Reputation: 50
Quote:
Bus 003 Device 006: ID 9710:7715 MosChip Semiconductor Printer cable
It looks more like a parallel adapter than a serial one...
 
Old 09-09-2010, 06:53 AM   #4
Daravon
Member
 
Registered: Mar 2006
Posts: 166

Original Poster
Rep: Reputation: 15
It was one of those Open-box discounted items at Fry's. I bet someone switched devices in the package.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial input device using usb-serial connector slackiz Linux - Hardware 4 01-12-2009 05:04 AM
Using USB<->Serial and serial gender changer to transmit data between computers JoeyAdams Linux - Hardware 4 04-17-2008 05:15 AM
Control of device names of USB to RS232 serial adapters hakelm Linux - Hardware 1 02-11-2008 07:49 PM
Serial Port taken by Ext Modem. I need to use one of my(2) USB ports to convert Balarabay1 Suse/Novell 2 03-15-2006 06:25 PM
zoom external serial with usb to serial adapter foustware Linux - Hardware 1 12-07-2003 02:02 AM


All times are GMT -5. The time now is 07:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration