在 Windows Mobile 上使用虚拟 com 端口
我有一台运行 Windows CE 5.0 的 Windows Mobile 设备。 我现在想将硬件连接到 USB 端口,并通过将其配置为虚拟 com 端口并向其写入/读取字节来与硬件进行通信。
我是否必须为 Windows Mobile 设备编写虚拟 com 驱动程序?请注意,硬件设备只是发送/接收字节的设备。
我可以简单地使用.net框架的SerialPort类吗?
将设备连接到 USB 后,我如何知道设备所连接的 COM 端口? windows mobile 有设备管理器吗?
谢谢。
I have a windows mobile device which is running windows CE 5.0.
I want to now connect a hardware to the USB port and communicate with the hardware by configuring it as a virutal com port and writing/reading bytes to/from it.
Do i have to write a virual com driver for the windows mobile device? Please note that the hardware device that is just a device which sends/receives bytes..
Can i simply use the SerialPort class of .net framework?
How will i know the COM port to which the device is connected once i connect it to the USB ? is there a device manager in windows mobile?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Windows Mobile != Windows CE 5.0,因此首先您需要验证您的硬件实际运行的是什么。其次,您必须验证“USB 端口”是什么。 USB 有两种“模式”——主机模式和客户端模式——它们在物理上和软件上都不同。如果您通过该端口将设备连接到 PC,那么它就是客户端端口,并且无法接受外围设备。
现在,如果它是 CE 5.0 设备并且如果它是 USB 主机端口,那么我们将深入了解 USB 设备类型和操作系统驱动程序。它是什么样的设备?它是否已经充当串行设备(例如,它具有 FTDI 或 Prolific 芯片组)?如果是这样,只需安装正确的 CE 驱动程序即可。如果没有,那么您需要编写一个主机设备驱动程序以允许 USB 系统与该特定设备进行通信。该驱动程序如何工作取决于硬件。
至于端口名称是什么,这取决于主机驱动程序的注册表设置。通常,它将从第一个可用端口启动(即,如果您的硬件已经有“COM1:”,那么它将从“COM2:”启动),但这很容易被覆盖,因此请在注册表中进行验证。
编辑
有关驱动程序实现的示例,请参阅 PC 上的以下位置(假设您已安装 Platform Builder - 我认为自 3.0 起的任何版本):
< code>%WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS\USBSER 用于基本 USB 主机 串行类驱动程序示例
%WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\SERIAL
用于基本 USB 功能 串行驱动程序示例Windows Mobile != Windows CE 5.0, so first you need to verify what your hardware is actually running. Second, you have to verify what the "USB port" is. USB has two "modes" - Host and CLient - and they are different both physically and in software. If it's the port that you hoos the device to the PC through, then it's a client port and is not going to be able to accept a peripheral.
Now if it's a CE 5.0 device and if it's a USB Host port then we get down to the USB device type and the OS drivers. What kind of device is it? Does it act as a serial device already (e.g. it has an FTDI or Prolific chipset in it)? If so, just install the right CE driver and you're set. If it doesn't, then you need to write a host device driver to allow the USB system to communicate with this particular device. How that driver will work depends on the hardware.
AS to what the port name will be, that's up to the host driver's registry settings. Typically it will start at the first available port (i.e. if your hardware already has "COM1:", then it will start at "COM2:"), but that's easily overridden, so verify in the registry.
EDIT
For examples of the driver implementations see the following locations on your PC (this assumes you've got Platform Builder - I think any version since about 3.0 - installed):
%WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS\USBSER
for a basic USB host serial class driver example%WINCEROOT%\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\SERIAL
for a basic USB function serial driver example