Hello.
I’m working on a VirtualSerial driver.
I start from “Virtual serial driver sample” of “windows-driver-kit-81-cpp.zip” and run without modification.
I’m able to install and debug example on VMware Windows 7 virtual machine.
After running, driver example create a new COM port (COM12 on my PC).
If I open virtual COM port from some serial port terminal (Hercules for example) every thing it’s ok.
I got problems if I open COM port from my own Java program or my owm VB.Net program.
VB.Net cannot open COM port (I got problem with SerialPort.Open).
I think Microsoft VirtualSerial example is bugged. I wrote to Microsoft support but I got no usefull reply.
This is source code of my Console application example:
Imports System.IO.Ports
Imports System.Threading
Imports sql.lhr.net
Module Module1
Dim uartReceived As Boolean
Dim _serialPort As SerialPort
Sub Main()
’ Create a new SerialPort object with default settings.
_serialPort = New SerialPort()
’ Allow the user to set the appropriate properties.
_serialPort.PortName = “COM12”
_serialPort.BaudRate = 115200
_serialPort.Parity = IO.Ports.Parity.None
_serialPort.DataBits = 8
_serialPort.StopBits = 1
_serialPort.Handshake = Handshake.None
’ Set the read/write timeouts
_serialPort.ReadTimeout = 500
_serialPort.WriteTimeout = 500
Dim ret() As Byte = UserDefinedFunctions.CreateTransport(1, 0, UserDefinedFunctions.CreateSimplyMxpPacket21(1234567890123456, UserDefinedFunctions.CreateMxpCommand2(2, 0, hexStringToByteArray(“0x”), 1), 1, 0), 2)
Console.WriteLine(“Open COM12”)
_serialPort.Open()
uartReceived = False
Console.WriteLine("Write: " + ret.ToString)
_serialPort.Write(ret.ToString)
Console.WriteLine(“Wait for receive”)
While (Not uartReceived)
End While
Console.WriteLine(“Received”)
Console.WriteLine(“Close COM12”)
_serialPort.Close()
End Sub
End Module