Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #13004 > unrolled thread

Simple protocol analyzer?

Started byTim Wescott <tim@seemywebsite.really>
First post2013-08-06 11:54 -0500
Last post2013-08-08 08:50 +1000
Articles 15 — 7 participants

Back to article view | Back to comp.arch.embedded


Contents

  Simple protocol analyzer? Tim Wescott <tim@seemywebsite.really> - 2013-08-06 11:54 -0500
    Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-06 17:17 +0000
      Re: Simple protocol analyzer? Tim Wescott <tim@seemywebsite.really> - 2013-08-06 13:00 -0500
        Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-06 18:48 +0000
          Re: Simple protocol analyzer? Tim Wescott <tim@seemywebsite.really> - 2013-08-06 14:33 -0500
            Re: Simple protocol analyzer? Frank Buss <fb@frank-buss.de> - 2013-08-07 14:52 +0200
            Re: Simple protocol analyzer? Les Cargill <lcargill99@comcast.com> - 2013-08-07 08:06 -0500
            Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-07 14:48 +0000
            Re: Simple protocol analyzer? rickman <gnuarm@gmail.com> - 2013-08-07 23:25 -0400
              Re: Simple protocol analyzer? John Devereux <john@devereux.me.uk> - 2013-08-08 08:44 +0100
                Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-08 12:57 +0000
          Re: Simple protocol analyzer? Clifford Heath <no.spam@please.net> - 2013-08-07 22:42 +1000
            Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-07 15:02 +0000
              Re: Simple protocol analyzer? Grant Edwards <invalid@invalid.invalid> - 2013-08-07 15:15 +0000
              Re: Simple protocol analyzer? Clifford Heath <no.spam@please.net> - 2013-08-08 08:50 +1000

#13004 — Simple protocol analyzer?

FromTim Wescott <tim@seemywebsite.really>
Date2013-08-06 11:54 -0500
SubjectSimple protocol analyzer?
Message-ID<vradnSIUxLKwt5zPnZ2dnUVZ5qudnZ2d@giganews.com>
I have a need to read in lines of text from a serial port onto a PC, and 
timestamp them.

I just need one timestamp per line, preferably for the leading character 
but I could collect data OK by getting the timestamp of the linefeed.

I'm hoping that someone has already written some sort of a simple 
protocol analyzer that does this.

Open source is a plus.  Something that's already available for 
installation in Ubunto is a double-plus.  I could make things work with 
Windows (ick).

I'm reading in numbers from an instrument which does not always sample at 
a consistent speed.  Ideally what I would end up with would be a text 
file that goes

<time> <reading> <reading> <reading> cr lf
<time> <reading> <reading> <reading> cr lf

etc.

(The end goal is to record this text file, read it into Scilab and 
analyze the bejeezus out of it).

Any suggestions?

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

[toc] | [next] | [standalone]


#13005

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-06 17:17 +0000
Message-ID<ktrb3v$ih6$1@reader1.panix.com>
In reply to#13004
On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
> I have a need to read in lines of text from a serial port onto a PC, and 
> timestamp them.
>
> I just need one timestamp per line, preferably for the leading character 
> but I could collect data OK by getting the timestamp of the linefeed.
>
> I'm hoping that someone has already written some sort of a simple 
> protocol analyzer that does this.
>
> Open source is a plus.  Something that's already available for 
> installation in Ubunto is a double-plus.

http://elinux.org/Grabserial

-- 
Grant Edwards               grant.b.edwards        Yow! Hmmm ... A hash-singer
                                  at               and a cross-eyed guy were
                              gmail.com            SLEEPING on a deserted
                                                   island, when ...

[toc] | [prev] | [next] | [standalone]


#13008

FromTim Wescott <tim@seemywebsite.really>
Date2013-08-06 13:00 -0500
Message-ID<y_ydnU1gndpIpJzPnZ2dnUVZ5h2dnZ2d@giganews.com>
In reply to#13005
On Tue, 06 Aug 2013 17:17:51 +0000, Grant Edwards wrote:

> On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
>> I have a need to read in lines of text from a serial port onto a PC,
>> and timestamp them.
>>
>> I just need one timestamp per line, preferably for the leading
>> character but I could collect data OK by getting the timestamp of the
>> linefeed.
>>
>> I'm hoping that someone has already written some sort of a simple
>> protocol analyzer that does this.
>>
>> Open source is a plus.  Something that's already available for
>> installation in Ubunto is a double-plus.
> 
> http://elinux.org/Grabserial

Grant, that's about as perfect as a command-line utility can get.  It 
does just what I want, and the command-line clunkiness doesn't intrude 
too badly.  It's going to save me tons of time over having to write 
something.

-- 
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

[toc] | [prev] | [next] | [standalone]


#13009

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-06 18:48 +0000
Message-ID<ktrge0$hrt$1@reader1.panix.com>
In reply to#13008
On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:

>> http://elinux.org/Grabserial
>
> Grant, that's about as perfect as a command-line utility can get.  It 
> does just what I want, and the command-line clunkiness doesn't intrude 
> too badly.  It's going to save me tons of time over having to write 
> something.

Well, it'll save you a few minutes over having to write something

;)


  #!/usr/bin/python
  import serial,time
  p = serial.Serial('/dev/ttyS1', 9600)
  while 1:
      line = p.readline()
      print time.time(),line

In that version, the timestamp is associated with the end of the line.
If you want the timestamp for the start of the line, it's a bit more
complicated:

  #!/usr/bin/python
  import serial,time
  p = serial.Serial('/dev/ttyS1', 9600)
  while 1:
      first = p.read(1)
      stamp = time.time()
      rest = p.readline()
      print stamp, first+rest

-- 
Grant Edwards               grant.b.edwards        Yow! Should I get locked
                                  at               in the PRINCICAL'S
                              gmail.com            OFFICE today -- or have
                                                   a VASECTOMY??

[toc] | [prev] | [next] | [standalone]


#13010

FromTim Wescott <tim@seemywebsite.really>
Date2013-08-06 14:33 -0500
Message-ID<MdednQUFYega0pzPnZ2dnUVZ5vednZ2d@giganews.com>
In reply to#13009
On Tue, 06 Aug 2013 18:48:32 +0000, Grant Edwards wrote:

> On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
> 
>>> http://elinux.org/Grabserial
>>
>> Grant, that's about as perfect as a command-line utility can get.  It
>> does just what I want, and the command-line clunkiness doesn't intrude
>> too badly.  It's going to save me tons of time over having to write
>> something.
> 
> Well, it'll save you a few minutes over having to write something
> 
> ;)
> 
> 
>   #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>   9600)
>   while 1:
>       line = p.readline() print time.time(),line
> 
> In that version, the timestamp is associated with the end of the line.
> If you want the timestamp for the start of the line, it's a bit more
> complicated:
> 
>   #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>   9600)
>   while 1:
>       first = p.read(1) stamp = time.time() rest = p.readline() print
>       stamp, first+rest

If I were to write it in python I'd first have to learn python, though.

This is better.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

[toc] | [prev] | [next] | [standalone]


#13023

FromFrank Buss <fb@frank-buss.de>
Date2013-08-07 14:52 +0200
Message-ID<kttfvb$qpp$1@newsreader4.netcologne.de>
In reply to#13010
Tim Wescott wrote:

> If I were to write it in python I'd first have to learn python, though.
> 
> This is better.

In the long term learning Python will save you much time. And you'll
find examples for almost anything, because many people are using it.

One of my retro-computing examples, using binary file read/write and WAV
file reading:

http://www.frank-buss.de/c64/sampler/index.html

Or think of automated test equipment. Buy a Raspberry Pi and download
the Python library for direct IO pin access for it, and use PyGame (not
just for games, good if you need to draw a lot) or Tkinter (good if you
have standard text fields, buttons etc.) to show something on the HDMI
output.

-- 
Frank Buss, http://www.frank-buss.de
electronics and more: http://www.youtube.com/user/frankbuss

[toc] | [prev] | [next] | [standalone]


#13024

FromLes Cargill <lcargill99@comcast.com>
Date2013-08-07 08:06 -0500
Message-ID<kttgm2$906$1@dont-email.me>
In reply to#13010
Tim Wescott wrote:
> On Tue, 06 Aug 2013 18:48:32 +0000, Grant Edwards wrote:
>
>> On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
>>
>>>> http://elinux.org/Grabserial
>>>
>>> Grant, that's about as perfect as a command-line utility can get.  It
>>> does just what I want, and the command-line clunkiness doesn't intrude
>>> too badly.  It's going to save me tons of time over having to write
>>> something.
>>
>> Well, it'll save you a few minutes over having to write something
>>
>> ;)
>>
>>
>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>    9600)
>>    while 1:
>>        line = p.readline() print time.time(),line
>>
>> In that version, the timestamp is associated with the end of the line.
>> If you want the timestamp for the start of the line, it's a bit more
>> complicated:
>>
>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>    9600)
>>    while 1:
>>        first = p.read(1) stamp = time.time() rest = p.readline() print
>>        stamp, first+rest
>
> If I were to write it in python I'd first have to learn python, though.
>
> This is better.
>


In the long run, you are better off with at least one scripting 
language. Python has good market share now; might as well be it.

I think there's a problem or two with Python that Tcl does not
have*, but anything is better than nothing.

*they are all a compromise, and I am biased.

--
Les Cargill

[toc] | [prev] | [next] | [standalone]


#13026

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-07 14:48 +0000
Message-ID<kttmog$l0i$1@reader1.panix.com>
In reply to#13010
On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
> On Tue, 06 Aug 2013 18:48:32 +0000, Grant Edwards wrote:
>
>> On 2013-08-06, Tim Wescott <tim@seemywebsite.really> wrote:
>> 
>>>> http://elinux.org/Grabserial
>>>
>>> Grant, that's about as perfect as a command-line utility can get.  It
>>> does just what I want, and the command-line clunkiness doesn't intrude
>>> too badly.  It's going to save me tons of time over having to write
>>> something.
>> 
>> Well, it'll save you a few minutes over having to write something
>> 
>> ;)
>> 
>> 
>>   #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>   9600)
>>   while 1:
>>       line = p.readline() print time.time(),line
>> 
>> In that version, the timestamp is associated with the end of the line.
>> If you want the timestamp for the start of the line, it's a bit more
>> complicated:
>> 
>>   #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>   9600)
>>   while 1:
>>       first = p.read(1) stamp = time.time() rest = p.readline() print
>>       stamp, first+rest
>
> If I were to write it in python I'd first have to learn python, though.

True.

Python is awfully handing for banging together little tools to do
testing on embedded systems that have either serial or ethernet ports.
If you have to do that sort of stuff, learning Python might be worth
it (it's pretty easy to learn).

-- 
Grant Edwards               grant.b.edwards        Yow! Now we can become
                                  at               alcoholics!
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#13045

Fromrickman <gnuarm@gmail.com>
Date2013-08-07 23:25 -0400
Message-ID<ktv32q$gc4$1@dont-email.me>
In reply to#13010
On 8/6/2013 3:33 PM, Tim Wescott wrote:
> On Tue, 06 Aug 2013 18:48:32 +0000, Grant Edwards wrote:
>
>> On 2013-08-06, Tim Wescott<tim@seemywebsite.really>  wrote:
>>
>>>> http://elinux.org/Grabserial
>>>
>>> Grant, that's about as perfect as a command-line utility can get.  It
>>> does just what I want, and the command-line clunkiness doesn't intrude
>>> too badly.  It's going to save me tons of time over having to write
>>> something.
>>
>> Well, it'll save you a few minutes over having to write something
>>
>> ;)
>>
>>
>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>    9600)
>>    while 1:
>>        line = p.readline() print time.time(),line
>>
>> In that version, the timestamp is associated with the end of the line.
>> If you want the timestamp for the start of the line, it's a bit more
>> complicated:
>>
>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>    9600)
>>    while 1:
>>        first = p.read(1) stamp = time.time() rest = p.readline() print
>>        stamp, first+rest
>
> If I were to write it in python I'd first have to learn python, though.
>
> This is better.

I'm a fan of Forth.  It is a general purpose language with nice 
debugging features.  The learning curve is not so much the language as 
the philosophy.  It is really very nice and highly interactive which is 
a big advantage when doing something like a script.

-- 

Rick

[toc] | [prev] | [next] | [standalone]


#13047

FromJohn Devereux <john@devereux.me.uk>
Date2013-08-08 08:44 +0100
Message-ID<87a9kswrr9.fsf@devereux.me.uk>
In reply to#13045
rickman <gnuarm@gmail.com> writes:

> On 8/6/2013 3:33 PM, Tim Wescott wrote:
>> On Tue, 06 Aug 2013 18:48:32 +0000, Grant Edwards wrote:
>>
>>> On 2013-08-06, Tim Wescott<tim@seemywebsite.really>  wrote:
>>>
>>>>> http://elinux.org/Grabserial
>>>>
>>>> Grant, that's about as perfect as a command-line utility can get.  It
>>>> does just what I want, and the command-line clunkiness doesn't intrude
>>>> too badly.  It's going to save me tons of time over having to write
>>>> something.
>>>
>>> Well, it'll save you a few minutes over having to write something
>>>
>>> ;)
>>>
>>>
>>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>>    9600)
>>>    while 1:
>>>        line = p.readline() print time.time(),line
>>>
>>> In that version, the timestamp is associated with the end of the line.
>>> If you want the timestamp for the start of the line, it's a bit more
>>> complicated:
>>>
>>>    #!/usr/bin/python import serial,time p = serial.Serial('/dev/ttyS1',
>>>    9600)
>>>    while 1:
>>>        first = p.read(1) stamp = time.time() rest = p.readline() print
>>>        stamp, first+rest
>>
>> If I were to write it in python I'd first have to learn python, though.
>>
>> This is better.
>
> I'm a fan of Forth.  It is a general purpose language with nice
> debugging features.  The learning curve is not so much the language as
> the philosophy.  It is really very nice and highly interactive which
> is a big advantage when doing something like a script.

Python is interactive too, or can be (ipython).

Quite a nice environment for data manipulation, plotting etc.

<http://ipython.org/>
<http://matplotlib.org/>
<http://www.numpy.org/>



-- 

John Devereux

[toc] | [prev] | [next] | [standalone]


#13049

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-08 12:57 +0000
Message-ID<ku04jr$jur$1@reader1.panix.com>
In reply to#13047
On 2013-08-08, John Devereux <john@devereux.me.uk> wrote:

> Quite a nice environment for data manipulation, plotting etc.
>
><http://ipython.org/>
><http://matplotlib.org/>
><http://www.numpy.org/>

Python is brilliant for doing data analysis and visualization, and
there is a large scientific/engineering computing community.  Back
when I did things like curve fitting and surface triangulation for
calibrating various sorts of sensors, I used Scientific Python and
SciPy (two different, somewhat competing, libraries). I higly
recommend both:

http://www.scipy.org/
https://sourcesup.renater.fr/projects/scientific-py/

FWIW, I found gnuplot-py to be easier to use for sophisticated plots
than matplotlib, but that's probably just because I already had 15
years experience using gnuplot:

http://sourceforge.net/projects/gnuplot-py/
http://gnuplot-py.sourceforge.net/

If you want everything all bundered together, Enthought provides
Python distributions bundled with a pretty complete set of scientific
and data visualization libraries:

https://www.enthought.com/

I haven't used it for a couple years, but it's especially nice if you
have to make something work on Windows.  [If you're using a decent
Linux distro, then there should already be native packages for most of
what's included in Enthought's distribution.]

-- 
Grant Edwards               grant.b.edwards        Yow! I KAISER ROLL?!
                                  at               What good is a Kaiser Roll
                              gmail.com            without a little COLE SLAW
                                                   on the SIDE?

[toc] | [prev] | [next] | [standalone]


#13022

FromClifford Heath <no.spam@please.net>
Date2013-08-07 22:42 +1000
Message-ID<xgrMt.1627$7K3.791@fx07.iad>
In reply to#13009
On 07/08/13 04:48, Grant Edwards wrote:
> If you want the timestamp for the start of the line, it's a bit more
> complicated:
>    #!/usr/bin/python
>    import serial,time
>    p = serial.Serial('/dev/ttyS1', 9600)
>    while 1:
>        first = p.read(1)
>        stamp = time.time()
>        rest = p.readline()
>        print stamp, first+rest

Does Python's serial object put the line into raw mode so you can get 
the first character before the linefeed is sent? or did you miss that?
Just curious, not nit-picking.

[toc] | [prev] | [next] | [standalone]


#13027

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-07 15:02 +0000
Message-ID<kttni9$e1e$1@reader1.panix.com>
In reply to#13022
On 2013-08-07, Clifford Heath <no.spam@please.net> wrote:
> On 07/08/13 04:48, Grant Edwards wrote:
>> If you want the timestamp for the start of the line, it's a bit more
>> complicated:
>>    #!/usr/bin/python
>>    import serial,time
>>    p = serial.Serial('/dev/ttyS1', 9600)
>>    while 1:
>>        first = p.read(1)
>>        stamp = time.time()
>>        rest = p.readline()
>>        print stamp, first+rest
>
> Does Python's serial object put the line into raw mode so you can get 
> the first character before the linefeed is sent? or did you miss that?
> Just curious, not nit-picking.

Yes.  The port defaults to raw mode (8,none,1).  The author of
pyserial is an embedded systems developer who (I believe) wrote it to
support a set of tools used for downloading/testing/debugging
microcontroller-based widgets that had serial ports.  Since that's
mainly what I use it for, I find pyserial pretty much always defaults
to doing the "right" thing.

What it doesn't do is deal with the UARTs RX FIFO threshold setting or
the Linux tty layer's low_latency flag.  If you're using a UART with a
large FIFO (e.g. 128 bytes), the incoming lines of text are short,
don't have significant gaps between them, and you care about
millisecond accuracy, then you'll need to go to some extra work to
select a low rx FIFO threshold and set the low-latency flag on the
device using something like the setserial utility (or the underlying
ioctl() call that it uses).

-- 
Grant Edwards               grant.b.edwards        Yow! DIDI ... is that a
                                  at               MARTIAN name, or, are we
                              gmail.com            in ISRAEL?

[toc] | [prev] | [next] | [standalone]


#13030

FromGrant Edwards <invalid@invalid.invalid>
Date2013-08-07 15:15 +0000
Message-ID<kttob1$b0l$1@reader1.panix.com>
In reply to#13027
On 2013-08-07, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2013-08-07, Clifford Heath <no.spam@please.net> wrote:
>> On 07/08/13 04:48, Grant Edwards wrote:
>>> If you want the timestamp for the start of the line, it's a bit more
>>> complicated:
>>>    #!/usr/bin/python
>>>    import serial,time
>>>    p = serial.Serial('/dev/ttyS1', 9600)
>>>    while 1:
>>>        first = p.read(1)
>>>        stamp = time.time()
>>>        rest = p.readline()
>>>        print stamp, first+rest
>>
>> Does Python's serial object put the line into raw mode so you can get 
>> the first character before the linefeed is sent? or did you miss that?
>> Just curious, not nit-picking.
>
> Yes.  The port defaults to raw mode (8,none,1).  The author of
> pyserial is an embedded systems developer who (I believe) wrote it to
> support a set of tools used for downloading/testing/debugging
> microcontroller-based widgets that had serial ports.  Since that's
> mainly what I use it for, I find pyserial pretty much always defaults
> to doing the "right" thing.

I forgot to post a link to the pyserial project:

http://pyserial.sourceforge.net/

Pyserial isn't part of the Python standard library, but I think most
Linux distros have a package for it -- even if they don't, installing
only requires a couple commands.

-- 
Grant Edwards               grant.b.edwards        Yow! PARDON me, am I
                                  at               speaking ENGLISH?
                              gmail.com            

[toc] | [prev] | [next] | [standalone]


#13042

FromClifford Heath <no.spam@please.net>
Date2013-08-08 08:50 +1000
Message-ID<RaAMt.9006$Ag2.6191@fx04.iad>
In reply to#13027
On 08/08/13 01:02, Grant Edwards wrote:
> Yes.  The port defaults to raw mode (8,none,1).

Right, nice.

> What it doesn't do is deal with the UARTs RX FIFO threshold setting or
> the Linux tty layer's low_latency flag.

I've done that at the C level (CMIN, CTIME, etc). Even got the developer 
to fix a driver bug I found in the low_latency implementation. Seems 
like a lifetime ago.

My scripting language of choice is Ruby, but it's been a long time since 
I did any serial port things with it, and I think for someone choosing a 
scripting language to support embedded work, Python is probably better 
because it has more users in that community.

One technique I've used in serial port work is to use separate threads 
for input and output. You have to synchronise, but it's nicer than using 
select().

Clifford Heath

[toc] | [prev] | [standalone]


Back to top | Article view | comp.arch.embedded


csiph-web