|
![]() |
How to Analyze RS232 Serial CommunicationsWhen working with RS232 serial communications the ability to analyze the data stream is important in a variety of situations. If you are developing a serial protocol an RS232 analyzer or serial port spy can save you hours of troubleshooting and if used from the start of your project gives you the ability to catch and correct problems early in the development cycle. Trying to reverse engineer or debug an RS232 protocol is virtually impossible to do without one of these tools.But which tool is better suited for the job an RS232 analyzer or a serial port spy? Although both tools are extremely useful and allow you to analyze RS232 data flows, they utilize very different methods and each has its own advantages and drawbacks. This article describes both approaches to help you pick the best tool for your situation. RS232 Analyzer:This approach utilizes both software and special hardware to provide byte level analysis of the rs232 line. There are several different hardware/software options out there but typically this type of solution requires a specially wired cable and a PC with two available rs232 ports. The cabling is designed to tap on all the RS232 signals and utilizes the receive pins of the serial ports to correctly analyze bidirectional data.This setup gives you a byte level analysis of what is physically occurring on the serial link. The RS232 analyzer records and time stamps the data, changes to the signal lines, and line status errors while the transmission is occurring. Since the data is being collected at the byte level you are able to inspect the inter character timing between events exactly as they were recorded on the line. The benefit to this approach is that you can view exactly how the data was transmitted on the RS232 line along with the timings between events. An RS232 analyzer is the tool you want to use when you are in a situation where you need to prove who sent what. You can also analyze a link between any two RS232 devices including two embedded systems. The drawback is that you need to break your RS232 link to insert the cable which can be difficult if you are working with a remote user in the field. Serial Port Spy:This approach utilizes a special filter driver that inserts itself into the operating systems driver stack. Once inserted the filter driver can passively spy all data flows between any program running on the PC and one of its serial ports. This configuration allows for a logical view of how a program interacts with the Windows serial API. As such data is captured and time stamped at the packet level as it is passed to and from the API.The benefit to this approach is that it is usually easier to configure and use. It also allows you to see things internal to the operating system that an RS232 line analyzer cannot such as API calls to open and close the serial port handle, the process id of the program using the serial port, and the baud rate being used. It also allows you to debug a link in situations where physically tapping into the serial line is impossible such as internal modems or devices that connect to the PC via USB and utilize internal USB–RS232 converters. The drawback is that a serial port spy is limited to displaying only what a program reads or writes to the API. If for some reason your program stopped making read requests it might look like the remote device stopped transmitting when in reality the Windows program stopped listening. It also requires that one of the devices in your link be a Windows PC, therefore you cannot debug two microcontrollers with this type of tool. Summary:If you were to run both tools on the same link you would see two different views of the same protocol. The RS232 analyzer would show you the real time data transmission while the serial port spy would display the sequencing and results of the Windows programs API calls.In general an RS232 analyzer is better suited to tackle a wider range of problems since it displays what physically happens on the serial link but the convenience of a serial spy and its ability to give you a logical view of how your program is interacting with the Windows API is very beneficial to engineers who develop serial applications under Windows. Send mail to webmaster@sinnovations.com
with questions or comments about this web site.
|