LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-08-2006, 01:50 AM   #1
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Rep: Reputation: 15
Serial port spy


Any program can monitor / capture the serial port data in real time under Linux environment?
 
Old 06-08-2006, 01:42 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
Been a while since I worked on serial but back then we simply added a tee statement to the start line in /etc/inittab. We did that a lot for serial interfaces where we wanted to see the traffic.
 
Old 06-11-2006, 07:21 AM   #3
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Original Poster
Rep: Reputation: 15
Hi jlightner,

Thank you for your information. However, I'm a beginner on Linux. Can you provide me more information about the "tee statment"?

Thanks again.
Alan.
 
Old 06-12-2006, 09:25 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
I guess first I'll have to epxlain that basically in Linux/Unix you have the concept of "standard" file handles. The 3 basic ones are standard input (stdin), standard output (stdout) and standard error (stderr). stdout is file handle 1 and stderr is file handle 2.

By default stdout and stderr both point to the display device you are using. They can be redirected. This is commonly done with items going to a log file. A good example is "ls -l"

Do "ls -l" and you'll see a list of files on your screen.

Do "ls -l 2>/tmp/testlog1" and you'll see the list of files on your screen. If there were any errors (unlikely in a simple ls) you'd see them in the file /tmp/testlog1. (Type "cat /tmp/testlog1" to see its contents.)

Do "ls -l >/tmp/testlog2" and you will NOT see the list of files on your screen. However if you look at /tmp/testlog2 (cat /tmp/testlog2) you'll see it contains all the files. (Note: If file handle number isn't specified as in prior example it is assumed to be file handle 1, stdout.)

Typically in logging you want BOTH the stdout and the stderr to go to the file so the syntax would be "ls -l >/tmp/testlog3 2>&1". In this case nothing will appear in your screen. The file list AND any errors will appear in your log file. The "2>&1" says to redirect stderr into stdout.

Note that it is important the ">/tmp/testlog3" appear BEFORE the "2>&1". If you had it the other way then 2 would go to your display because at the time you set its redirection that was where 1 was set. Restated you must set 1 before you set 2 if you want them both to go to the same location with the above syntax.

In addition to redirection as described above there is the concept of piping. By default the pipe sign (veritical bar, | ) takes anything from stdout and pipes it into the command following the pipe sign.

All of this leads us to the "tee" command which is used to duplicate output to the display AND to a file. So doing "ls -l |tee /tmp/testlog4" will show the list of files on your screen AND write the list to the file /tmp/testlog4. Any errors if they occur would only appear on the screen and not in the file.

Since pipe does NOT deal with stderr you have to also redirect stderr BEFORE the pipe so it goes to stdout which is then acted upon by the pipe. "ls -l 2>&1 |tee /tmp/testlog5" would therefore first redirect stderr to stdout then pipe stdout to tee. Tee would then show everything from ls -l on the screen AND write the list to /tmp/testlog5.

You'd need to modify your inittab entry so that whatever it currently sends to the device is tee'd to the file you want. Also for interfaces we used to redirect IN from the stdin. There are likely examples of such inittab entries. Unfortunately as I've mentioned before it has been a long time since I did one so I can't give you a good example.

For more detail on the tee command just type "man tee" or "info tee". FYI: Most Unix/Linux commands have a "man" (manual) page and in Linux typing "info" will show you the "man" page as well as any extended information if it exists.
 
Old 06-12-2006, 10:34 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Although looking for another one, maybe this one can do what you need.
 
Old 06-14-2006, 08:55 PM   #6
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Original Poster
Rep: Reputation: 15
Hi jlightner,

I'm very appreciated on your details explanation, thank you very much.

Besides, thank you for the information from Wim Sturkenboom also.

You both make my work more easier. Thank you once again.

Alan.
 
  


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
linux serial port to router console port connection? frankie_fix Linux - General 3 02-26-2007 09:32 PM
timedia 4 port serial port i/o card configuration binu_edl Linux - Hardware 0 03-09-2006 09:39 AM
IBM AIX 5.2/5.3 serial port/tty0 port vinod_balani AIX 2 02-19-2006 03:38 PM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
Using an USB port as a standard DB9 Serial Port Lsteele Linux - Newbie 1 10-22-2005 09:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration