• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 483
  • Last Modified:

How to verify/test the data on COM port?

Hello experts,

I have written an application using C# and it is supposed to send/receive data on COM port. Of course, I'm using a laptop and have a dongle USB to serial (USB to male DB2) and now want to verify the data coming out of computer.

What is the fastest (if accurate) solution?

Your help is appreciated greatly.


Thanks.

p.s. base on http://zone.ni.com/devzone/cda/tut/p/id/3450#toc0  I can connect pin 2 and 3 then outputted data will loop back to computer and can read it off the serial port. Any idea?


 
0
akohan
Asked:
akohan
  • 5
  • 4
  • 3
  • +2
3 Solutions
 
eagerCommented:
Using a loopback connection may turn out to be confusing.

I would suggest hooking your serial connection to a serial port on a different computer using a cross-over cable (pin 2 wired to pin 3 on the other end, and vice versa).  You can use a terminal program like minicom on Linux on the second computer to monitor output and generate input.  

0
 
Blue_-_BearCommented:
I you have two of these USB devices, you can connect both with a cross cable and read on the second virtual port what you sent on the first one.
0
 
HappyCactusCommented:
Use another pc or another program with another serial port and check the communication with different patterns.
One strategy could be using a predefined pattern, shared between the two peers; another strategy could be using a random pattern and and error checking algorithm; for example, transfer 1Mb of data and calculate the MD5 hash of it.
But what is your doubt? about the working of your hardware? about the connection?
If the connection is long or not too reliable, you could implement an error correction algorithm in your application.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
akohanAuthor Commented:

Thanks for the help. As far as error correction, what would be the issue with parity bit?
and where can I get some idea how to write a correction algorithm?

Regards.
0
 
HappyCactusCommented:
Parity bit can only detect an error on one bit. if the error affects two bits, or even the parity bit itself, it can be undetected.
checksum and crc32 can detect more subtle errors and noise; start and stop byte can synchronize the communication.
Retransmission in case of errors on crc or checksum or unsynchronized communication is the simplest way to correct errors.
But it depends on your application.
0
 
eagerCommented:
Most serial port connections are set up as 8N1 -- 8 bits data, NO parity, 1 stop bit.
Don't worry about parity; it usually is not used.  

First, verify that your serial connection is working, then worry about checksums or CRC. Depending on what you are doing, you may not need this.
0
 
akohanAuthor Commented:

Yes, it is working and sends the data on pin .. what I'm doing is as following:

1) sending specific information to a board (FPGA). Each fpga has different elements e.g. DSP module, RAM, and etc...

2) there will be a controlling code on board which redirects the data (coming from rs232) on selected element let's say DSP module to do a calculation or to Memory to read/write data from/to it.

The point is that the wire can be long 6 ~ 8 feet. I like to ensure data will be on board intact.

Thanks!
0
 
eagerCommented:
The most common way that serial communication is handled in your kind of application is to create a data transfer protocol.  This might involve codes which describe the kind of data or the kind of operation, the length of the data, and end with a checksum or CRC value for the message.  

Take a look at the GDB remote protocol, which is designed for bidirectional serial connections: http://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html

BTW, unless you have a very noisy environment with a lot of EMF, your RS-232 levels are marginal, or you use really crappy cables, you won't see any problems with transferring data 6-8 feet.  RS-232 handles distances of 50 feet easily and much longer with special cables.  
0
 
HappyCactusCommented:
eager, it depends on speed. On embedded / industrial world you cannot rely on "goodness" or lenght of cable.

akohan, implement a packet transfert with an error detection (1 or 2 bytes checksum or crc32), a start and stop byte. All industry level serial protocols to that. Use low speeds, 9600 if possible, or 38400 max. Parity is used sometime, but it's not very reliable. Use good, shielded cables, and a good earth connection. If needed, 422 or 485 connection are available for longer and noisy connections .
0
 
eagerCommented:
I work in the embedded world.  6-8 feet is not a problem, even at 115,200 bps, unless there is EMF.  Shielded cable is always a good idea.
0
 
akohanAuthor Commented:

Thank you, I will get back to you guys soon.
0
 
aloisiop1Commented:
You can use a sniffer  program to verify if that data are  going to out ..

Try RealTerm, It´s a great software
0
 
akohanAuthor Commented:

Thanks but I have to write it myself ... cannot use third part software but I appreciate sharing it.

Regards.
0
 
akohanAuthor Commented:
Thanks to all.  

Aloisiop1, I noticed the link you sent also offers the source code.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now