Skip to content

Send & Receive Data from Usb Hid device #239

@Iveky

Description

@Iveky

I am working on C# hobby Project to poll data from Solar Hybrid Inverter (Axpert clone) over USB (hid) connection and discovered this package on Nuget.
Communication is ok for short amount data (< 8 bytes) but I don't catch how to receive larger chunks of data:
Device sends everything divided into 8 byte chunks, so, what to do to get 100+ bytes of data, cos this code in example is not enough:
Proper response would be: "(1492932112103803005535;0" but I receive only first part: "(1492932"

Here below is code that I wrote looking into example.

logText("Write command: QSID");
await targetDevice.InitializeAsync();
readBuffer = await targetDevice.WriteAndReadAsync(buffer).ConfigureAwait(false);
if (readBuffer.BytesTransferred < 3)
{
logText("Response from device is too short!");
Console.WriteLine("\r\nResponse from device is too short!\r\n");
return;
}
//readBuffer.Data is byte[]
response = System.Text.Encoding.ASCII.GetString(readBuffer.Data).Replace("\0", "");
logText("Response from device:" + response);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions