I'm working on a device which communicates with a PC through a (virtual) serial port. The problem is that the data we are sending occasionally gets incorrectly identified by Windows as a bus mouse, after which the "Microsoft Serial Ballpoint" driver is loaded and the mouse pointer starts jumping around on the screen and randomly clicking on things.
A bit of Googling reveals that is an old and well-known problem with serial devices where the usual work-around is a bit of registry hacking to disable the offending driver. That it is a lot to demand from our users however and I'd rather not have our application messing around with the user's registry. Especially not when the fix is dependent on the Windows version and the user may well be using a bus mouse.
Instead I'd like to avoid the problem by changing our protocol to not send any data which may get us misidentified as a mouse. The only problem is that I'm not quite certain what patterns to avoid. Apparently Microsoft's Mouse protocol consists of packets of four bytes where the MSB of the first is set and that of the last three is clear.
Would sending only 7-bit ASCII suffice? Are there any other devices I need to worry about being detected as?
A serial mouse is a computer mouse that connects to the computer through a serial port. Today, the serial mouse has been replaced by the PS/2 and USB mouse.
BTW: Serial Mice are still supported as of Windows 10, including over USB-to-serial adapters (and it's still possible to get native serial ports on your motherboard: I've got one!) You probably would only know this because sometimes it completely breaks.
Find the Microsoft Serial Ballpoint and press the right hand mouse button and select the option to disable the mouse. Do not use the uninstall option as the next time you turn on the computer the PC will automatically reinstall the mouse driver. You will now be warned about disabling the mouse, click Yes.
Click the Start button, type “regedit” in the Search field, and then open the Registry Editor. In the right pane of the Registry Editor, select Start and change it's value to 4 to disable serial mouse detection at boot time. Close the Registry Edior and restart your PC.
I just encountered this problem myself on Windows 7 Professional x64
, and a solution that worked for me was to go into the registry and edit the following value:
Location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\sermouse Key: Start Value: 3
Change Value
to 4
and it will stop this problem occurring.
Here is a list of all valid Start values:
0 Boot (loaded by kernel loader). Components of the driver stack for the boot (startup) volume must be loaded by the kernel loader. 1 System (loaded by I/O subsystem). Specifies that the driver is loaded at kernel initialization. 2 Automatic (loaded by Service Control Manager). Specifies that the service is loaded or started automatically. 3 Manual. Specifies that the service does not start until the user starts it manually, such as by using Device Manager. 4 Disabled. Specifies that the service should not be started.
A reg edit command would be as follows:
REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\sermouse" /V Start /T REG_DWORD /F /D 4
You then need to restart the computer, which should now start correctly and not attempt to discover a serial mouse.
good luck.
It turns out that mouse detection in Windows is normally handled by the serenum.sys
filter driver. This driver implements support for legacy serial mice along with serial plug-and-play. Microsoft has even provided the sourcecode as a WDK sample.
During detection the ports switches to 1200-7-N-1 mode while asserting DTR
+RTS
to which a response is expected within 200 ms, with a couple of retries in case of failure. Unfortunately for a legacy mouse a single M
or B
character suffices as identification.
In our case the protocol was reworked to avoid these characters and now appears not to be misidentified anymore.
However we were using a virtual USB serial port and for a traditional serial port this approach may be somewhat difficult as anything sent at a different baud rate is liable to look like line noise. In this case I suppose the easiest workaround is probably, as has already been suggested, to avoid making any unsolicited transmissions.
Alternatively with the serial control signals actually hooked up, or intercepted by a USB CDC device, processing the DTR
or RTS
signals and holding off on output. Actually implementing the plug-and-play protocol would be an even niftier option. Supposedly there are cheap RS232 cables around without a full complement of control signals though so this approach might still fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With