WINCE下如何虚拟多个串口

应用背景

我们的产品是GPS产品,GPS模块是通过TXRX来和CPU串口控制器的UART2连接的,对应于COM3(这个可以根据自己的项目的需要来定)platform.reg中注册表信息如下:

;==========GPS===== UART2===COM3===============

[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial2]

   "DeviceArrayIndex"=dword:2

   "Irq"=dword:f

   "MemBase"=dword:50008000

   "MemLen"=dword:30 ;; 2c

   "InterruptBitsShift"=dword:6 ; UART 2 Interrupt Sub Register shift bit.

   ;"ISTTimeouts"=dword:200 ; every 512 ticks checking Modem status.

   "Prefix"="COM"

   "Index"=dword:3

   "Dll"="serial_smdk2443.Dll"

   "Order"=dword:0

   "Priority"=dword:0

   "Port"="COM3:"

   "DeviceType"=dword:0  ; IRDA modem, 0 -> null modem

   "FriendlyName"="GPS COM3"

   "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"

   "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00

应用程序通过COM2可以接受到GPS发送的数据并进行解析,把解析出来的数据在shell上显示,给用于直观的GPS数据。应用端往往需要多个COM口来接受GPS发送的数据,那么如何解决这个问题了,可以通过基于COM3来虚拟多个串口出来,这样可以打开多个COM口来接受GP发送过来的数据,如何实现呢?只需要做一下动作就可以实现了。

 

1. 使用vspd.dll来实现虚拟多个串口功能,这个驱动在网上应该很容易找到的。

2. 如果是WINCE5.0那么就在platform.bib中加入:

vspd.dll         $(_FLATRELEASEDIR)/vspd.dll NK  SH

如果是WINCE6.0系统,那么就在platform.bib中加入:

vspd.dll         $(_FLATRELEASEDIR)/vspd.dll NK  SHK   

对于WINCE5.0WINCE6.0系统,这个vspd.dll驱动是通用的。

3.platform.reg中加入

[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/VSPD0]

"Priority"=dword:00000000

"DeviceArrayIndex"=dword:00000000

"PortIsRO"=dword:00000000

"SplitPort"=dword:00000003

"Index"=dword:00000001

"Prefix"="COM"

"Dll"="vspd.dll"

"DeviceType"=dword:00000000

"Tsp"="Unimodem.dll"

"FriendlyName"="Virtual port COM1"

"DevConfig"=hex:10,00,00,00,05,00,00,00,10,01,00,00,00,4b,00,00,00,00,08,00,00,00,00,00,00

 

[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/VSPD1]

"Priority"=dword:00000000

"DeviceArrayIndex"=dword:00000001

"PortIsRO"=dword:00000000

"SplitPort"=dword:00000003

"Index"=dword:00000005

"Prefix"="COM"

"Dll"="vspd.dll"

"DeviceType"=dword:00000000

"Tsp"="Unimodem.dll"

"FriendlyName"="Virtual port COM5"

"DevConfig"=hex:10,00,00,00,05,00,00,00,10,01,00,00,00,4b,00,00,00,00,08,00,00,00,00,00,00

 

[HKEY_LOCAL_MACHINE/Drivers/BuiltIn/VSPD2]

"Priority"=dword:00000000

"DeviceArrayIndex"=dword:00000002

"PortIsRO"=dword:00000000

"SplitPort"=dword:00000003

"Index"=dword:00000006

"Prefix"="COM"

"Dll"="vspd.dll"

"DeviceType"=dword:00000000

"Tsp"="Unimodem.dll"

"FriendlyName"="Virtual port COM6"

"DevConfig"=hex:10,00,00,00,05,00,00,00,10,01,00,00,00,4b,00,00,00,00,08,00,00,00,00,00,00

 

上面的注册表就是基于COM3,虚拟出COM1COM5COM6,这样这4COM口都可以用于和GPS通信了,在这里强调一点,就是注册表项"SplitPort"=dword:00000003的值一定要和实际的COM口一致(在此是COM3)

你可能感兴趣的:(WINCE驱动开发)