Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arduino.inf should load serenum.sys in addition with usbser.sys #1745

Open
ElbertMai opened this issue Dec 17, 2013 · 0 comments
Open

arduino.inf should load serenum.sys in addition with usbser.sys #1745

ElbertMai opened this issue Dec 17, 2013 · 0 comments
Labels
feature request A request to make an enhancement (not a bug fix) OS: Windows Specific to the Windows version of the Arduino IDE

Comments

@ElbertMai
Copy link

This is related to this old issue (#934) which is still open as of this writing.

When I plug in a typical USB-to-serial converter such as any FTDI-based converter, Windows will send a WM_DEVICECHANGE message to all interested applications. By inspecting the WM_DEVICECHANGE message, you can determine if the message is due to the attachment of a specific device type i.e. serial ports.

I can take advantage of this to give any microcontroller project true plug-and-play capabilities and not have to mess around COM port settings or require any other manual intervention by the user. This would greatly improve the end-user experience, and would be especially useful for Firmata-based PC + microcontroller projects. I got this working fine with my FTDI-based converters.

However, because arduino.inf does not have directives to load serenum.sys, Windows will not generate the right WM_DEVICECHANGE messages for boards like the Arduino UNO. This is an issue for me since quite a few of my friends and colleagues primarily use Arduinos, and thus my program won't work with their boards. Other USB-to-serial converters do in fact load the serenum.sys driver in addition to usbser.sys (or whatever custom driver they use), and do not have this issue as a result.

I was able to modify the arduino.inf file (from Arduino software version 1.0.5) and reinstall it to load this additional driver. This allows Arduino boards to look more like a proper COM port to Windows. Since usbser.sys is untouched in the fix, it is fully backwards compatible with any existing programs that open a COM port to the Arduino. The fix has been tested in Windows 7.

I would love to contribute the fix as a patch. I'm not sure how to handle this since the original INF file itself is signed, and thus my patch as-is won't load in Windows 8.


This fix also allows Windows to generate what's called a device path to the Arduino's ATmega16U2-based converter. It looks something like this:

\\?\usb#vid_2341&pid_0043#<serial number of Arduino board>#{4d36e978-e325-11ce-bfc1-08002be10318}

This path is synonymous with the COM<arduino port number> path. It appears that serenum.sys is responsible for generating this path. You can pass this device path directly to any serial library on Windows that allows passing file names directly to the OS and it will work. I would effectively be able to open a COM port to an Arduino UNO or similar systems without ever having to touch COM port numbers.


Modifications to the INF file:

  • Updated DriverVer directive in [Version] section to indicate newer version

  • Added SerEnumServiceName="SerEnum Filter Driver" directive to [Strings] section

  • Added AddService=serenum,,SerEnumDriverService directive to [DriverInstall.Services] section.

  • Added new sections:

    [DriverInstall.HW]
    AddReg=DriverAddReg.HW
    
    [DriverAddReg.HW]
    HKR,,"UpperFilters",0x00010000,"serenum"
    
    [SerEnumDriverService]
    DisplayName=%SerEnumServiceName%
    ServiceType=1
    StartType=3
    ErrorControl=1
    ServiceBinary=%12%\serenum.sys
    LoadOrderGroup=PNP Filter
    
  • Moved the following directives from [DriverAddReg] to [DriverAddReg.HW] section:

    HKR,,DevLoader,,*ntkern 
    HKR,,NTMPDriver,,usbser.sys 
    

Other directives were not modified.

@ffissore ffissore self-assigned this Jul 1, 2015
@per1234 per1234 added the feature request A request to make an enhancement (not a bug fix) label Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request to make an enhancement (not a bug fix) OS: Windows Specific to the Windows version of the Arduino IDE
Projects
None yet
Development

No branches or pull requests

3 participants