Net Serialport Frame Error
Contents |
Libraries Question 0 Sign in to vote Hi there.I wrote a simple application in C#, using the SerialPort in the .Net Framework 2.0, which receives some data via the serial port. The data it receives is incorrect, though. I compared it to
C# Serial Port Example
the data received by an Delphi app, which I received for testing purposes, and very basic .net serial port library VB6 app, which I wrote using the MSComm control.Examples :Correct values (Received in Delphi & VB6 Apps) :91 01 01 03 48 48 50 c# serial port readasync 69 66 51 70 55 52 93 (14 bytes)Incorrect values (Received in C# App) :91 241 254 252 242 146 42 201 51 70 55 52 93 (13 bytes)As you can see the first byte and the last five bytes
C# Serial Port Asynchronous Read
correspond.Recently, I checked the ErrorReceived and PinChanged event of the SerialPort. For every DataReceivedevent an ErrorReceived event fires which stated that a framing error has occurred. The PinChanged event also fired numerous times for each DataReceived event, but I would assume that that in itself does not indicate a problem.That leaves me with the question : why would the SerialPort class encounter a framing error while the other apps apparently did not ? Tuesday, October 07, 2008 5:16 PM Reply
Serialport Basestream Readasync
| Quote Answers 1 Sign in to vote Well, that's all fairly mysterious. Some embedded devices derive serial port chip power from the handshake lines. DTR is a popular choice. Lord knows what happens if it is off. Seeing RING jiggle that much is definitely not normal nor healthy. It will give the driver a pretty bad headache, for one. You'd better check the cabling, digging up a scope somewhere is highly recommended. Hans Passant. Marked as answer by Zhi-Xin Ye Monday, October 13, 2008 8:34 AM Wednesday, October 08, 2008 11:05 PM Reply | Quote Moderator All replies 1 Sign in to vote Seeing the PinChanged event fire a lot is definitely not normal. Could be SerialPinChanged.Break but you would have to have a really gross framing error to get that.Let's assume the Baudrate setting is in the ballpark, at least some bytes resemble each other. You are missing a byte in the 2nd sequence, that's consistent with a framing error. Check the StopBits, DataBits and Parity properties and ensure they match the device. Hans Passant. Wednesday, October 08, 2008 10:43 AM Reply | Quote Moderator 0 Sign in to vote Hi there.First off, thanks for the reply, it is appreciated.It seems as if the problem has been resolved, after nearly a month of headscratching and teeth-gnashing.I compared logs generated on Portmon by the VB app and the C# app and found along with a few other
peripheral devices, I use serial data streams a lot. Mostly USB virtual serial posts from FTDI, but also the USB Communication Device Class and real 16550-compatible UARTs on the PCI c# serial port datareceived bus. Since looking at data through an in-circuit emulator debug interface is generally
Ben Voigt Serial Port
a miserable experience, getting serial data communication with a custom PC application is essential to analyzing data quality and providing c# serial port alternative feedback on hardware designs. C# and the .NET Framework provide a rapid application development that is ideal for early development that needs to track changing requirements as hardware designs evolve. Ideal in most respects, https://social.msdn.microsoft.com/Forums/vstudio/en-US/a45a079f-64b8-457e-a061-c327e7d8a1a5/serialport-framing-error?forum=netfxbcl I should say. The System.IO.Ports.SerialPort class which ships with .NET is a glaring exception. To put it mildly, it was designed by computer scientists operating far outside their area of core competence. They neither understood the characteristics of serial communication, nor common use cases, and it shows. Nor could it have been tested in any real world scenario prior to shipping, without finding flaws that litter both http://www.sparxeng.com/blog/software/must-use-net-system-io-ports-serialport the documented interface and the undocumented behavior and make reliable communication using System.IO.Ports.SerialPort (henceforth IOPSP) a real nightmare. (Plenty of evidence on StackOverflow attests to this, from devices that work in Hyperterminal but not .NET because IOPSP makes setting certain parameters mandatory, although they aren’t applicable to virtual ports, and closes the port on failure. There’s no way to bypass or ignore failure of these settings during IOPSP initialization.) What’s even more astonishing is that this level of failure occurred when the underlying kernel32.dll APIs are immensely better (I’ve used the WinAPI before working with .NET, and still do when I want to use a function that .NET doesn’t have a wrapper for, which notably includes device enumeration). The .NET engineers not only failed to devise a reasonable interface, they chose to disregard the WinAPI design which was very mature, nor did they learn from two decades of kernel team experience with serial ports. A future series of posts will present the design and implementation of a rational serial port interface built upon, and preserving the style of, the WinAPI serial port functions. It fits seamlessly into the .NET event dispatch model, and multiple coworkers have expressed that i
/ Firmware Product Bulletins Warranty Policy & Procedure Spares Program xPrintServer – Compatible Printer Lists Skip Navigation Scripting must be enabled to use this site. Log In|Sign Up http://ltxfaq.custhelp.com/app/answers/detail/a_id/85/~/serial-port-framing-errors Username Password Forgot your username or password? Support Home Answers Ask a Question My Stuff Account Overview Support History Account Settings Notifications Serial Port Framing Errors Published 07/01/1999 11:35 AM | Updated 03/25/2014 05:08 PM When I check the device port status on a Lantronix serial device server I see that I have Framing Errors. What might be causing this? Framing errors normally occur: with baud rate serial port mismatches when the serial line is very long or when there is a lot of electrical noise on the serial cable Framing errors can also occur if there is no serial ground connection between the two connected serial devices, or if the connection is intermittent or has a high impedance, e.g. because one or both ends are not well connected. This can cause noise on the serial line, c# serial port resulting in framing errors. Background: Asynchronous serial data received by a UART has an additional start bit and a stop bit.The start and stop bits are periods of silence between each character on an asynchronous serial connection, e.g. RS232, RS422 or RS485. At a specific serial speed each bit of data takes a single "bit time" to be transmitted. E.g. at 9600 bits per second the bit time is 1/9600 = 0.000104 seconds, or 104 microseconds. This is the bit time. For instance, if data bits is set to 8, parity is set to none and stop bits is set to 1 (8N1) eachcharacter of data is 10 bit timeslong. The stop and start bits "frame" the data. A framing error occurs when acharacter of data received by the serial port is too long or too short, i.e. has too many or too few bit times between start and stop bits. For instance, at 9600, 8N1 each character should be 104 microseconds * 10 bit times = about 1.04 milliseconds in length. (1040 microseconds = 1.04 milliseconds). Was this answer helpful? Yes No Please tell us how we can make this answer more useful. Email *Required Your Feedback *Re