I believe I have figured it out. I got the source code for MFDeploy from the Micro Framework Porting Kit and ran it in the debugger in Visual Studio.
It first enumerates through a list of my USB devices and opens handles to them. These are the â\Device\USBPDO-xxâ handles. One of these devices is my USB-Serial Module, as the âfileâ variable on line 527 of âStreams.csâ where it calls âNative.CreateFileâ is â\?\usb#vid_0403&pid_6001âŚâ, which matches the hardware IDs for the GHI USB-Serial Module in Device Manager.
Apparently, once it opens a handle to the USB Serial Converter as a USB device, when âNative.CreateFileâ is called with the serial portâs path â\\.\COM7â its access is denied, and it returns an invalid handle and throws an InvalidOperationException. This is where MFDeploy says there was no response from the device.
So I made the change below to Streams.cs in the Microsoft.SPOT.Debugger namespace, which prevents it from opening the handle to the USB Serial Converter as a USB device. Now when I try to connect to COM7, I no longer get âACCESS_DENIEDâ.
Was:
static private SafeFileHandle OpenHandle( string file, System.IO.FileShare share )
{
if(file == null || file.Length == 0)
{
throw new ArgumentNullException( "file" );
}
SafeFileHandle handle = Native.CreateFile(file, Native.GENERIC_READ | Native.GENERIC_WRITE, share, Native.NULL, System.IO.FileMode.Open, Native.FILE_FLAG_OVERLAPPED, Native.NULL);
if(handle.IsInvalid)
{
throw new InvalidOperationException( String.Format( "Cannot open {0}", file ) );
}
return handle;
}
Changed to:
static private SafeFileHandle OpenHandle(string file, System.IO.FileShare share)
{
if (file == null || file.Length == 0)
{
throw new ArgumentNullException("file");
}
if (!file.Equals(@"\\?\usb#vid_0403&pid_6001#a60395nh#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"))
{
SafeFileHandle handle = Native.CreateFile(file, Native.GENERIC_READ | Native.GENERIC_WRITE, share, Native.NULL, System.IO.FileMode.Open, Native.FILE_FLAG_OVERLAPPED, Native.NULL);
if (handle.IsInvalid)
{
throw new InvalidOperationException(String.Format("Cannot open {0}", file));
}
return handle;
}
else
{
throw new InvalidOperationException(String.Format("Cannot open {0}", file));
}
}