intel realsense usb列舉,讀寫資料解析
0)intel realsense列舉裝置的呼叫堆疊如下:
rs_create_context--->
rs_context* rs_context_base::acquire_instance(),首先呼叫query_devices 獲取裝置資訊;呼叫的是windows的Media Foundation 列舉音訊,視訊捕獲裝置。
rs_create_context--->
rs_context* rs_context_base::acquire_instance(),首先呼叫query_devices 獲取裝置資訊;呼叫的是windows的Media Foundation 列舉音訊,視訊捕獲裝置。
通過獲取vid,判斷是不是intel的裝置,通過獲取pid判斷是intel的哪種型別的裝置,sr300,f200等等,然後呼叫相應的函式獲取rs_device
switch(get_product_id(*device))
{
case R200_PRODUCT_ID: rs_dev = rsimpl::make_r200_device(device); break;
case LR200_PRODUCT_ID: rs_dev = rsimpl::make_lr200_device(device); break;
case ZR300_PRODUCT_ID: rs_dev = rsimpl::make_zr300_device(device); break;
case F200_PRODUCT_ID: rs_dev = rsimpl::make_f200_device(device); break;
case SR300_PRODUCT_ID: rs_dev = rsimpl::make_sr300_device(device); break; //sr300裝置
}
將裝置加入到裝置列表:
if (rs_dev && is_compatible(rs_dev))
{
devices.push_back(rs_dev);
}
if (rs_dev && is_compatible(rs_dev))
{
devices.push_back(rs_dev);
}
其中: std::shared_ptr<rs_device> make_sr300_device(std::shared_ptr<uvc::device> device)實現的功能如下:
0.1)ivcam::claim_ivcam_interface(*device);----》claim_interface---》open_win_usb
0.2) auto calib = sr300::read_sr300_calibration(*device, mutex); //讀取標定的SR300的資料
1)windows下列舉裝置的程式碼在uvc-wmf.cpp 的open_win_usb函式如下:
void open_win_usb(int vid, int pid, std::string unique_id, const guid & interface_guid, int interface_number)
引數說明:
vid,pid:供應商ID(VID)和產品識別碼(PID);
unique_id:
interface_guid:介面的GUID
interface_number:介面號
void open_win_usb(int vid, int pid, std::string unique_id, const guid & interface_guid, int interface_number)
引數說明:
vid,pid:供應商ID(VID)和產品識別碼(PID);
unique_id:
interface_guid:介面的GUID
interface_number:介面號
列舉過程:
1.1)首先呼叫SetupDiGetClassDevs函式,通過interface_guid列舉device_info;
1.2)然後通過device_info和interface_guid, 列舉所有的裝置介面;
1.3)Check if this is our device
通過比較vid,pid,unique_id,interface_number,判斷是否是我們的裝置;
1.4)通過DevicePath建立檔案控制程式碼;(DevicePath = 0x00000193760cadf4 L"\\\\?\\usb#vid_8086&pid_0aa5&mi_04#7&6d10b2e&0&0004#{175695cd-30d9-4f87-8be3-5a8270f49a31}")
*file_handle = CreateFile(detail_data->DevicePath, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, nullptr);
if (*file_handle == INVALID_HANDLE_VALUE) throw std::runtime_error("CreateFile(...) failed");
1.5)The WinUsb_Initialize function creates a WinUSB handle for the device specified by a file handle.
WinUsb_Initialize
WinUsb_Initialize call queries the underlying USB stack for various descriptors and allocates enough memory to store the retrieved descriptor data.
WinUsb_Initialize first retrieves the device descriptor and then gets the associated configuration descriptor.
From the configuration descriptor, the call derives the associated interface descriptors and stores them in an array.
The interfaces in the array are identified by zero-based indexes. An index value of 0 indicates the first interface (the default interface),
a value of 1 indicates the second associated interface, and so on.
WinUsb_Initialize parses the default interface descriptor for the endpoint descriptors and caches information such as the associated pipes or state specific data.
The handle received in the InterfaceHandle parameter is a pointer to the memory block allocated for the first interface in the array.
1.1)首先呼叫SetupDiGetClassDevs函式,通過interface_guid列舉device_info;
1.2)然後通過device_info和interface_guid, 列舉所有的裝置介面;
1.3)Check if this is our device
通過比較vid,pid,unique_id,interface_number,判斷是否是我們的裝置;
1.4)通過DevicePath建立檔案控制程式碼;(DevicePath = 0x00000193760cadf4 L"\\\\?\\usb#vid_8086&pid_0aa5&mi_04#7&6d10b2e&0&0004#{175695cd-30d9-4f87-8be3-5a8270f49a31}")
*file_handle = CreateFile(detail_data->DevicePath, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, nullptr);
if (*file_handle == INVALID_HANDLE_VALUE) throw std::runtime_error("CreateFile(...) failed");
1.5)The WinUsb_Initialize function creates a WinUSB handle for the device specified by a file handle.
WinUsb_Initialize
WinUsb_Initialize call queries the underlying USB stack for various descriptors and allocates enough memory to store the retrieved descriptor data.
WinUsb_Initialize first retrieves the device descriptor and then gets the associated configuration descriptor.
From the configuration descriptor, the call derives the associated interface descriptors and stores them in an array.
The interfaces in the array are identified by zero-based indexes. An index value of 0 indicates the first interface (the default interface),
a value of 1 indicates the second associated interface, and so on.
WinUsb_Initialize parses the default interface descriptor for the endpoint descriptors and caches information such as the associated pipes or state specific data.
The handle received in the InterfaceHandle parameter is a pointer to the memory block allocated for the first interface in the array.
1.6)開啟裝置後,進行讀寫,windows下讀寫的程式碼都在uvc_wmf.cpp裡面,linux下的讀寫程式碼在uvc-libuvc.cpp 和uvc-v4L2.cpp裡面。
相關文章
- USB裝置的列舉過程分析——資料結構先行資料結構
- ubuntu 16.04 lts 安裝intel realsense 步驟UbuntuIntel
- Java列舉解讀Java
- Windows下USB磁碟開發系列二:列舉系統中所有USB裝置Windows
- C#從SQL Server中讀寫大資料列C#SQLServer大資料
- Python opencv USB攝像頭 讀寫PythonOpenCV
- OC中列舉寫法 以及 字串型別列舉實現探索字串型別
- Python 列舉類原始碼解析Python原始碼
- 大資料實踐解析(下):Spark的讀寫流程分析大資料Spark
- C語言 列舉資料型別C語言資料型別
- 【C++】資料型別-列舉型C++資料型別
- Pandas資料讀寫
- 資料讀寫流程
- ubuntu Realsense buildUbuntuUI
- 資料讀寫壓力大,讀寫分離
- 列舉python常用的資料結構Python資料結構
- 列舉繫結資料來源,獲取值
- Java 列舉(Enums)解析:提高程式碼可讀性與易維護性Java
- TensorFlow讀寫資料
- ADO.NET列舉資料提供者
- HBase資料的讀寫流程
- vtk資料的讀寫
- 資料庫讀寫分離資料庫
- 如何解析 Ethereum 資料:讀取 LevelDB 資料
- Java 列舉、JPA 和 PostgreSQL 列舉JavaSQL
- USB 控制寫傳輸、控制讀傳輸、無資料控制傳輸都是在什麼場景下?
- 解析Pyspark如何讀取parquet資料Spark
- 列舉和列舉的取值範圍
- 教你更優雅地寫 API 之「列舉使用」API
- Java mysql blob 資料讀寫操作JavaMySql
- JuiceFS 資料讀寫流程詳解UI
- io流對資料的讀寫
- iOS 簡單資料的讀寫iOS
- 資料庫的讀寫分離資料庫
- Redis資料儲存和讀寫Redis
- 資料結構複習-01enum列舉型別資料結構型別
- Windows下USB磁碟開發系列一:列舉系統中U盤的碟符Windows
- [提問交流]在模型管理中增加的資料欄位是列舉型別,但是寫入資料庫變成了數字形式,如何寫成原值?模型型別資料庫