2009年7月22日 星期三

Push Mode簡介



說明:
"push mode" 是指device 上觸發了某些事件,這些事件有必要讓PC 端知道。
如在Scanner 上按下了掃描鍵。PC 端應立刻讀取scanner 上的掃描資訊,進行掃描。

基本上分為兩種:
1. polling: 每隔一段時間便向device 詢問相關資訊。
2.1 function 呼叫時機:
自行參考xp ddk下的demo

2. asynchronous: device 透過 interrupt 發送相關資訊上來。
2.1 function 呼叫時機:
//initialization
IStiUSD::Initialize()
IStiUSD::GetCapabilities()
IStiUSD::GetStatus()
IStiUSD::SetNotificationHandle()

//when device send a interrupt
IStiUSD::GetNotificationData()

//Set again
IStiUSD::SetNotificationHandle()

.
.
.

Function 簡介(asynchronous):

IStiUSD::Initialize()
a. 用Createfile()取得另一個Handle,有別於read/write 用的那一個。

IStiUSD::GetCapabilities()
a. 提供支援STI 的版本(xp: STI_VERSION, vista/7: STI_VERSION_3)
b. 告知是否支援wia, 支援何種 push mode(polling/ asynchronous)

IStiUSD::GetStatus()
a. 由mask 中的
STI_DEVSTATUS_ONLINE_STATE 決定是否告知device online,
STI_DEVSTATUS_EVENTS_STATE 決定是否告知有無event pending-----只有 polling mode此flag 才會被設立
b. 告知是否Device online

IStiUSD::SetNotificationHandle()
a. 用來DeviceIoControl(,IOCTL_WAIT_ON_DEVICE_EVENT,..)來幫助WIA Service 等待device 的interrupt.
b. 支援 asynchronous才會進來此function,支援 polling 則不會。

IStiUSD::GetNotificationData()
a. WIA Service 一旦等待到Device interrupt 便會呼叫此function
b. 在此從device 取得相關資訊,並由此資訊判斷屬於哪個Event ,再回傳此Event給 WIA Service

IWiaMiniDrv::drvGetCapabilities()
a. 告知支援的Event 及command

IWiaMiniDrv::drvNotifyPnpEvent
a. 當asynchronous 模式且pnp Event 為WIA_EVENT_POWER_RESUME ,得再次呼叫IStiUSD::SetNotificationHandle() 來設立WIA Service的等待模式。




INF File

"Capabilities" in INF DDInstall section:

bit 0(STI_GENCAP_NOTIFICATIONS): 支援push mode 預設模式 為 asynchronous
bit 1(STI_GENCAP_POLLING_NEEDED): 改變模式為 polling
bit 2(STI_GENCAP_GENERATE_ARRIVALEVENT):
bit 3(STI_GENCAP_AUTO_PORTSELECT):
bit 4(STI_GENCAP_WIA): 支援WIA
bit 5(STI_GENCAP_SUBSET):


ex:
.
.
.
[Manufacturer]
%Mfg%=Models

[Models]
%WIASample.DeviceDesc% = WIASample.Scanner, MICROSOFT_WIASCANR_TESTDEVICE_PNP_ID

[WIASample.Scanner]
Capabilities=0x31(支援wia(ddk 中demo code 中把STI_GENCAP_SUBSET 設起來), 且push mode 的模式為 asynchronous)
.
.
.


沒有留言:

張貼留言