全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:5178
推到 Plurk!
推到 Facebook!

請問如何使用BCB來開啟一個USB HID裝置

尚未結案
freeway710202
一般會員


發表:1
回覆:0
積分:0
註冊:2007-03-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-03-05 12:38:37 IP:140.116.xxx.xxx 訂閱
<textarea class="cpp" rows="10" cols="60" name="code"> 請在此區域輸入程式碼 </textarea>
soonbedone
一般會員


發表:1
回覆:9
積分:7
註冊:2005-03-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-05-24 21:08:15 IP:124.8.xxx.xxx 訂閱
底下是我以前寫的一個 PS2 連線小程式之一部份, 使用 TUSBIO 物件, 該物件請至此處看看 http://www.thesycon.de/eng/usbio_demo.shtml
------------ 希望多少有點幫助 ------
procedure TMYUSB.GoFunc1(Sender: TObject);
begin { 與 PS2 連線 }
if not isitok then Exit; { 無裝置 }
piCmd := TusbioPipe.Create; usrAbort := False;
status := piCmd.Open(DeviceNo, DevList, @USBIO_IID);
if status <> USBIO_ERR_SUCCESS then begin
MemoWrite('開啟傳輸導管裝置失敗' piCmd.errortext(status));
Exit;
end;
piCmd.ResetPipe; { see $40242C }
// 進行 Configuration 裝置參數設定
ZeroMemory(@conf, sizeof(conf));
conf.ConfigurationIndex := 0;
conf.NbOfInterfaces := 1;
conf.InterfaceList[0].InterfaceIndex := 0;
conf.InterfaceList[0].AlternateSettingIndex := 0;
conf.InterfaceList[0].MaximumTransferSize := 4096;
MemoWrite('Configuring the device ...');
status := piCmd.SetConfiguration(@conf);
if status <> USBIO_ERR_SUCCESS then begin
MemoWrite('命令導管裝置設定失敗' piCmd.errortext(status));
Exit;
end;
MemoWrite('命令導管裝置設定成功 !');
// 開啟三條傳輸導管
MemoWrite('Opening pipes...');
piRead := TusbioPipe.Create;
piWrite := TusbioPipe.Create;
piTest := TusbioPipe.Create;
status := piRead.Bind(DeviceNo, $83, DevList, @USBIO_IID);
if status <> USBIO_ERR_SUCCESS then begin
MemoWrite('讀取專用導管裝置設定失敗' piRead.errortext(status));
Exit;
end;
status := piWrite.Bind(DeviceNo, $02, DevList, @USBIO_IID);
if status <> USBIO_ERR_SUCCESS then begin
MemoWrite('寫出專用導管裝置設定失敗' piWrite.errortext(status));
Exit;
end;
status := piTest.Bind(DeviceNo, $81, DevList, @USBIO_IID);
if status <> USBIO_ERR_SUCCESS then begin
MemoWrite('測試專用導管裝置設定失敗' piTest.errortext(status));
Exit;
end;
MemoWrite('三條傳輸導管開啟成功 !');
MainPipeCommand(1, TX_Request); // 經由 piCmd 命令導管寫出指令
MainPipeCommand(1, TX_Complete);
MainPipeCommand(3, Peer_Exist); // 執行後則 PC : ready !
WaitPeer; { 經由測試專用導管, 等待對方端點回應 }
end;
------
~~ 縱想要有, 天不從人願 ~~
系統時間:2024-04-23 15:23:10
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!