Timeout exception when writing to virtual COM
I am trying to write to a COM port using .NET sample
I have no problem writing to real COM, but when I try to write to virtual COM I get a timeout exception
Unhandled Exception: System.TimeoutException: Recording timed out. at System.IO.Ports.SerialStream.Write (Byte [] array, Int32 offset, Int32 count, Int32 timeout) at System.IO.Ports.SerialPort.Write (line text) at System.IO.Ports.SerialPort.WriteLine ( line text)
I searched for this issue and found this . according to what said this is the problem:
Function.net write () uses CreateFile and WriteFile Async like this:
CreateFile("\\\\.\\" + portName,
NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE,
0, // comm devices must be opened w/exclusive-access
IntPtr.Zero, // no security attributes
UnsafeNativeMethods.OPEN_EXISTING, // comm devices must use OPEN_EXISTING
FILE_FLAG_OVERLAPPED,
IntPtr.Zero // hTemplate must be NULL for comm devices
);
WriteFile(_handle, p + offset, count, IntPtr.Zero, overlapped);
when i used the ones that had NULL instead of FILE_FLAG_OVERLAPPE
My question is, how can I solve this problem? do i need to write my own code?
source to share
No one has answered this question yet
See similar questions:
or similar: