I am looking for a way to have as much control over a serial port in my C # application. The problem is that I need to communicate with a device that does not have documentation, except for the old C ++ program written to control it. I tried to use the SerialPort class to communicate with the device, but its behavior is rather strange (I need to repeat some commands, some other commands do not work at all). I would like to copy this uncontrolled behavior of the program, however, it seems that this is not possible with the serialport class, since it does not provide access to low-level functions and structures, such as DCB.
Are there any low level serial communication wrappers available for .net? Maybe I could use reflection to manipulate irreconcilable serialport members at runtime?
For those who offer to look at the .NET SerialPort class; Ben Voigt, a frequent stack overflow answer provider for Serial related questions, provides some excellent insights into why the wrapper around WinAPI will end up being a much better idea than using the environment provided by SerialPort:
Ben Voigt at .NET SerialPort
A must be read.
WinAPI, . , .
, , , , .
:
, -, , .NET SerialPort... , Win32 API .
, MSDN .
" P/Invoke .NET ", 2002 MSDN, :
, Microsoft, , 2003 :
FWIW, - ...
, SerialPort . , DCB - .
- SerialPort . ().
, , RTS_CONTROL_TOGGLE: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/45a89532-b01c-4ef8-aa46-532882cec004
SerialPort - API- Win32, , . , .NET 1.x , . MSDN.
. , ( ), RTS. , Handshake RequestToSend.
- Read(). , . , , . , 1 , .
SysInternals PortMon , , . , , Hyperterminal .
PInvoke . Silverlight, .NET. Silverlight 5 (COM-) , . WinAPI, , ++.
P.S. , PortMon, , .
Perhaps you can copy the old C ++ code into a managed C ++ class, which can then be used, like any regular .NET class, from your C # code. This may be the fastest way to achieve your goal.
Source: https://habr.com/ru/post/1756191/More articles:info button user close button - javascriptNavigation incorrectly placed in html / css - htmlHow do I complete this runoff step? - databaseEntity Framework 4 Code First Custom Table Mapping Issues with Fluent API - c #What is the java unit test library for http? - javaWhat is the C # analog of C fread ()? - chow to get client IP address using C # socket programming - c #Android - request if synchronization account is synchronized for synchronization - androidSilverlight MVVM: How to do localization correctly? - silverlightClojure: gen-class and double arrays - clojureAll Articles