Author Topic: Serial Port Sniffer & 9th bit support  (Read 46108 times)

mduarte

  • Member
  • ***
  • Posts: 3
Serial Port Sniffer & 9th bit support
« on: March 21, 2012, 01:37:08 am »
Hello !

I need to start some research creating a serial port sniffer to analyze a specific protocol (I mean.. spy an existing rs232 serial protocol between two serial devices).  I have read a lot about 9th bit on windows, so I want to change the device.

I was thiking to use Arduino forthis purpose. So I have the following questions I hope somebody may help me :

- Does arduino supports to have two different serial ports opened and listen them ?
- The Rs232 serial protocol I need to analyze is very strict and special: 5ms interbyte timming, and 9th bit set on first byte to determine packet start.
  Does arduino UART support 9th bit detection/set ??   What about the interbyte timming, do you think arduino processor would be fast enough to manage it ?

- Do you think I can have the same results if I use Netduino instead Arduino ?

- BTW, do you have any libray/code I can use to implement 9th bit on PC-UART (I just need to determine if first byte has 9th bit set, but with parity replacement I cannot get it works)


Thanks in advance for your guidelines ! 



GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Sniffer & 9th bit support
« Reply #1 on: March 21, 2012, 09:05:20 am »
Hi,

I have used AGG softs Advanced Serial Port Monitor with mixed results I have not tried to read 9 bit data with it, but it should or else AGG will be able to guide you web site is www.aggsoft.com/serial-port-monitor.htm
Also  I have used Free Serial Port Monitor from HDD soft at www.serial-port-monitor.com/index.html again I have not used for 9 bit data, but you might get lucky....

Glenn

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Sniffer & 9th bit support
« Reply #2 on: March 21, 2012, 10:10:18 am »
I have links to serial-port software tools here:

http://www.lvr.com/serport.htm#software

For Arduino-specific questions, an Arduino forum might be the best place to ask:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl

Jan

mduarte

  • Member
  • ***
  • Posts: 3
Re: Serial Port Sniffer & 9th bit support
« Reply #3 on: March 21, 2012, 02:30:15 pm »
Thank you for your fast responses!

Maybe I have no explained my need pretty well. I already have a external software to monitor the communications between two serial port devices like AGG softs Advanced Serial Port Monitor.

The think I need to resolve is that right now I need to do something by myself.  I am not thinking to reinvent the wheel, because I only need to get working the following data flow:

 For each byte coming from Serial Port 1 =>  Store each byte into internal memory and read 9th bit status => redirect the byte to Serial Port 2

Each time I detect a packet end (in my case is with an interbyte timeout greather than 5ms), I need to move the byte array stored at internal memory and send it back to be parsed later on (maybe to a text file, through another serial port, etc) and clear it to next incoming packet.

The effort on development I suppose it is going to be only in the offline parser, not in the serial port pass through. For the offline parser is where I need to be able to retrieve the 9th bit status it had on arribe.

What kind of architecture can you recommend us to implement that feature ?  (pc with dos, windows or linux, PIC, Arduino, etc.etc.)
 
Thanks!

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Sniffer & 9th bit support
« Reply #4 on: March 22, 2012, 01:14:55 pm »
I take it English is not your first language, as I am having a little trouble following your reply, but I will try.  You need to read eight bytes, the next byte is used to switch to the next Serial port and not really used for data (i.e. 0 for stay the same 1 for switch) ? As for the architecture why do you ask, Jan's examples are targeted toward Windows and Vis studio with PIC being the Embedded platform, however Linux & Arduino, PC running DOS can do it as well.  In my own view Windows C# & Microchip's PIC family are a good starting point, lots of users good help.
"The effort on development I suppose it is going to be only in the offline parser, not in the serial port pass through. For the offline parser is where I need to be able to retrieve the 9th bit status it had on arribe."  So the job is an offline parser?  So if I get what you are saying the data could look like
                                       111111111,222222222,3333333,44444444,55555555,666666,7777777,88888888,0000001
coming in via Com1 (11111111, is the first byte)

so the data stored is:
11111111
22222222
33333333
44444444
55555555
66666666
77777777
88888888
00000001

the 00000001 causes the port to switch to Com2 ?  Could you not then step through it using an array or RegEx type expression.  Seem to less about comms and more about handling data. Sounds an awful lot like a Uni Assignment to me! :)
       
 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Sniffer & 9th bit support
« Reply #5 on: March 22, 2012, 05:16:45 pm »
Mark and Space parity can be used as a 9th bit in .NET. However, this may be too slow if your goal is to monitor traffic you don't have control over.

Jan

mduarte

  • Member
  • ***
  • Posts: 3
Re: Serial Port Sniffer & 9th bit support
« Reply #6 on: March 26, 2012, 11:28:36 am »
GlennP / Jan,  thanks for your response.  you're right english is not my first language  ;)

What I need to do is similar to what you has explained jan. Let's suppose the following packet is arriving from COM2 :

{ 0x01,0x10,0x030,0x40 }   ( I am going to determine when the packet is completed checking the interbyte timeout, the brackets are just used here to delimit the whole packet content).

I need to store the packet content (for example in flat text mode) to analyze later on, adding to the packet an identifier (or whatever I choose) only if the first byte (0x01) has set the 9th bit, for example:  { *,0x01,0x10,0x030,0x40 }

The analysis process and how to store the packet content in fact is out of what I need because I know how to resolve it. What I didn't know how to handle was to determine if a specific byte has set the 9th bit or no. That's all ;-)

Because as far as I know, under windows it is not possible to determine it accurately and fast enough as you read each byte, so I was trying to have opinions about what different architecture I can use.  (maybe you have some c++ code which allows me to read the 9th bit status under windows)

I hope this post is more clear the previous one. Sorry about the misunderstandings!
Marcelo





Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Sniffer & 9th bit support
« Reply #7 on: March 26, 2012, 02:03:18 pm »
I don't have a specific recommendation, but a search on:

windows serial port "9-bit" driver

will turn up various discussions and tools.

Jan

GlennP

  • Frequent Contributor
  • ****
  • Posts: 141
Re: Serial Port Sniffer & 9th bit support
« Reply #8 on: April 10, 2012, 05:47:23 am »
Umm Hi,

Looking for something else I came across this:

http://www.codeproject.com/Articles/75770/Basic-serial-port-listening-application

Might be what is wanted?


Glenn

KJB

  • Member
  • ***
  • Posts: 1
Re: Serial Port Sniffer & 9th bit support
« Reply #9 on: August 13, 2014, 11:26:34 am »
mduarte - You mention in one of your posts that you had found a serial port monitoring tool that allowed monitoring serial port communications using 9 bit data.  Do you mind sharing which tool (website) you found?  I've been searching and most tools out there don't support capturing 9 bit serial data.

Thanks!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Serial Port Sniffer & 9th bit support
« Reply #10 on: August 13, 2014, 08:41:57 pm »
Did you try AGG soft?