简体   繁体   English

设备被误检测为串行鼠标

[英]Device misdetected as serial mouse

I'm working on a device which communicates with a PC through a (virtual) serial port.我正在开发一种通过(虚拟)串行端口与 PC 通信的设备。 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.问题是我们发送的数据偶尔会被 Windows 错误地识别为总线鼠标,之后加载“Microsoft Serial Ballpoint”驱动程序,鼠标指针开始在屏幕上跳来跳去并随机点击事物。

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.尤其是当修复依赖于 Windows 版本并且用户很可能正在使用总线鼠标时。

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.显然微软的鼠标协议由四个字节的数据包组成,其中第一个的 MSB 被设置,最后三个的 MSB 是明确的。

Would sending only 7-bit ASCII suffice?只发送 7 位 ASCII 就足够了吗? Are there any other devices I need to worry about being detected as?我还需要担心被检测为其他设备吗?

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:我自己刚刚在Windows 7 Professional x64上遇到了这个问题,对我Windows 7 Professional x64的解决方案是进入注册表并编辑以下值:

Location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\sermouse  
Key: Start  
Value: 3

Change Value to 4 and it will stop this problem occurring.Value更改为4 ,它将阻止此问题的发生。

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 编辑命令如下:

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.事实证明,Windows 中的鼠标检测通常由serenum.sys过滤器驱动程序处理。 This driver implements support for legacy serial mice along with serial plug-and-play .该驱动程序实现了对传统串行鼠标以及串行即插即用的支持。 Microsoft has even provided the sourcecode as a WDK sample . Microsoft 甚至提供了源代码作为 WDK 示例

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.在检测期间,端口切换到 1200-7-N-1 模式,同时断言DTR + RTS ,预计在 200 毫秒内响应,在失败的情况下重试几次。 Unfortunately for a legacy mouse a single M or B character suffices as identification.不幸的是,对于传统鼠标,单个MB字符就足以识别。

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.然而,我们使用的是虚拟 USB 串行端口,对于传统的串行端口,这种方法可能有些困难,因为以不同波特率发送的任何内容都可能看起来像线路噪声。 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.或者,通过 USB CDC 设备实际连接或拦截串行控制信号,处理DTRRTS信号并延迟输出。 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.据说周围有便宜的 RS232 电缆,但没有完整的控制信号,因此这种方法可能仍然失败。

I also encountered this problem, fixed it by disabling "serial enumerator" in the advanced properties of the FTDI driver (properties of COM ports in Device Manager).我也遇到了这个问题,通过在 FTDI 驱动程序的高级属性(设备管理器中的 COM 端口属性)中禁用“串行枚举器”来修复它。 This is described in http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf .这在http://www.ftdichip.com/Support/Documents/AppNotes/AN_107_AdvancedDriverOptions_AN_000073.pdf 中有描述。

I have encountered this Windows bug myself.我自己也遇到过这个 Windows 错误。 Here is my own research on the topic:这是我自己对这个主题的研究:

Microsoft acknowledges this bug: http://support.microsoft.com/kb/819036 Start with downloading their tool and see if it solves the issue. Microsoft 承认此错误: http : //support.microsoft.com/kb/819036首先下载他们的工具,看看它是否能解决问题。

  • Download & install their program.下载并安装他们的程序。
  • Run it from the command prompt from C:\\program\\Microsoft comdisable\\从 C:\\program\\Microsoft comdisable\\ 的命令提示符运行它
  • Write comdisable /list when executing the program.执行程序时写入comdisable /list
  • All ports on the computer will be shown.将显示计算机上的所有端口。
  • Write comdisable /disable COMx where x is the port number.写入comdisable /disable COMx ,其中 x 是端口号。
  • Do this for all ports on the computer.对计算机上的所有端口执行此操作。
  • Reboot.重启。

This should hopefully work as an universal solution.这应该有望成为一个通用的解决方案。

Alternatively, you can hack in boot.ini but I don't believe this works in Vista/Win 7. I have some app note from Cisco systems describing how to do this.或者,您可以在 boot.ini 中进行 hack,但我不相信这在 Vista/Win 7 中有效。我有一些来自 Cisco 系统的应用说明,描述了如何执行此操作。 If the above doesn't solve your problem, please let me know.如果以上方法不能解决您的问题,请告诉我。

In my development environment, I've simply disabled Microsoft Serial Mouse from the Device Manager.在我的开发环境中,我只是从设备管理器中禁用了Microsoft 串行鼠标

This seems to solve the culprit of my problem.这似乎解决了我的问题的罪魁祸首。 Before doing so, the CH340G chip I've used in my design used to lower the DTR five times before initiating the connection, effectively rebooting my Arduino-based board and render it useless.在此之前,我在我的设计中使用的CH340G芯片在启动连接之前将DTR降低了五次,有效地重新启动了我的基于 Arduino 的电路板并使其变得无用。

微软串行鼠标驱动程序与 Arduino Clone 的 CH340G UART 转 USB 混淆

Maybe this helps: We had the same problem with FTDI FT232RL.We found out, that it was a hardware issue of our PCB.也许这会有所帮助:我们在 FTDI FT232RL 上遇到了同样的问题。我们发现,这是我们 PCB 的硬件问题。

FTDI-Datasheet says about #RESET-Pin: Active low reset pin. FTDI 数据表说明了#RESET-Pin:低电平有效复位引脚。 This can be used by an external device to reset the FT232R.外部设备可以使用它来重置 FT232R。 If not required can be left unconnected, or pulled up to VCC.如果不需要,可以悬空,或上拉至 VCC。

RESET-Pin was not required in our application, so we connected it to Vcc via 1k Pull-Up.我们的应用中不需要 RESET-Pin,因此我们通过 1k 上拉将其连接到 Vcc。 It seemed that the pull-up of #RESET-Pin caused an undefined start-up of the FT232RL, at least every second converter, we connected to a USB-socket caused a serial-ball-point in the devive manager.似乎#RESET-Pin 的上拉导致了 FT232RL 的未定义启动,至少每隔一秒转换器,我们连接到 USB 插座就会导致设备管理器中的串行球点。 We removed the pull-up-resistor at #RESET-Pin, therewith the #RESET-Pin is unconnected.我们在#RESET-Pin 处移除了上拉电阻,因此#RESET-Pin 未连接。 Since then every interface worked proberly and didn't any longer create serial-ball-points in the Windows device manager.从那时起,每个接口都可以正常工作,并且不再在 Windows 设备管理器中创建串行圆珠点。

If you have a "true" serial port, or an USB dongle (RS-232, RS-485, it does not matter) this problem can be worked around by first opening the serial port in question with a terminal, or whatever application you want to monitor it with, and only then plugging the device in. For your own sake, you should also pay attention to remove the device before terminating the connection.如果你有一个“真正的”串口,或者一个 USB 加密狗(RS-232、RS-485,没关系)这个问题可以通过首先用终端打开有问题的串口来解决,或者你使用的任何应用程序想要监控它,然后才插入设备。为了你自己,你也应该注意在终止连接之前移除设备。

With FTDI chips soldered on the device itself, you are busted.将 FTDI 芯片焊接在设备本身上,你就失败了。 It took a few rounds for me to explain the management that a device communicating on it's own paired with an FTDI chip soldered on the PCB meeting Windows computers won't likely pass for user-friendliness, no matter how slick an USB socket may look like on the cabinet... (Thankfully, all these conditions coming together are quite rare and unusual)我花了几轮来解释管理,一个独立通信的设备与焊接在 PCB 上的 FTDI 芯片配对 Windows 计算机不太可能通过用户友好性,无论 USB 插座看起来多么光滑在柜子上......(谢天谢地,所有这些情况都非常罕见且不寻常)

I had this problem since 2010 with serial scale heads connected to the pc.自 2010 年以来,我遇到了这个问题,串行秤头连接到电脑。 Usb to serial converter or not.. I use onkly SILABS device's CP2102 or the like.. I worked around it by simply allowing the driver to install and then in device manager look for the ballpoint driver under mouse/HIDA and then simply DISABLE the driver, DO NOT UNINSTALL IT simply disable it. USB到串行转换器与否..我使用onkly SILABS设备的CP2102或类似设备..我通过简单地允许安装驱动程序然后在设备管理器中查找鼠标/HIDA下的圆珠笔驱动程序然后简单地禁用驱动程序来解决它, 不要卸载它只是禁用它。 Then when you reboot even with the driver instaled it seems windows ignores the comport as serial mouse and uses the data from the input.然后,即使在安装了驱动程序的情况下重新启动时,Windows 似乎也会忽略作为串行鼠标的通信并使用来自输入的数据。 You will also find that if the ballpoint driver is active then that COMport is in use and sometimes returns a COM PORT not accessible... hope this helps some one out there :) Tx Ben您还会发现,如果圆珠笔驱动程序处于活动状态,则该 COMport 正在使用中,有时会返回一个无法访问的 COM PORT...希望这对那里的人有所帮助:) Tx Ben

Code tot stop GPS from being detected as serial mouse.代码阻止 GPS 被检测为串行鼠标。

Below is the code for a subroutine in C#.net.下面是 C#.net 中子程序的代码。 It checks if the registry key is set to 4 and if not it issues the configuration command to disable sermouse.它检查注册表项是否设置为 4,如果没有,则发出配置命令以禁用 sermouse。 Embed this subroutine in a program which runs at startup and it will correct the setting after a windows update.将此子例程嵌入在启动时运行的程序中,它将在 Windows 更新后更正设置。

Maybe useful if you get annoyed when this problem happens time and again如果您在一次又一次出现此问题时感到恼火,这可能很有用

private void Stop_sermouse() private void Stop_sermouse()

    {
        string k =
        "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\sermouse";

        object v = Microsoft.Win32.Registry.GetValue(k, "Start", null);
        if (v==null)
            {
            MessageBox.Show("No Registry Key for sermouse");
                }
        else
        {
            string sr = v.ToString();
            if (sr == "4")
            {; }
            else
            {
                DialogResult mbox = MessageBox.Show("disable sermouse ? " + v.ToString(), "Found sermouse enabled! ", MessageBoxButtons.YesNo);
                if (mbox == DialogResult.Yes)
                { 
                    // prepare a small job to issue confuguration command
        ProcessStartInfo s = new ProcessStartInfo("cmd.exe", "/c sc config sermouse start=disabled");
                    Process p = new Process();
                    s.Verb = "runas"; // Must run as administrator
                    s.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    p.StartInfo = s;
        // and run the command
                    p.Start();
        //check if the registry is modified indeed
                    v = Microsoft.Win32.Registry.GetValue(k, "Start", null);
                    sr = v.ToString();
                    if (sr == "4")
                    {
                        MessageBox.Show("finished ''sc config sermouse start=disabled'' but not succesfull in registry!");
                    }
                    else
                    {
                        MessageBox.Show("sermouse is disabled");
                    }
                }
            }
        }           
    }

Turns out there is a setting to stop windows trying to enmumerate devices that connect as a COM port.原来有一个设置可以阻止 windows 尝试枚举连接为 COM 端口的设备。

高级 COM 端口设置

Make sure that "Serial Enumerator" is unchecked under "Miscellaneous Options"确保在“杂项选项”下未选中“串行枚举器”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM