Main menu:

Site search


Search the web


Categories

February 2010
S M T W T F S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28  

Archive

Hyper-V Serial Ports and Windows 2008

Unlike many other virtualization solutions, it’s not particularly easy to connect a Windows 2008 Hyper-V guest to its host serial ports.  Perversely, there are settings to connect the guest COM ports to “named pipes,” but there’s no way on the host to connect COM ports to named pipes.  (It appears that this option is used primarily for debugging programs, rather than for using actual serial ports — it doesn’t appear to have been intended to be used to provide actual serial port access from the guest.)

The Hyper-V Deployment guide contains little more than this:

“Note:  No access to a physical COM port is available from a virtual machine.”

What follows is a recipe to access the physical COM ports on the host from a guest using com0com, and its related utilities.  The idea is to make a COM port on the host available via TCP/IP, and then attach to it via the guest, then make this process automatic.

First, on the guest, you’ll need an appropriate version of hub4com, and the batch file bundled with it, com2tcp-rfc2217.bat.  Naturally, I’m running 64-bit Windows 2008, and there doesn’t appear to be a version compiled for 64-bit Windows, so I had to compile my own.  This can be kind of a pain, especially if you’re using Visual Studio Express, so you’re welcome to download my 64-bit hub2com binaries here.

My device is on COM3, and I can make it available on port 7000 using the following command line:

com2tcp-rfc2217 COM3 7000

This gives me a DOS Window that shows me what’s going on — this is handy for debugging, but hardly something I want to leave on my screen all the time.  The simplest solution is to create a launcher script:

Set objShell = CreateObject ("WScript.Shell")
objShell.Run "cmd /K CD C:\Program Files (x86)\com0com & com2tcp-rfc2217 COM3 7000", 0, false

This script effectively hides the program so that it can run in the background, so all that remains is to have it launch when the system starts.  That’s best accomplished using the registry to create a new “Expandable String Value” under “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run”.  It doesn’t matter what the Name of the String Value is, but the Data should be the command line necessary to launch the script:

%WinDir%\system32\wscript "C:\Program Files (x86)\com0com\com3-listen.vbs"

When done this way, the port is made available whether or not anybody is actually logged into the machine.

The guest is only slightly trickier, requiring both com0com and hub2com binaries to be installed.  Since my guest is 32-bit Windows XP, I could use the precompiled “i386″ binaries directly from the c0m0com sourceforge page.

The com0com installer wants to create a null modem pair from “cnca0″ to “cncb0.”  You’ll need this pair of virtual devices, and you’ll want to turn on “baud rate emulation,” and rename one end like a regular COM port.    This can be accomplished from the com0com command line setup:

install EmuBR=yes EmuBR=yes
change CNCA0 PortName=COM3

Once the virtual port pair is available, one end can be connected to the host, using the hub2com batch file com2tcp-rfc2217:

com2tcp-rfc2217 \\.\CNCB0 host-hostname 7000

As before, this opens a DOS Window where you can see what’s going on.  At this point, COM3 on the guest is communicating directly with COM3 on the host.  As before, a small launcher script is created to hide this window:

Set objShell = CreateObject ("WScript.Shell")
objShell.Run "cmd /K CD C:\Program Files\com0com & com2tcp-rfc2217 \\.\CNCB0 skypiea 7000", 0, false

And, as before, a registry string is added to the guest to launch this automatically in its own “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run” key.

%WinDir%\system32\wscript "C:\Program Files\com0com\com3-client.vbs"

Simple, eh?  Well, perhaps not, but once it’s set up, the guest Hyper-V machine can communicate via COM3.  Additional ports can be added in the same way.

  • Share/Bookmark

SIIG Cyber Serial under Windows 2008, or getting old drivers to work

I’m in the process of “upgrading” a server from Windows 2003 server to Windows 2008 server, and one of the things this server does is manage a few serial devices.  Therefore, it contains an old PCI serial board, but the manufacturer has since moved on to newer hardware, and hasn’t bothered to update the drivers.

Trying to install the Windows 2003 drivers yielded the following:

a service installation section in this inf is invalid

And, naturally, refused to install.  To track down the source of this error, there is a file created in \Windows\inf called “setupapi.dev” that logs details about the driver installation process.  Reading through this file, the reason for the error is evident:

inf:       ServiceBinary=C:\Windows\system32\DRIVERS\mf.sys  (mf.inf line 39)
!!!  dvi:       Add Service: Binary 'C:\Windows\system32\DRIVERS\mf.sys' for service 'mf' is not present.
!!!  inf:  {Install Inf Section [MFINSTALL.mf.Services] exit(0xe0000217)}

Intriguingly, a quick search through C:\Windows\System32\DriverStore\FileRepository showed that the driver does exist, it just happens not to be installed.  There’s a filder called mf.inf_Identifier (where “Identifier” appears to be random junk) that contains a file called mf.sys.  Copying this file into C:\Windows\System32\Drivers allowed the device drivers to install, and they appear to work perfectly well.

  • Share/Bookmark

Tales of a Triumph

Triumph GT6+

Triumph GT6+

I once owned, and loved, a 1968 Triumph GT6+.  It had a beastly inline 6 cylinder engine with twin carburetors, and the drive wheels were attached with fancy little doodads called “rotoflex” connectors, which were essentially big rubber bands.  The net effect was that this car could move really well.

The car wasn’t without its problems — the gas gauge never worked all that well, it leaked from a few places, the carburetors would stick, and the electrical system was designed to work only when the stars and planets were perfectly aligned — none of which really dissuaded me from taking it out on lesser-used stretches of road and opening up the throttle.

After a few times of doing this, I agreed to let my girlfriend drive.  It was a much more harrowing experience from the passenger seat, for some reason, and when I wasn’t trying to climb under the seat I noticed that she had the speedometer well above the 140 mark.  In between flashes of my life up until that point, I wondered how good my tires really were.

On the way back from one of these forays, I saw flashing red and blue lights in my rear view window, clearly signaling for me to pull over.  I had just enough time to contemplate how often the third digit on police radar gets used when the cop approached the car.  I was poking through the tiny glove compartment for my insurance information when the cop said, “What year is this car?”

“Uh.  1968.”

“Can I look under the hood?” he said, with a sheepish enthusiasm.

“Sure!” I said, equally enthusiastic to not be getting a ticket, or worse.


Triumph GT6+

Triumph GT6+

While driving down Lakeshore Drive, the car’s temperamental electrical system shorted out and overheated, evidenced by some spectacular flames shooting up from the dashboard and in front of the windshield.   This had no discernible effect on the drivability of the car, so I decided to ignore it until I got home, about a mile away — since the alternative was to pull over on Lakeshore Drive (four lanes of crazy in each direction with no real shoulders or breakdown lanes) and try to fix it.

After a moment, a car pulled up beside me, its passenger gesturing wildly.  She then mouthed exaggeratedly, “your car is on fire!” while pointing frantically.

I’ll emphasize that the flames were right in front of my face.  I was looking through them to be able to drive the car down the road at all.  I paused a moment to consider what this good Samaritan thought I could possibly be looking at in order to miss the flames leaping up in front of my face?  Did she think I was sleep-driving?  Perhaps I thought the city was burning to the ground and didn’t realize my car was on fire?

In order not to dissuade this kind person from helping somebody truly stupid and in  need of having the obvious pointed out, I pretended to understand what she meant, gave her a thumbs-up, and a non-sarcastically exaggeratedly mouthed, “thanks!”

Perhaps the next life she saves will be somebody playfully pretending to ignore a “do not eat” label.

  • Share/Bookmark