Re: Serial Port Monitoring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 12 October 2004 09:57, Neil Marjoram wrote:
> Has anyone got any software that can monitor all data  from a
> serial port?
>
> I have looked around and found a couple of projects, but I can't
> find anything that can time stamp the data as well as log it.
>
> I am currently looking at slsnif-0.4.3, which seems to be able to
> do it only I am getting an error :
>
> Serial Line Sniffer. Version 0.4.3
>         Copyright (C) 2001 Yan Gurtovoy (ymg@xxxxxxxxxxxxx)
>
> Failed to open a pty: No such file or directory
>
> Can anyone tell me what this may be?
>
> I am in a race with an MS system to deliver the output - the
> project found the Winblows box to be unreliable (funny that!),
> and big mouth here said why don't you use a proper system!
>
> Thanks,
>
> Neil.
>
 
You didn't say, but if your serial communication is based on lines 
of text you can easily use something like tclsh or expect as 
follows:

############## serial_capture.sh ##############

#!/usr/bin/expect

proc Reader { pipe } {
  global done

  if {[eof $pipe]} {
    catch {close $pipe}
    set done 1
    return
  }
  gets $pipe line
  set tagxmitdate [clock seconds]
  #puts $line $tagxmitdate
  puts "$tagxmitdate $line"
}

set pipe [open "|cat /dev/ttyS0" r]
fileevent $pipe readable [list Reader $pipe]
vwait done

####### End serial_capture.sh #########

This was done on FC1 with expect:

$rpm -qa expect
expect-5.39.0-96.0.1

The line with "set pipe" shows ttyS0 but you can specify which 
serial device you want to use. The output will be as follows:

$./serial_capture.sh

1097638625 Line 1
1097638625 Line 2 
1097638625 Line 3
1097638625 etc...

which shows the number of seconds since Jan 01, 1970 for each line 
of text your received.  In order to save this to a file simply 
redirect the output: i.e.

$./serial_capture.sh > serial.log

Regards, Mike Klinke  


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux