Einzelnen Beitrag anzeigen

Kas Ob.

Registriert seit: 3. Sep 2023
351 Beiträge
 
#7

AW: Delphi 7, mit USB auf Cypress CY7C68013 FX2 zugreifen

  Alt 15. Aug 2024, 18:57
Hi,

My knowledge with such USB devices is very limited as almost non existed, but i can put some thoughts about this subject:

1) Using specific USB API (WinUsb) is way easier than going full low level with DeviceIoControl, so yes stick to https://learn.microsoft.com/en-us/wi...32/api/winusb/

2) I see that you reported successful WinUsb_QueryPipe, yet you did not mention what is the result of WinUsb_ReadPipe, see,.. return value is the most important for any API, in case of failure then you always want to query and report/log the GetLastError, always always always do that .

3) from your post WinUsb_ReadPipe you are using $81 as PipeID, while PipeID is in fact bEndpointAddress, where
Zitat:
Bit 7 indicates the direction of the endpoint: 0 for OUT; 1 for IN.
May be i am wrong here but shouldn't be 0 here ? meaning the PipeID should be $01.

4) The buffer size is very important, many devices are so simple hardware that refuse to handle arbitrary sizes, so after WinUsb_QueryPipe, use the MaximumPacketSize in that Info, try only that size or exact multiple sizes aka n*MaximumPacketSize, no more and no less.

5) To my knowledge to almost always you need to issue a command then read the result, USB it self is protocol, so i think WinUsb_WritePipe should be involved before WinUsb_ReadPipe, but again i might be wrong.

Now to different approach :
I faced something similar with completely different hardware, there was working software, the client needed remote functionality for this USB device which the company was dissolved and gone, so i reversed engineer its protocol and extracted the few needed commands, then build an application to do it.
I will not assume you will/can entertain the full process of reversing/decompiling... , but i can suggest something you can use and at least put you on the right way, Use Api Monitor from here http://www.rohitab.com/apimonitor
or try to search for DDK debugger if you prefer, with API Monitor you can choose the following functions in the screen shot, assuming you have working software with that device
wdk_usb.png

See how that software is communicating with USB device, watch how the API's are being used and deduce your usage, as Api Monitor can and will capture the selected API function and their parameters with their return value, pay extra attention to the buffers sizes , and .....
I can't emphasize enough to check if that working software is using overlapped or not, if it is then you must (have to) use overlapped as this device is asynchronous and might be filling partially, in other words your problem could be simply blocking and waiting, yet, use this monitor for confirmation.

Sorry for the bad English, and good luck !
Kas
  Mit Zitat antworten Zitat