Faced the problem of transferring large arrays via CDC.
For example, when transmitting a binary packet of 4096 bytes, it is accepted, but if you send it a second time, the device returns “IRP USBD_STATUS: USBD_STATUS_CANCELED (0xc0010000)”. Then there are endless attempts to resend the packet and return from the “USBD_STATUS_CANCELED” device. At the same time, TinyCLR does not see an error on the bus, and if such a situation arises, it is not clear how to react to it, because there is no feedback for the program…
Wireshark log:
Wireshark Log. Data starts from 40 frame.
Sample:
static void Main()
{
var usbclientController = UsbClientController.GetDefault();
var usbClientSetting = new UsbClientSetting()
{
Mode = UsbClientMode.Cdc,
ManufactureName = "Manufacture_Name",
ProductName = "Product_Name",
SerialNumber = "12345678",
};
var cdc = new Cdc(usbclientController, usbClientSetting);
var buffer = new byte[65536];
cdc.DeviceStateChanged += (a, b) => Debug.WriteLine("Connection changed.");
cdc.DataReceived += (a, count) =>
{
if (cdc.Stream.BytesToRead == 0) return;
var readCount = cdc.Stream.Read(buffer, 0, buffer.Length);
Debug.WriteLine("Data received:" + readCount);
};
cdc.Enable();
while (cdc.DeviceState != DeviceState.Configured) ;
Debug.WriteLine("UsbClient Connected");
while (true)
{ }
}