Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, i have implemented COM port communication using System.IO.ports serilPorts (RS 232) to send and receive data to port. During receive the response,
SerialDataReceivedEventHandler
doesn't get any value and leads to application crash, malfunction.

when i gone through many cases win32 is better than serialport. i have decided to implement win32 over serialport.

can you please provide me steps to implement win32 in C# to send and receive data from the COM port.

What I have tried:

i didnt find any idea about win32 serial.
Posted
Updated 11-May-20 2:53am
Comments
[no name] 11-May-20 5:56am    
My experience is, that the c# SerialPort class is very reliable.
Richard MacCutchan 11-May-20 6:07am    
You first need to diagnose why the crash occurred in your code.
Dave Kreskowiak 11-May-20 10:45am    
Why would you want to do that when the .NET classes are doing that exact thing for you already? The .NET classes just wrap the Win32 serial port functionality. You would be rewriting all that code yourself.

1 solution

I would first do as Richard MacCutchan says in the comments "
Quote:
You first need to diagnose why the crash occurred in your code.


Then, if your code is working and it turns out there's a speed issue, there are things you can do .. this for instance Improving the Performance of Serial Ports Using C#[^] (this is from his series here Dotric Pty Ltd - Software[^] )

See also : If you *must* use .NET System.IO.Ports.SerialPort | Hardware, Software & Product Development | Sparx Engineering[^]

My point is it's easy to say the existing .NET classes etc are deficient in some way, and I want to re-write it for myself - by that is a hell of a lot of work - Interesting have been in this position the best way we ended up fixing the speed issues were to attach a proprietary dongle to the serial port of the device and handle reading it with MODBUS over TCP/IP
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900