2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址:https://www.aliyun.com/minisite/goods
入口地址:https://www.aliyun.com/minisite/goods
We are trying to connect two Hyper-V VMs through a serial port. Hyper-V exposes the serial port as a named pipe to the host system, and implements the server end of the named pipe. Consequentially, to connect them, we need to write a named-pipe client which connects to both VMs, and copies the data back and forth.
Find out how to add COM ports to Hyper-V and access serial ports from within the VM. Document the named pipe path shown by Hyper-V. Hyper-V provides data from a named pipe into the VM as a COM port, as you show above. Hyper-V, rather unhelpfully, does not connect that named pipe to the host's COM port, which is what you would need to pass the data through to your VM. I just wrote a Windows program that runs on the host OS and provides a link between the host COM port and the named pipe, allowing you to use the host COM port from your Ubuntu VM.
We have written such an application. Unfortunately, this application loses data.
If we connect two hyperterms, and have them exchange data, the transmission sometimes succeeds, but in many cases, the receiving end reports errors, or the transmission just deadlocks. Likewise, if we use the link to run a kernel debugger, it also seems to hang often.
What could be the cause of the data loss? What precautions must be taken when connecting named pipes in such a manner?
Edit: We have worked around the problem, using kdsrv.exe. The COM port of the debuggee continues to be exposed through a named pipe, however, the debugger end talks to kdserv via TCP.
answer 1 >>---Accepted---Accepted---Accepted---
The data loss is not due to the named pipes. It is infact the COM ports (emulated and physical) that may lose data since they operate with a small buffer in the UART.
![Hyper v serial port named pipe Hyper v serial port named pipe](/uploads/1/2/6/3/126328188/771302607.png)
The named pipe receives all the data that is written to the COM port. Your program reads data from the named pipe and writes it to another named pipe. This is where data loss can originate if you write too fast the receiveing COM port's UART can overflow leading to data loss.
You may need to add some delay to avoid exceeding the baud rate expected by the receiving side.
In addition, you are missing
ResetEvent()
calls in your program.For your KD issues, you may need to add
resets=0
to the connection string.Recommend:hyper-v: read VM serial port pipe application
d the serial output. I copied a simple C# application from here to read the COM pipe and ran it as admin. static void PipeClient() { NamedPipeClientStream npc = new NamedPipeClientStream('.', 'DebianCom1', PipeDirection.InOut);
Hi,
I've created this little program to be able to have all thejoys of a serial port in most virtual machines by Microsoft.
It reads from the namedpipe created by the vm on the host andwrites that to a comport of your choice.
I've tested it on hyperv and vpc (win7)
So far I've sent and received faxes and i've made a dialupconnection. Although you should turn the logging off if youwant to enjoy the full speed of the connection.
This makes it possible in theory to virtualize your fax server.
There's also a binary release here: https://github.com/downloads/albertjan/PipeToCom/NP2COM.zip
NP2COMV is a winforms app to test and make your settings. Itallows you to save configuration files that look like this:
![Hyper V Serial Port Named Pipe Hyper V Serial Port Named Pipe](http://139.59.40.198/blog/wp-content/uploads/2008/02/vmsettings1.jpg)
Which you can later on use to configure your service:
NP2COMS is a windows service that reads n config files like aboveand creates as many named-pipe serialport connections as you want.
Enjoy,
Having problems start here: https://github.com/albertjan/PipeToCom/issues/10
Installing: (by @vibac)
Give your user full rights on the NP2COM folder after extracting it:
- Right click the NP2COM folder>properties and give your user full rights
- You can put this folder anywhere on your server, ie: C:NP2COM
Ensure that the NP2COMS general properties are unblocked:
- Right click the NP2COMS.exe>properties at the bottom hit the 'unblock' button
Register the service NP2COMS:
- After you've installed .net 3, 3.5, 4 or 4.5 you can register NP2COMS.exe as a service by applying the following cmd
Start cmd with 'run as Admin'c:windowsmicrosoft.netframeworkv4.0.30319installutil.exe -t C:NP2COMNP2COMS.exeor use run%WINDIR%Microsoft.NETFrameworkv4.0.30319InstallUtil -t C:NP2COMNP2COMS.exe
Create the Named pipe in the guest VM settings:
- Right click the vm from within the host's Hyper-V, select 'settings', then select com1 or com2, tic 'named pipe' and enter a name, ie: comport
Create a config file for NP2COMs service
- Run the NP2COMV.exe as admin to create a .n2c config file and save it in the PathToNP2COMS.exe, ie: C:NP2COM
- On the left hand side select the NamedPipe you created previously in step 4 from the drop down list, ie: .pipecomport
- Set the serial port settings to your needs, ie: baudrate 9600
- Now click 'Write config file' to save it and save it in the NP2COM location, ie: C:NP2COM
Delete the example config file
- Delete example.n2c
Start the NP2COMS service
- Run: c:>net start NP2COMService or go to services and start it
DONE!
Test communication
- Stop the NP2COM service on host
- Launch the NP2COMV.exe as admin
- Go to the guest and launch hyper terminal or putty terminal
- Once you connect to the setup COM port hit enter
- Go to the NP2COMV window on the host and see if the data is written
- Once you are done, kill the NP2COMV process then start the NP2COM service