• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

TnrUSBPipePair timeouts and nrUSB driver issues

Started by Zdenek Hlavica, February 13, 2021, 09:55:09 am

Previous topic - Next topic

Zdenek Hlavica

February 13, 2021, 09:55:09 am Last Edit: February 13, 2021, 10:05:38 am by Zdenek Hlavica
Hello Mr. Novgorodov,

I'would like to discuss my several other findings related to nrComm USB components.

-----------------------------------------------------------------------------------
Topic 1: TnrUSBPipePair.TimeoutRead & TnrUSBPipePair.TimeoutWrite
-----------------------------------------------------------------------------------
Perhaps I've been doing something wrong, but I've never noticed that settings of timeouts has any influence on data transfer. I've been testing mainly TimeoutRead property which is related to IN pipes. I've tried to use many differents values of TimeoutRead property, but timeout or canceling transfer has never occured. I've tried to pause sending of packets in the middle of transfer (on USB device side) even for minutes and after resuming sending of packets the transfer always continued as with infinite timeout settings. I've tried behaviour of timeouts settings with both WinUSB and nrUSB drivers, in both cases was the same.
Additionaly I would like to ask you if a timeout event does initiate raising of TnrUSBPipePair.OnFatalError event.

-----------------------------------------------------------------------------------
Topic 2: nrUSB driver and TnrUSB.ControlRequest
-----------------------------------------------------------------------------------
I've found out strange behavior of TnrUSB.ControlRequest if an application uses nrUSB driver. The TnrUSB.ControlRequest works if I send vendor-specific requests, but it doesn't work when I try to read device descriptors. Reading of USB device descriptors by TnrUSB.ControlRequest works well with using WinUSB driver, but with the same code the TnrUSB.ControlRequest function always returns false with using nrUSB driver.

-----------------------------------------------------------------------------------
Topic 3: nrUSB driver and transfer instability
-----------------------------------------------------------------------------------
This is dificult issue, because it can be hard to reproduce it. This issue is related to nrUSB driver only, it works well with WinUSB driver. I'm sending TnrUSB.ControlRequest (vendor specific) and receiving data from IN pipe in loop (TnrUSBPipePair.ReadBufferSize = 32768):

1. send vendor-specific TnrUSB.ControlRequest
2. receive 32768 bytes from IN pipe
3. send vendor-specific TnrUSB.ControlRequest
4. receive 32768 bytes from IN pipe
...
...
The loop ends when 4194304 bytes are received.

Issues:
1. Occasionally the TnrUSB.ControlRequest fails (return false). It is quite rare, lets say 1 error per 1000 sending of TnrUSB.ControlRequest.
2. Occasionally an event TnrUSBPipePair.OnAfterReceive returns nonsense in Received value. When error occur a value or Received parameter is always about 55 million (e.g. 55165472). Frequency is 1 error per 300 transfers of 32768 bytes (or 1 error per each third loop of receiving of 4194304 bytes).
3. One time I expirienced debugger exception 'Pipe IDs are wrong' during the transfer.

How I said, all these instability issues are related to nrUSB driver only. It works well with WinUSB driver. If I find more dependencies I will let you know, but in this time it looks like the WinUSB solutions is more stable.


Info about my setup:
- OS Windows 10 (64bit)
- IDE Delphi 10.3 Rio (32-bit app)
- nrComm Lib v9.59
- My own USB device (my own design)

Thank you and Best Regards,
Zdenek