0
我正在嘗試爲從HID讀取數據的C++代碼創建一個C#封裝。我給出的代碼非常簡單,但並不完整。從設備接收到的數據讀入緩衝區如下:解析緩衝區數據到結構
pTmpBuf = (U8 *)calloc(InputReportByteLength, sizeof(U8));
if (ReadFile(hDevice, pTmpBuf, InputReportByteLength, &nRead, NULL))
{
memcpy(`pAppBuffer`, pTmpBuf + 1, nRead-1);
}
我想在pAppBuffer
數據解析成被定義爲結構如下:
struct BAYER_CONTOUR_REPORT
{
unsigned char reportID; // HID report ID
unsigned char checkSum; // checksum for hostID + deviceID + data
unsigned char hostID // host ID assigned by communications manager
unsigned char deviceID; // device ID assigned by communications manager
unsigned char length; // length of data in buffer
unsigned char data[60]; // data send with message
};
如何才能做到這一點?任何幫助或指針表示讚賞。
pAppBuffer與struct的大小相同嗎? –
是你的代碼C#還是C++? – Gonmator
我發佈的代碼是C++ –