Link to home
Start Free TrialLog in
Avatar of akohan
akohan

asked on

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?


 
Avatar of Michael Eager
Michael Eager
Flag of United States of America image

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.  

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.
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.
Avatar of akohan
akohan

ASKER


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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Michael Eager
Michael Eager
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akohan

ASKER


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!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 .
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.
Avatar of akohan

ASKER


Thank you, I will get back to you guys soon.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akohan

ASKER


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

Regards.
Avatar of akohan

ASKER

Thanks to all.  

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