AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Delphi 7, mit USB auf Cypress CY7C68013 FX2 zugreifen
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi 7, mit USB auf Cypress CY7C68013 FX2 zugreifen

Offene Frage von "jaenicke"
Ein Thema von max pack · begonnen am 14. Aug 2024 · letzter Beitrag vom 14. Feb 2025
Antwort Antwort
Kas Ob.

Registriert seit: 3. Sep 2023
457 Beiträge
 
#1

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

  Alt 15. Aug 2024, 17: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
max pack

Registriert seit: 28. Okt 2011
4 Beiträge
 
#2

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

  Alt 16. Aug 2024, 16:04
Hallo zusammen,
@Alter Mann: Nein, ich habe ein anderes Teil, kommt von AZ-Delivery (ohne hier Werbung zu machen oder Urheberrechtsverletzungen BlaBla auf den Leim zu gehen, dient nur der Beschreibung). Ist zwar absolut lächerlich, sollte heutzutage aber leider dazu geschrieben werden.

@Kas Ob: Thank you for your response.
1. Thanks, yes, I know the site with the learn.microsoft.
2. Sorry, you're right. Here are the returned values by a recievebuffer-size of 512bytes:
WinUSB Initialisierung OK.
WinUSB Handle basierend auf dem DeviceHandle ist: $00647918
---------------------------------------------------------------------------------------------------------------
WinUsb_GetDescriptor: Beschreibung des USB-Geräts abrufen:
Descriptor Länge: 18
DescriptorType: 1
USB Specification (Version): 2.0
DeviceClass: 255
DeviceSubClass: 255
DeviceProtocol: 255
Max Packet Size: 64
Vendor ID (VID): 0925
Product ID (PID): 3881
Device1: 1
Device2: 0
Manufacturer: 0
Product: 0
SerialNumber: 0
NumConfigurations: 1
---------------------------------------------------------------------------------------------------------------
WinUsb_QueryPipe: Infos zu den Pipes abfragen:
Pipe: 0 Endpoint: $0001 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
Pipe: 1 Endpoint: $0081 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
Pipe: 2 Endpoint: $0002 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
Pipe: 3 Endpoint: $0004 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
Pipe: 4 Endpoint: $0086 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
Pipe: 5 Endpoint: $0088 TransferType=Bulk Maximale Paketlänge: 512 bytes Interval: 0
---------------------------------------------------------------------------------------------------------------
WinUsb_ReadPipe: Daten abrufen aus Endpoint
WinUsb_ReadPipe erfolgreich
Bytes wurden emfangen: 0

48 F1 19 00 00 00 00 00 30 5C F3 00 04 00 00 00
00 84 62 00 FF FF FF FF 99 0F 01 2B 01 00 00 00
00 00 00 00 36 00 00 00 00 00 60 00 00 00 00 00
00 00 15 00 63 00 00 50 AF 74 BD 77 00 00 00 00
5E C6 B3 77 63 01 00 50 00 84 01 00 00 00 00 00
E0 83 62 00 08 84 62 00 00 00 60 00 A4 F1 19 00
C4 5F BD 77 15 00 04 11 9B 5F BD 77 0B 6F C6 7D
00 00 60 00 00 00 00 00 00 00 00 40 F4 0A 00 00
50 00 00 00 0A 00 00 00 00 84 62 00 63 01 00 50
72 B8 83 00 0A 00 00 00 50 84 62 00 00 84 62 00
00 84 62 00 64 F2 19 00 30 F3 B6 77 17 DA 1F 0A
FE FF FF FF EC F1 19 00 DD 0A B8 77 00 00 00 00
04 0B B8 77 08 84 62 00 00 00 60 00 00 00 00 00
36 00 00 00 9F 6D C6 7D 36 00 00 00 40 00 00 00
00 00 60 00 71 00 10 00 00 00 00 00 04 00 00 00
18 00 00 00 C9 00 00 00 01 00 00 00 00 00 60 00
00 00 60 00 00 00 00 00 00 00 60 00 18 F2 19 00
AF 74 BD 77 01 00 00 00 00 00 60 00 00 00 00 00
01 00 00 00 00 00 60 00 00 00 00 00 00 00 60 00
00 00 00 00 74 F2 19 00 AA 67 BD 77 58 02 60 00
7F 67 BD 77 DB 6C C6 7D 00 00 60 00 04 00 00 00
00 00 00 00 C4 F2 19 00 32 B3 7E 75 70 00 00 00
68 F2 19 00 00 00 00 00 63 00 00 50 00 00 60 00
00 84 62 00 01 00 00 00 00 84 62 00 70 87 62 01
20 F2 19 00 0F 00 00 00 A0 F3 19 00 30 F3 B6 77
BF CB 1F 0A FE FF FF FF B0 F3 19 00 46 F8 B3 77
08 84 62 00 1F 6D C6 7D 00 84 62 00 00 00 60 00
00 00 00 00 F0 F2 19 00 CB 6D DE 76 00 00 00 00
88 45 16 77 70 87 62 00 99 0F 01 2B D0 5A F3 00
00 00 00 00 58 76 01 00 62 00 00 40 00 00 00 00
F4 0A 00 00 99 0F 2B FF FF FF FF FF F4 0A 00 00
01 2B 01 00 00 00 00 00 00 00 00 00 F5 AD 7E 75
3. Yes, right, my mistake. This was just from my quick'n dirty testing. I tested several values, without any success.
4. I tested several sizes of buffer, withot success.
5. I tested this. The documentation from Sigrok says, that the device needs 2 bytes on endpoint 1: 0x01 (or 0xd5 for newer versions) and the second byte for the samplerate. Again no success.
My next work could be the test with the ApiMonitor, as you suggested.


Um uns gegenseitig nicht weiter unsere Zeit zu stehen - bitte nicht falsch verstehen(!) - sollten wir nicht weitere Links aufführen mit: Guck mal hier oder da und kennst Du das schon... Das ist sicherlich gut gemeint, aber nicht zielführend.
Ich hatte gehofft, dass schon jemand damit konkrete Erfahrungen hat und sagen kann: Hier ist ein Codeschnippsel, oder da ist ein Schreibfehler in der Doku und muss heißen Rumpelstielzchen(123) statt Schneewittchen(432), oder eine andere Lösung.
Ich muss mich wohl damit abfinden, dass ich mein Vorhaben so in dieser Zusammensetzung nicht hin bekommen werde.
Das ist zwar schade, ist aber auch eine Art Lösung und eine Erkenntnis.
Aber vielleicht meldet sich ja noch ein Wissender.


Trotzdem nochmals vielen Dank an die tüchtigen Teilnehmer und allen ein schönes Wochenende.
  Mit Zitat antworten Zitat
Alter Mann

Registriert seit: 15. Nov 2003
Ort: Berlin
949 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

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

  Alt 17. Aug 2024, 14:10
So, so. Den LA habe ich auch, jedoch ekennt Windows den nicht.
Zitat:
Vendor ID (VID): 0925
Product ID (PID): 3881
Dafür ist der Saleae Treiber erforderlich, oder irre ich mich?
  Mit Zitat antworten Zitat
mpv

Registriert seit: 10. Jun 2024
2 Beiträge
 
#4

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

  Alt 19. Aug 2024, 09:09
Libusb kann WinUSB als Frontend benützen, und es gibt eine gute Übersetzung von libusb in Delphi (https://github.com/ZYHPRO/Delphi-libusb)
Die Kupplung von WinUSB mit Windows soll natürlich da sein, über inf File (oder Firmware), das wird wahrscheinlich schon gemacht beim C++ Beispiel dass du hast.

Matt
Matt
  Mit Zitat antworten Zitat
max pack

Registriert seit: 28. Okt 2011
4 Beiträge
 
#5

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

  Alt 13. Feb 2025, 14:22
An Administrator(en) von www.delphipraxis.net:

Bitte diesen (meinen) Beitrag (215656-delphi-7-mit-usb-auf-cypress-cy7c68013-fx2-zugreifen) seit 14.8.24 vollständig löschen aus diesem Forum.

Warum?
Es ist Nichts heraus gekommen und es meldet sich auch kein Wissender mehr. Mein Thema bleibt unbeantwortet. Nichts ist schlimmer, als falsch
oder unbeantwortete Forendiskussionen. Genau wie diese hier.
Der Ärger bei Interessierten, die durch Suchmaschinen hier landen, inkl. deren damit verbundenen Zeitverschwendung ist verantwortungslos.
Ich weiß wovon ich rede (betrifft NICHT uns hier): Unendlich viele Stunden bin ich schon in Foren mit vielversprechenden Titeln unterwegs gewesen
mit der Hoffnung, eine akzeptable Lösung zu finden. Nur um nach langer Zeit feststellen zu müssen, dass da nur nicht-funktionierender Code steht,
tote und/oder unbrauchbare Links, 1000ste Version von irgendeinem Copy&Paste-Müll und viel BlaBlaBla, was oft nicht einmal mehr etwas mit dem
eigentlichen Thema zu tu hat. Unnützes Zeugs ohne Lösung. Viele andere Foren sind damit schon komplett über-zugemüllt und kaum noch brauchbar.
Delphi-Praxis sollte (meiner Meinung nach) ein besseres Bild abgeben.

Deswegen: Ersatzlos weg mit diesem ganzen Beitrag, löschen und allen einen Gefallen tun und Vorbild sein.
Danke an alle Beteiligten und Gruß
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
10.055 Beiträge
 
Delphi 12 Athens
 
#6

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

  Alt 14. Feb 2025, 00:20
Das Problem ist, dass es die Software für das Board offenbar nirgends mehr gibt. Das war die "Cypress Suite USB", die oben ja auch schon erwähnt wurde. Darin lag eine CyUSB.dll, die exportierte Funktionen hat, mit denen man Daten lesen und schreiben kann.

Eventuell bekommst du die Software noch hier:
https://gitcode.com/open-source-tool...top&type=card&

Wenn du die Software noch auftreiben kannst, könnte es so ca. gehen:
Delphi-Quellcode:
unit CyUSB;

interface

uses
  Windows, SysUtils;

const
  CyUSB_DLL = 'CyUSB.dll';

type
  // Funktionsdefinitionen aus der CyUSB.dll
  TOpenDevice = function(VendorID, ProductID: Word): Pointer; stdcall;
  TCloseDevice = procedure(Device: Pointer); stdcall;
  TWriteUSB = function(Device: Pointer; Endpoint: Byte; Buffer: Pointer; BufferSize: DWord): DWord; stdcall;
  TReadUSB = function(Device: Pointer; Endpoint: Byte; Buffer: Pointer; BufferSize: DWord): DWord; stdcall;

var
  OpenDevice: TOpenDevice;
  CloseDevice: TCloseDevice;
  WriteUSB: TWriteUSB;
  ReadUSB: TReadUSB;

procedure LoadCyUSB;
procedure UnloadCyUSB;

implementation

var
  DLLHandle: THandle;

procedure LoadCyUSB;
begin
  DLLHandle := LoadLibrary(CyUSB_DLL);
  if DLLHandle <> 0 then
  begin
    @OpenDevice := GetProcAddress(DLLHandle, 'OpenDevice');
    @CloseDevice := GetProcAddress(DLLHandle, 'CloseDevice');
    @WriteUSB := GetProcAddress(DLLHandle, 'WriteUSB');
    @ReadUSB := GetProcAddress(DLLHandle, 'ReadUSB');
  end;
end;

procedure UnloadCyUSB;
begin
  if DLLHandle <> 0 then
  begin
    FreeLibrary(DLLHandle);
    DLLHandle := 0;
  end;
end;

initialization
  LoadCyUSB;

finalization
  UnloadCyUSB;

end.
Verwenden:
Delphi-Quellcode:
program TestFX2USB;

uses
  Windows, SysUtils, CyUSB;

var
  FX2Device: Pointer;
  DataOut: array[0..63] of Byte;
  DataIn: array[0..63] of Byte;
  BytesWritten, BytesRead: DWord;

begin
  // 1. Gerät mit Vendor-ID und Product-ID öffnen
  FX2Device := OpenDevice($04B4, $1004); // Beispiel: Cypress Vendor-ID
  if FX2Device = nil then
  begin
    Writeln('FX2-Gerät nicht gefunden!');
    Exit;
  end;

  Writeln('FX2-Gerät verbunden!');

  // 2. Daten an FX2 senden (Bulk OUT auf Endpoint 0x02)
  FillChar(DataOut, SizeOf(DataOut), $A5); // Beispiel-Daten füllen
  BytesWritten := WriteUSB(FX2Device, $02, @DataOut, SizeOf(DataOut));
  Writeln('Bytes gesendet: ', BytesWritten);

  // 3. Daten vom FX2 lesen (Bulk IN von Endpoint 0x86)
  BytesRead := ReadUSB(FX2Device, $86, @DataIn, SizeOf(DataIn));
  Writeln('Bytes empfangen: ', BytesRead);

  // 4. Gerät schließen
  CloseDevice(FX2Device);
  Writeln('Verbindung geschlossen.');
end.
Es gibt noch das EZ-USB™ FX3 Software Development Kit, aber ob diese aktuellere Software mit der alten Hardware funktioniert und genauso ansteuerbar ist, weiß ich nicht.
Sebastian Jänicke
AppCentral
  Mit Zitat antworten Zitat
Antwort Antwort

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:07 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz