Aktuelle Zeit: 24.09.2020 10:25

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: FTDI D2XX Driver 64Bit
BeitragVerfasst: 23.07.2020 20:21 
Offline

Registriert: 06.04.2005 22:44
Guten Abend zusammen,

ich versuche gerade meinen funktionierenden 32 Bit Lib für FTDI d2xx Direkt Treiber auf 64 Bit zu portieren.
Leider scheitere ich.

Ich kann zwar noch die Anzahl der Chips abholen (FT_CreateDeviceInfoList) und beim Detail (FT_GetDeviceInfoDetail)
bekomme ich beim Type noch die richtige Info aber beim *pcSerialNumber Geht gar nichts mehr

das
Code:
FT_Device = FT_Device_by_SerialNumberPart("CC001",0)

klappt ohne Probleme bei 32Bit

Zum testen müsste man einen FT232R im D2XX Mode bringen zum testen

Demo Prg:
Code:
EnableExplicit

#DLLwork = 0

XIncludeFile "ftdi_libProto.pbi"

Global i.l,Flag.l,Type.l,ID.l,LocID.l,Hdl, *pcSerialNumber,*pcDescription
Global Result   

*pcSerialNumber = AllocateMemory(128)
*pcDescription = AllocateMemory(128)
 


Debug FT_CreateDeviceInfoList (*FT_NumDevs)
Debug FT_NumDevs

For i = 1 To FT_NumDevs
  Result  = FT_GetDeviceInfoDetail(i-1,@Flag,@Type,@ID,@LocID,*pcSerialNumber,*pcDescription,@Hdl)
  If Result <> #FT_ok
    MessageRequester("Error",Str(Result))
  Else
    Debug PeekS(*pcSerialNumber)
    Debug PeekS(*pcSerialNumber,#PB_Ascii)
    Debug PeekS(*pcSerialNumber,#PB_UTF8)
    Debug PeekS(*pcSerialNumber,#PB_UTF32)
  EndIf
 
Next i





FT_Device = FT_Device_by_SerialNumberPart("CC001",0)
Debug FT_Device

Debug FT_Open(FT_Device,*FT_Handle)
PokeS(*FT_Outbuffer,"Thomas",-1,#PB_Ascii)

FreeMemory(*pcDescription)
FreeMemory(*pcSerialNumber)

While (1)
 
Delay(10) 
Wend


LIB:
Code:
EnableExplicit

CompilerIf #PB_Compiler_IsMainFile
  #DLLwork = 0
CompilerEndIf



CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Macro PrototypeOS
    Prototype
  EndMacro
  Global FTDIfile.s = "ftd2xx.dll"
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
  Macro PrototypeOS
    PrototypeC
  EndMacro
  Global FTDIfile.s = "libftd2xx.so.1.4.6"
CompilerEndIf



Structure FT_Prog_Info_S ;{
    VendorId.w              ; // 0x0403
    ProductId.w             ; // 0x6001
    Manufacturer.s{10}      ; // "DG5MPQ"
    Description.s{30}       ; // "USB HS Serial Converter"
    SerialNumber.s{30}      ; // "FT000001" if fixed, or NULL
    MaxPower.w              ; // 0 < MaxPower <= 500
EndStructure ;}
Structure FT_Program_data_struct;{
 Signature1.l               ; // Header - must be 0x0000000
 Signature2.l               ; // Header - must be 0xffffffff
 Version.l                  ; // Header - FTROGRAM_DATA version
                            ; // 0 = original
                            ; // 1 = FT2232 extensions
                            ; // 2 = FT232R extensions
                            ; // 3 = FT2232H extensions
                            ; // 4 = FT4232H extensions
 VendorId.w                 ; // 0x0403
 ProductId.w                ; // 0x6001
 Manufacturer.l            ; // "FTDI"
 ManufacturerId.l          ; // "FT"
 Description.l             ; // "USB HS Serial Converter"
 SerialNumber.l            ; // "FT000001" if fixed, or NULL
 MaxPower.w                 ; // 0 < MaxPower <= 500
 PnP.w                      ; // 0 = disabled, 1 = enabled
 SelfPowered.w              ; // 0 = bus powered, 1 = self powered
 RemoteWakeup.w             ; // 0 = not capable, 1 = capable
 ;//
 ;// Rev4 (FT232B) extensions
 ;//
 Rev4.c                     ; // non-zero if Rev4 chip, zero otherwise
 IsoIn.c                    ; // non-zero if in endpoint is isochronous
 IsoOut.c                   ; // non-zero if out endpoint is isochronous
 PullDownEnable.c           ; // non-zero if pull down enabled  SerNumEnable; // non-zero if serial number to be used 
 SerNumEnable.c             ; // non-zero if serial number to be used
 USBVersionEnable.c         ; // non-zero if chip uses USBVersion
 USBVersion.w               ; // BCD (0x0200 => USB2) //
 ;//
 ;// Rev 5 (FT2232) extensions
 ;//
 Rev5.c                     ; // non-zero if Rev5 chip, zero otherwise
 IsoInA.c                   ; // not implemented – set to 0
 IsoInB.c                   ; // not implemented – set to 0
 IsoOutA.c                  ; // not implemented – set to 0
 IsoOutB.c                  ; // not implemented – set to 0
 PullDownEnable5.c          ; // non-zero if pull down enabled
 SerNumEnable5.c            ; // non-zero if serial number to be used
 USBVersionEnable5.c        ; // non-zero if chip uses USBVersion
 USBVersion5.w              ; // BCD (0x0200 => USB2)
 AIsHighCurrent.c           ; // non-zero if interface is high current
 BIsHighCurrent.c           ; // non-zero if interface is high current
 IFAIsFifo.c                ; // non-zero if interface is 245 FIFO
 IFAIsFifoTar.c             ; // non-zero if interface is 245 FIFO CPU target
 IFAIsFastSer.c             ; // non-zero if interface is Fast serial
 AIsVCP.c                   ; // non-zero if interface is to use VCP drivers
 IFBIsFifo.c                ; // non-zero if interface is 245 FIFO
 IFBIsFifoTar.c             ; // non-zero if interface is 245 FIFO CPU target
 IFBIsFastSer.c             ; // non-zero if interface is Fast serial
 BIsVCP.c                   ; // non-zero if interface is to use VCP drivers
 ;//
 ;// Rev 6 (FT232R) extensions
 ;//
 UseExtOsc.c                ; // Use External Oscillator
 HighDriveIOs.c             ; // High Drive I/Os
 EndpointSize.c             ; // Endpoint size – this should always be 64
 PullDownEnableR.c          ; // non-zero if pull down enabled
 SerNumEnableR.c            ; // non-zero if serial number to be used
 InvertTXD.c                ; // non-zero if invert TXD
 InvertRXD.c                ; // non-zero if invert RXD
 InvertRTS.c                ; // non-zero if invert RTS
 InvertCTS.c                ; // non-zero if invert CTS
 InvertDTR.c                ; // non-zero if invert DTR
 InvertDSR.c                ; // non-zero if invert DSR
 InvertDCD.c                ; // non-zero if invert DCD
 InvertRI.c                 ; // non-zero if invert RI
 Cbus0.c                    ; // Cbus Mux control
 Cbus1.c                    ; // Cbus Mux control
 Cbus2.c                    ; // Cbus Mux control
 Cbus3.c                    ; // Cbus Mux control
 Cbus4.c                    ; // Cbus Mux control
 RIsD2XX.c                  ; // non-zero if using D2XX driver
 ;//
 ;// Rev 7 (FT2232H) Extensions
 ;//
 PullDownEnable7.c          ; // non-zero if pull down enabled
 SerNumEnable7.c            ; // non-zero if serial number to be used
 ALSlowSlew.c               ; // non-zero if AL pins have slow slew
 ALSchmittInput.c           ; // non-zero if AL pins are Schmitt input
 ALDriveCurrent.c           ; // valid values are 4mA, 8mA, 12mA, 16mA
 AHSlowSlew.c               ; // non-zero if AH pins have slow slew
 AHSchmittInput.c           ; // non-zero if AH pins are Schmitt input
 AHDriveCurrent.c           ; // valid values are 4mA, 8mA, 12mA, 16mA
 BLSlowSlew.c               ; // non-zero if BL pins have slow slew
 BLSchmittInput.c           ; // non-zero if BL pins are Schmitt input
 BLDriveCurrent.c           ; // valid values are 4mA, 8mA, 12mA, 16mA
 BHSlowSlew.c               ; // non-zero if BH pins have slow slew
 BHSchmittInput.c           ; // non-zero if BH pins are Schmitt input
 BHDriveCurrent.c           ; // valid values are 4mA, 8mA, 12mA, 16mA
 IFAIsFifo7.c               ; // non-zero if interface is 245 FIFO
 IFAIsFifoTar7.c            ; // non-zero if interface is 245 FIFO CPU target
 IFAIsFastSer7.c            ; // non-zero if interface is Fast serial
 AIsVCP7.c                  ; // non-zero if interface is to use VCP drivers
 IFBIsFifo7.c               ; // non-zero if interface is 245 FIFO
 IFBIsFifoTar7.c            ; // non-zero if interface is 245 FIFO CPU target
 IFBIsFastSer7.c            ; // non-zero if interface is Fast serial
 BIsVCP7.c                  ; // non-zero if interface is to use VCP drivers
 PowerSaveEnable.c          ; // non-zero if using BCBUS7 to save power for self- // powered designs
 ;//
 ;// Rev 8 (FT4232H) Extensions
 ;//
 PullDownEnable8.c          ; // non-zero if pull down enabled
 SerNumEnable8.c            ; // non-zero if serial number to be used
 ASlowSlew.c                ; // non-zero if AL pins have slow slew
 ASchmittInput.c            ; // non-zero if AL pins are Schmitt input
 ADriveCurrent.c            ; // valid values are 4mA, 8mA, 12mA, 16mA
 BSlowSlew.c                ; // non-zero if AH pins have slow slew
 BSchmittInput.c            ; // non-zero if AH pins are Schmitt input
 BDriveCurrent.c            ; // valid values are 4mA, 8mA, 12mA, 16mA
 CSlowSlew.c                ; // non-zero if BL pins have slow slew
 CSchmittInput.c            ; // non-zero if BL pins are Schmitt input
 CDriveCurrent.c            ; // valid values are 4mA, 8mA, 12mA, 16mA
 DSlowSlew.c                ; // non-zero if BH pins have slow slew
 DSchmittInput.c            ; // non-zero if BH pins are Schmitt input
 DDriveCurrent.c            ; // valid values are 4mA, 8mA, 12mA, 16mA
 ARIIsTXDEN.c               ; // non-zero if port A uses RI as RS485 TXDEN
 BRIIsTXDEN.c               ; // non-zero if port B uses RI as RS485 TXDEN
 CRIIsTXDEN.c               ; // non-zero if port C uses RI as RS485 TXDEN
 DRIIsTXDEN.c               ; // non-zero if port D uses RI as RS485 TXDEN
 AIsVCP8.c                  ; // non-zero if interface is to use VCP drivers
 BIsVCP8.c                  ; // non-zero if interface is to use VCP drivers
 CIsVCP8.c                  ; // non-zero if interface is to use VCP drivers
 DIsVCP8.c                  ; // non-zero if interface is to use VCP drivers
 ; //
  ; // Rev 9 (FT232H) Extensions
 ;//
 PullDownEnableH.c          ; // non-zero if pull down enabled
 SerNumEnableH.c            ; // non-zero if serial number to be used
 ACSlowSlewH.c              ; // non-zero if AC pins have slow slew
 ACSchmittInputH.c          ; // non-zero if AC pins are Schmitt input
 ACDriveCurrentH.c          ; // valid values are 4mA, 8mA, 12mA, 16mA
 ADSlowSlewH.c              ; // non-zero if AD pins have slow slew
 ADSchmittInputH.c          ; // non-zero if AD pins are Schmitt input
 ADDriveCurrentH.c          ; // valid values are 4mA, 8mA, 12mA, 16mA
 Cbus0H.c                   ; // Cbus Mux control
 Cbus1H.c                   ; // Cbus Mux control
 Cbus2H.c                   ; // Cbus Mux control
 Cbus3H.c                   ; // Cbus Mux control
 Cbus4H.c                   ; // Cbus Mux control
 Cbus5H.c                   ; // Cbus Mux control
 Cbus6H.c                   ; // Cbus Mux control
 Cbus7H.c                   ; // Cbus Mux control
 Cbus8H.c                   ; // Cbus Mux control
 Cbus9H.c                   ; // Cbus Mux control
 IsFifoH.c                  ; // non-zero if interface is 245 FIFO
 IsFifoTarH.c               ; // non-zero if interface is 245 FIFO CPU target
 IsFastSerH.c               ; // non-zero if interface is Fast serial
 IsFT1248H.c                ; // non-zero if interface is FT1248
 FT1248CpolH.c              ; // FT1248 clock polarity - clock idle high (1) or clock idle low (0)
 FT1248LsbH.c               ; // FT1248 data is LSB (1) or MSB (0)
 FT1248FlowControlH.c       ; // FT1248 flow control enable
 IsVCPH.c                   ; // non-zero if interface is to use VCP drivers
 PowerSaveEnableH.c         ; // non-zero if using ACBUS7 to save power for self-powered designs
EndStructure ;}
Structure FT_Device_List_Info_Node_struct ;{
 Flags.l
 Type.l
 ID.l
 LocId.l
 SerialNumber.c[16]
 Description.c[64]
 FT_Handle.i
EndStructure;}

;******************************** FTDI_Konstanten & Enumerations ***********************************************
#FT_InBuffer = 1024
#FT_OutBuffer = 1024
#FT_TX_Timeout = 1000  ; Milliseconds
#FT_RX_Timeout = 500  ; Milliseconds

;{ Konstanten FT
;FT_STATUS (DWORD)
 #FT_OK = 0
 #FT_INVALID_HANDLE = 1
 #FT_DEVICE_NOT_FOUND = 2
 #FT_DEVICE_NOT_OPENED = 3
 #FT_IO_ERROR = 4
 #FT_INSUFFICIENT_RESOURCES = 5
 #FT_INVALIDARAMETER = 6
 #FT_INVALID_BAUD_RATE = 7
 #FT_DEVICE_NOT_OPENED_FOR_ERASE = 8
 #FT_DEVICE_NOT_OPENED_FOR_WRITE = 9
 #FT_FAILED_TO_WRITE_DEVICE = 10
 #FT_EEPROM_READ_FAILED = 11
 #FT_EEPROM_WRITE_FAILED = 12
 #FT_EEPROM_ERASE_FAILED = 13
 #FT_EEPROM_NOTRESENT = 14
 #FT_EEPROM_NOTROGRAMMED = 15
 #FT_INVALID_ARGS = 16
 #FT_NOT_SUPPORTED = 17
 #FT_OTHER_ERROR = 18
 
 Global Dim FT_StateS.s(18)
 FT_StateS(0  ) = "00->FT_OK 0"
 FT_StateS(1  ) = "01->FT_INVALID_HANDLE"
 FT_StateS(2  ) = "02->FT_DEVICE_NOT_FOUND"
 FT_StateS(3  ) = "03->FT_DEVICE_NOT_OPENED"
 FT_StateS(4  ) = "04->FT_IO_ERROR"
 FT_StateS(5  ) = "05->FT_INSUFFICIENT_RESOURCES"
 FT_StateS(6  ) = "06->FT_INVALIDARAMETER"
 FT_StateS(7  ) = "07->FT_INVALID_BAUD_RATE"
 FT_StateS(8  ) = "08->FT_DEVICE_NOT_OPENED_FOR_ERASE"
 FT_StateS(9  ) = "09->FT_DEVICE_NOT_OPENED_FOR_WRITE"
 FT_StateS(10 ) = "10->FT_FAILED_TO_WRITE_DEVICE"
 FT_StateS(11 ) = "11->FT_EEPROM_READ_FAILED"
 FT_StateS(12 ) = "12->FT_EEPROM_WRITE_FAILED"
 FT_StateS(13 ) = "13->FT_EEPROM_ERASE_FAILED"
 FT_StateS(14 ) = "14->FT_EEPROM_NOTRESENT"
 FT_StateS(15 ) = "15->FT_EEPROM_NOTROGRAMMED"
 FT_StateS(16 ) = "16->FT_INVALID_ARGS"
 FT_StateS(17 ) = "17->FT_NOT_SUPPORTED"
 FT_StateS(18 ) = "18->FT_OTHER_ERROR"

 
 
;Flags (see FT_ListDevices)
 #FT_LIST_NUMBER_ONLY = $80000000
 #FT_LIST_BY_INDEX = $40000000
 #FT_LIST_ALL = $20000000

;Flags (see FT_OpenEx)
 #FT_OPEN_BY_SERIAL_NUMBER = 1
 #FT_OPEN_BY_DESCRIPTION = 2
 #FT_OPEN_BY_LOCATION = 4

;FT_DEVICE (DWORD)
 #FT_DEVICE_232BM = 0
 #FT_DEVICE_232AM = 1
 #FT_DEVICE_100AX = 2
 #FT_DEVICE_UNKNOWN = 3
 #FT_DEVICE_2232C = 4
 #FT_DEVICE_232R = 5
 #FT_DEVICE_2232H = 6
 #FT_DEVICE_4232H = 7
 #FT_DEVICE_232H = 8
 #FT_DEVICE_X_SERIES = 9
 
 
 
;Driver types
#FT_DRIVER_TYPE_D2XX = 0
#FT_DRIVER_TYPE_VCP = 1

;Word Length (see FT_SetDataCharacteristics)
 #FT_BITS_8 = 8
 #FT_BITS_7 = 7

;Stop Bits (see FT_SetDataCharacteristics)
 #FT_STOP_BITS_1 = 0
 #FT_STOP_BITS_2 = 2

;Parity (see FT_SetDataCharacteristics)
 #FT_PARITY_NONE = 0
 #FT_PARITY_ODD = 1
 #FT_PARITY_EVEN = 2
 #FT_PARITY_MARK = 3
 #FT_PARITY_SPACE = 4

;Flow Control
 #FT_FLOW_NONE = $0000
 #FT_FLOW_RTS_CTS = $0100
 #FT_FLOW_DTR_DSR = $0200
 #FT_FLOW_XON_XOFF = $0400

;Purge RX and TX Buffers (see FTurge)
 #FT_PURGE_RX = 1
 #FT_PURGE_TX = 2

;Notification Events (see FT_SetEventNotification)
 #FT_EVENT_RXCHAR = 1
 #FT_EVENT_MODEM_STATUS = 2
 #FT_EVENT_LINE_STATUS = 4


;Line Status (see FT_GetModemStatus)
 #FT_OE = $02
 #FT_PE = $04
 #FT_FE = $08
 #FT_BI = $10
 #FT_CTS = $10
 #FT_DSR = $20
 #FT_RI = $40
 #FT_DCD = $80
 

; Bit Modes (see FT_SetBitMode)
 #FT_Reset = $00
 #FT_Asynchronous_Bit_Bang = $01
 #FT_MPSSE = $02
 #FT_Synchronous_Bit_Bang = $04
 #FT_MCU_Host_Bus_Emulation = $08
 #FT_Fast_Opto_Isolated_Serial_Mode = $10
 #FT_CBUS_Bit_Bang = $20
 #FT_Single_Channel_Synchronous_245_FIFO_Mode = $40

;FT232R CBUS EEPROM OPTIONS - Ignored For FT245R (see FT_EErogram And FT_EE_Read)
 #FT_CBUS_TXDEN = $00
 #FT_CBUSWRON = $01
 #FT_CBUS_RXLED = $02
 #FT_CBUS_TXLED = $03
 #FT_CBUS_TXRXLED = $04 
 #FT_CBUS_SLEEP = $05
 #FT_CBUS_CLK48 = $06
 #FT_CBUS_CLK24 = $07
 #FT_CBUS_CLK12 = $08
 #FT_CBUS_CLK6 = $09
 #FT_CBUS_IOMODE = $0A
 #FT_CBUS_BITBANG_WR = $0B
 #FT_CBUS_BITBANG_RD = $0C

;FT_FLAGS (see FT_DEVICE_LIST_INFO_NODE)
 #FT_FLAGS_OPENED = $00000001
 #FT_FLAGS_HISPEED = $00000002

;Modem Status (see FT_GetModemStatus)
 #FT_CTS = $10
 #FT_DSR = $20
 #FT_RI = $40
 #FT_DCD = $80

; FT Event
 #FT_EVENT_RXCHAR = 1
 #FT_EVENT_MODEM_STATUS = 2

 #FT_BAUD_9600 = 9600
 #FT_BAUD_19200 = 19200

 #FT_EVENT_RXCHAR = 1
 #FT_EVENT_MODEM_STATUS = 2
 

;}

;**************************************** FTDI Vars ************************************************************

Global Dim FT_Typ.s (7) ;{
    FT_Typ (0) = "FT_DEVICE_232BM"
    FT_Typ (1) = "FT_DEVICE_232AM"
    FT_Typ (2) = "FT_DEVICE_100AX"
    FT_Typ (3) = "FT_DEVICE_UNKNOWN"
    FT_Typ (4) = "FT_DEVICE_2232C"
    FT_Typ (5) = "FT_DEVICE_232R"
    FT_Typ (6) = "FT_DEVICE_2232H"
    FT_Typ (7) = "FT_DEVICE_4232H"   ;}

Global Dim FT_DevInfo.FT_Device_List_Info_Node_struct(1)
Global *FT_DevInfo = @FT_DevInfo(0)
Global Dim FT_Prog_Info.FT_Prog_Info_S(1)                       ; Redim nachdem die Anzahl bekannt ist
Global FT_Status.l                                       ; Status in FT Operationen
Global FT_NumDevs.l                                      ; Number of devices connected.
Global *FT_NumDevs =@FT_NumDevs               
Global FT_PROGRAM_DATA.ft_Program_data_struct   
Global *FT_PROGRAM_DATA = @FT_PROGRAM_DATA
Global Dim FT_ManufacturerBuf.c(32)
Global Dim FT_ManufacturerIdBuf.c(16)
Global Dim FT_DescriptionBuf.c(64)
Global Dim FT_SerialNumberBuf.c(16)
 FT_PROGRAM_DATA\Signature1 = $00000000
 FT_PROGRAM_DATA\Signature2 = $ffffffff
 FT_PROGRAM_DATA\Version = $00000000                       
 FT_PROGRAM_DATA\Manufacturer = @FT_ManufacturerBuf(0)
 FT_PROGRAM_DATA\ManufacturerId = @FT_ManufacturerIdBuf(0)
 FT_PROGRAM_DATA\Description = @FT_DescriptionBuf(0)
 FT_PROGRAM_DATA\SerialNumber = @FT_SerialNumberBuf(0)
Global FT_Manufacturer.s = Space(100)
Global *FT_Manufacturer = @FT_Manufacturer
Global FT_ManufacturID.s = Space(100)
Global *FT_ManufacturID = @FT_ManufacturID
Global FT_Description.s = Space(100)
Global *FT_Description = @FT_Description
Global FT_SerialNumber.s  = Space(100)
Global *FT_SerialNumber =@FT_SerialNumber
Global FT_DLLVersion.l
Global *FT_DLLVersion = @FT_DLLVersion
Global FT_DriverVersion.l = 0
Global *FT_DriverVersion = @FT_DriverVersion
Global FT_Handle.l
Global *FT_Handle = @FT_Handle
Global FT_BytesWritten.w
Global *FT_BytesWritten = @FT_BytesWritten
Global FT_RxBytes.l
Global *FT_RxBytes = @FT_RxBytes
Global FT_TxBytes.l
Global *FT_TxBytes = @FT_TxBytes
Global FT_BytesReceived.l
Global *FT_BytesReceived = @FT_BytesReceived
Global FT_ComPortNumber.l
Global *FT_ComPortNumber = @FT_ComPortNumber
Global FT_lpdwDriverVersion.l = 0
Global *FT_lpdwDriverVersion= @FT_lpdwDriverVersion
Global FT_WordLength.l = 0
Global FT_StopBits.l= 0
Global FTarity.l= 0
Global FT_Handle.l = 0
Global FT_Device.l=0                                      ; Device Nummer
Global FT_ModemStatus.l
Global *FT_ModemStatus = @FT_ModemStatus
Global FT_EventStatus.l
Global *FT_EventStatus = @FT_EventStatus

Global FT_Flags = 0
Global *FT_Flags = @FT_Flags
Global FT_ID.l=0
Global *FT_ID = @FT_ID
Global FT_LocID.l=0
Global *FT_LocID = @FT_LocID

Global FT_Typ.l=0
Global *FT_Typ = @FT_Typ

Global FT_Library.i = OpenLibrary(#PB_Any, FTDIfile) 



If Not FT_library
 MessageRequester("Error",FTDIfile)
  ;CompilerIf #DLLwork = 0
    End
  ;CompilerEndIf
EndIf 


Global *FT_Inbuffer
Global *FT_InPointer
*FT_Inbuffer= AllocateMemory(#FT_InBuffer)
*FT_InPointer = *FT_InBuffer

If *FT_Inbuffer = 0
  MessageRequester("Error","Error Locate FTDI In Buffer")
  ;CompilerIf #DLLwork = 0
  ;  End
  ;CompilerEndIf
EndIf   

 

Global *FT_Outbuffer
Global *FT_OutPointer
*FT_OutBuffer= AllocateMemory(#FT_OutBuffer)
*FT_OutPointer = *FT_OutBuffer

If *FT_Outbuffer = 0
  MessageRequester("Error","Error Locate FTDI Out Buffer")
  ;CompilerIf #DLLwork = 0
  ;  End
  ;CompilerEndIf 
EndIf   


Procedure FtdiDeInit()
  CloseLibrary(FT_Library)
EndProcedure



Procedure.i CheckFunction(Library.i,Name.s)
  If GetFunction(Library.i,Name)
    ProcedureReturn GetFunction(Library.i,Name)
  Else
    MessageRequester("Error", "Can't find Function "+Name+" in Library.")
    CompilerIf #DLLwork = 0
      End
    CompilerEndIf
  EndIf
EndProcedure 



Procedure.s FT_wandeln (Wert.l)
   ProcedureReturn RSet(Hex((Wert & (255 <<16))>>16),2,"0")+"."+RSet(Hex((Wert & (255 <<8))>>8),2,"0")+"."+RSet(Hex(Wert & 255),2,"0")
EndProcedure   



CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
      PrototypeOS ProtoFT_GetLibraryVersion(*FT_DLLVersion)
    CompilerCase #PB_OS_Linux
      PrototypeOS ProtoFT_GetLibraryVersion(*FT_DLLVersion)
CompilerEndSelect

Global FT_GetLibraryVersion.ProtoFT_GetLibraryVersion = CheckFunction(FT_Library, "FT_GetLibraryVersion")


PrototypeOS ProtoFT_CreateDeviceInfoList (*FT_NumDevs)
Global FT_CreateDeviceInfoList.ProtoFT_CreateDeviceInfoList = CheckFunction(Ft_Library, "FT_CreateDeviceInfoList")

PrototypeOS ProtoFT_GetDeviceInfoList(*FT_DevInfo,FT_NumDevs.l)
Global FT_GetDeviceInfoList.ProtoFT_GetDeviceInfoList = CheckFunction(FT_Library,"FT_GetDeviceInfoList")


PrototypeOS.l ProtoFT_Open(FT_Device.l,*FT_Handle)
Global FT_Open.ProtoFT_Open = CheckFunction(FT_Library,"FT_Open")


PrototypeOS ProtoFT_openEx_Serial(Serial.s,dwFlags.l,*FT_Handle)
Global FT_openEx_Serial.ProtoFT_openEx_Serial = CheckFunction(FT_Library, "FT_OpenEx")

PrototypeOS ProtoFT_close (FT_Handle.l)
Global FT_close.ProtoFT_close = CheckFunction(FT_library, "FT_Close")

PrototypeOS ProtoFT_GetdriverVersion(FT_Handle.l,*FT_lpdwDriverVersion)
Global  FT_GetdriverVersion.ProtoFT_GetdriverVersion = CheckFunction(FT_Library,"FT_GetDriverVersion")


PrototypeOS ProtoFT_SetBaudRate(FT_Handle,FT_BaudRate)
Global FT_SetBaudRate.ProtoFT_SetBaudRate = CheckFunction(FT_Library,"FT_SetBaudRate")

PrototypeOS ProtoFT_SetDataCharacteristics (FT_HANDLE.l,FT_WordLength.c,FT_StopBits.c,FT_Parity.c)
Global FT_SetDataCharacteristic.ProtoFT_SetDataCharacteristics = CheckFunction(FT_Library,"FT_SetDataCharacteristics")

PrototypeOS ProtoFT_SetTimeouts (FT_Handle.l,FT_ReadTimeout.l,FT_WriteTimeout.l)
Global T_SetTimeouts.ProtoFT_SetTimeouts = CheckFunction(FT_Library.i,"FT_SetTimeouts")

PrototypeOS ProtoFT_SetFlowControl (FT_Handle.l,FT_FlowControl.w,FT_Xon.c,FT_Xoff.c)
Global  FT_SetFlowControl.ProtoFT_SetFlowControl = CheckFunction(FT_Library.i,"FT_SetFlowControl")

PrototypeOS ProtoFT_Write (FT_Handle.l,*FT_OutPointer,FT_BytesToWrite.w,*FT_BytesWritten)
Global FT_Write.ProtoFT_Write = CheckFunction(FT_Library,"FT_Write")

PrototypeOS ProtoFT_Read (FT_Handle.l,*FT_InBuffer,FT_RxBytes.l,*FT_BytesReceived)
Global FT_Read.ProtoFT_Read = CheckFunction(FT_Library,"FT_Read")

PrototypeOS ProtoFT_GetQueueStatus (FT_Handle.l,*FT_RxBytes)
Global FT_GetQueueStatus.ProtoFT_GetQueueStatus = CheckFunction(FT_Library,"FT_GetQueueStatus")

PrototypeOS ProtoFT_GetStatus (FT_Handle.l,*FT_RxBytes,*FT_TxBytes,*FT_E)
Global FT_GetStatus.ProtoFT_GetStatus = CheckFunction(FT_Library,"FT_GetStatus")


PrototypeOS ProtoFT_GetComPortNumber (FT_Handle.l,*FT_ComPortNumber)
Global FT_GetComPortNumber.ProtoFT_GetComPortNumber = CheckFunction(FT_Library,"FT_GetComPortNumber")

PrototypeOS ProtoFT_SetLatencyTimer(FT_Handle.l,ucTimer.c)
Global FT_SetLatencyTimer.ProtoFT_SetLatencyTimer = CheckFunction(FT_Library,"FT_SetLatencyTimer")


PrototypeOS ProtoFT_GetDeviceInfoDetail(FT_Device.l,*FT_Flags,*FT_Type,*FT_ID,*FT_LocID,*FT_SerialNumber,*FT_Description,*FT_Handle)
Global FT_GetDeviceInfoDetail.ProtoFT_GetDeviceInfoDetail = CheckFunction(FT_Library,"FT_GetDeviceInfoDetail")                                       

; PrototypeOS ProtoFT_SetBitmode (FT_Handle.l, FT_ucMask.c, FT_ucMode.c)
; Global FT_SetBitmode.ProtoFT_SetBitmode = CheckFunction(FT_Library,"FT_SetBitmode")
;
; PrototypeOS ProtoFT_GetBitmode (FT_Handle.l, FTucMode.c)
; Global FT_GetBitmode.ProtoFT_GetBitmode = CheckFunction(FT_Library,"FT_GetBitmode")

PrototypeOS.l ProtoFT_SetDtr(FT_Handle.l)
Global FT_SetDtr.ProtoFT_SetDtr = CheckFunction(FT_Library,"FT_SetDtr")

PrototypeOS.l ProtoFT_ClrDtr(FT_Handle.l)
Global FT_ClrDtr.ProtoFT_ClrDtr = CheckFunction(FT_Library,"FT_ClrDtr")

PrototypeOS.l ProtoFT_SetRts(FT_Handle.l)
Global FT_SetRts.ProtoFT_SetRts = CheckFunction(FT_Library,"FT_SetRts")

PrototypeOS.l ProtoFT_ClrRts(FT_Handle.l)
Global FT_ClrRts.ProtoFT_ClrRts = CheckFunction(FT_Library,"FT_ClrRts")

PrototypeOS ProtoFT_EE_READ(FT_Handle.l,*FT_Program_Data)
Global FT_EE_READ.ProtoFT_EE_READ = CheckFunction(FT_Library,"FT_EE_Read")

PrototypeOS ProtoFT_EE_Program(FT_Handle.l,*FT_Program_Data)
Global FT_EE_Program.ProtoFT_EE_Program = CheckFunction(FT_Library,"FT_EE_Program")

PrototypeOS ProtoFT_GetModemStatus(FT_Handle.l,*FT_ModemStatus)
Global FT_GetModemStatus.ProtoFT_GetModemStatus = CheckFunction(FT_Library,"FT_GetModemStatus")

PrototypeOS ProtoFT_Purge(FT_Handle.l,FT_Purge.l)
Global FT_Purge.ProtoFT_Purge = CheckFunction(FT_Library,"FT_Purge")

Procedure.l FT_Device_by_SerialNumberPart (Part.s,len.l)      ; Sucht die Device ID zur TeilSernummer, Len=0 Länge Egal
  Protected.i Result
  Protected.l i.l,Flag.l,Type.l,ID.l,LocID.l,Hdl
  Protected *pcSerialNumber,*pcDescription
 
  *pcSerialNumber = AllocateMemory(128)
  *pcDescription = AllocateMemory(128)
 
  If (*pcSerialNumber=0) Or (*pcDescription=0)
    ProcedureReturn -3
  EndIf
 
  For i = 0 To  FT_NumDevs -1
    Result = i
    If FT_GetDeviceInfoDetail(i,@Flag,@Type,@ID,@LocID,*pcSerialNumber,*pcDescription,@Hdl) <> #FT_ok
      Result = -2
      Break
    Else
      If Len
        If Len(PeekS(*pcSerialNumber,128,#PB_Ascii)) <> len
          Result = -1
        EndIf   
      EndIf   
     
      If Result > -1
        If Left(PeekS(*pcSerialNumber,128,#PB_Ascii),Len(Part)) = Part
          Break
        Else
          Result = -1
        EndIf
      EndIf   
    EndIf   
  Next I
 
  FreeMemory(*pcDescription)
  FreeMemory(*pcSerialNumber)
  ProcedureReturn result
EndProcedure




auszüge aus dem
.h file im original aus der 64Bit Version

Code:
typedef PVOID   FT_HANDLE;
typedef ULONG   FT_STATUS;



FTD2XX_API
      FT_STATUS WINAPI FT_GetDeviceInfoDetail(
      DWORD dwIndex,
      LPDWORD lpdwFlags,
      LPDWORD lpdwType,
      LPDWORD lpdwID,
      LPDWORD lpdwLocId,
      LPVOID lpSerialNumber,
      LPVOID lpDescription,
      FT_HANDLE *pftHandle
      );




Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: FTDI D2XX Driver 64Bit
BeitragVerfasst: 28.07.2020 10:49 
Offline
Benutzeravatar

Registriert: 22.12.2016 12:49
Wohnort: :D_üsseldorf-Wersten
Hallo Joshua314,

der zweite Parameter von PeekS ist die Länge.

Code:
    Debug PeekS(*pcSerialNumber,-1,#PB_Ascii)
    ShowMemoryViewer(*pcSerialNumber,128)


Gruß


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: FTDI D2XX Driver 64Bit
BeitragVerfasst: 28.07.2020 21:45 
Offline

Registriert: 06.04.2005 22:44
juergenkulow hat geschrieben:
Hallo Joshua314,

der zweite Parameter von PeekS ist die Länge.

Code:
    Debug PeekS(*pcSerialNumber,-1,#PB_Ascii)
    ShowMemoryViewer(*pcSerialNumber,128)


Gruß



Erster Test.... und schon geht es bei UTF8 und UTF32

jetzt teste ich noch die anderen Befehle.....

Danke an juergenkulow

Gruß Thomas


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: Programie und 15 Gäste


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye