Voor USB communicatie tussen een PIC en de PC, gebruik ik de DLL libusb0.dll.
De PC progjes maak in in Delphi.
Nu wil ik ook een Visual Basic versie maken.

Heeft iemand ervaring met Visual Basic samen met libusb0.dll ?

Mod's: Even voor de duidelijkheid, dit gaat inderdaad over software. Maar dit is specifiek voor een PIC bedoeld !

Martijn v

KIS!!: Keep It Simple

geen ervaring, maar wat wil je weten?

[Bericht gewijzigd door Martijn v op donderdag 28 december 2006 13:21:38 ]

Hoe ik met Visual Basic 6 kan communiceren met die DLL.

Martijn v

KIS!!: Keep It Simple

'k heb het driverproject gedownload, maar sjit dat is een hoop.., ik heb wel een bestand gevonden.
Zipfile/Docs/Function.sgml, daar staat een lang verhaal over welke functie's erzijn.

dit is de eerste die je moet aanroepen:

usb_init

er staat idd niet bij hoe de code dan zou moeten zijn.
maar ik denk, dat je best dit kunt proberen:


Public Declare sub mms_USB_Init Lib "LIBusb0.dll" Alias "usb_init" 

of

Public Declare Function mms_USB_Init Lib "LIBusb0.dll" Alias "usb_init" () As Long

das dan de declaratie van de API, en dan moet je natuurlijk nog het commando zelf geven.


mms_Usb_init

Ik ga een poging doen....

Wil je dat bestand mailen ?

Martijn v

KIS!!: Keep It Simple

'k wil het best mailen, maar je hebt het toch al?
en trouwens, kwenie zo goed waarvoor het is, maar als je BV zon USB setje van VOTI aan het spelen bent, dat zijn chips van FTDI, die hebben ook een DLL, met veel goede voorbeelden.
http://www.ftdichip.com/Projects/CodeExamples/VB.htm

k wil het best mailen, maar je hebt het toch al?

Als je dit bedoeld, dan weet ik niet wat ik hermee moet: Zipfile/Docs/Function.sgml

Public Declare sub mms_USB_Init Lib "LIBusb0.dll" Alias "usb_init"
of
Public Declare Function mms_USB_Init Lib "LIBusb0.dll" Alias "usb_init" () As Long

Kan je/iemand hier iets meer over vertellen, ik krijg alleen maar fout meldingen ?

[Bericht gewijzigd door MMSoft op donderdag 28 december 2006 14:25:39 ]

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

is dat de libusb van sourceforge ? ( mensen wat een draak is me dat geworden zeg. vroeger was het simpel klikkerdeklik om iets te downloaden daar. nu ben je 1) verblind door alle toeters en bellen , alle reclame die rond je oren zoeft , en moet je ene half uur lezen om te vinden waar je nu juist moet klikken om iets te krijgen... )

kzal sebiet ne keer kijken om de calls te porteren naar VB.

ik was net ook aant zien om iets te doen met libusb ... en kheb het zelf toch ook nodig.

der is een leuek tool die je kan downloaden (gratis) bij microsoft om in DLL's te neuzen om te kijken welke functies ze exporteren..
dat ding noemt Dependency Walker.

het analyseert eender welke DLL of EXe en toont de lijst van ge-exporteerde calls en ook welke andere libraries die file nodig heeft enzovoort.

hee leuk om te zien welke files een programma allemaal nodig heeft....

[Bericht gewijzigd door free_electron op donderdag 28 december 2006 17:12:22 ]

Martijn v

KIS!!: Keep It Simple

These functions comprise the core of libusb. They are used by all applications that utilize libusb.
usb_init

Initialize libusb void usb_init Just like the name implies, usb_init sets up some internal structures. usb_init must be called before any other libusb functions.
usb_find_busses
Finds all USB busses on system int usb_find_busses usb_find_busses will find all of the busses on the system. Returns the number of changes since previous call to this function (total of new busses and busses removed).
usb_find_devices
Find all devices on all USB devices int usb_find_devices usb_find_devices will find all of the devices on each bus. This should be called after . Returns the number of changes since the previous call to this function (total of new device and devices removed).
usb_get_busses
Return the list of USB busses found struct usb_bus *usb_get_busses usb_get_busses simply returns the value of the global variable usb_busses. This was implemented for those languages that support C calling convention and can use shared libraries, but don't support C global variables (like Delphi). This group of functions deal with the device. It allows you to open and close the device as well standard USB operations like setting the configuration, alternate settings, clearing halts and resetting the device. It also provides OS level operations such as claiming and releasing interfaces.
usb_open
Opens a USB device usb_dev_handle *usb_open struct *usb_device dev usb_open is to be used to open up a device for use. usb_open must be called before attempting to perform any operations to the device. Returns a handle used in future communication with the device.
usb_close
Closes a USB device int usb_close usb_dev_handle *dev usb_close closes a device opened with . No further operations may be performed on the handle after usb_close is called. Returns 0 on success or < 0 on error.
usb_set_configuration
Sets the active configuration of a device int usb_set_configuration usb_dev_handle *dev int configuration usb_set_configuration sets the active configuration of a device. The configuration parameter is the value as specified in the descriptor field bConfigurationValue. Returns 0 on success or < 0 on error.
usb_set_altinterface
Sets the active alternate setting of the current interface int usb_set_altinterface usb_dev_handle *dev int alternate usb_set_altinterface sets the active alternate setting of the current interface. The alternate parameter is the value as specified in the descriptor field bAlternateSetting. Returns 0 on success or < 0 on error. usb_resetep
Resets state for an endpoint int usb_resetep usb_dev_handle *dev unsigned int ep usb_resetep resets all state (like toggles) for the specified endpoint. The ep parameter is the value specified in the descriptor field bEndpointAddress. Returns 0 on success or < 0 on error.
usb_resetep is deprecated. You probably want to use .
usb_clear_halt
Clears any halt status on an endpoint int usb_clear_halt usb_dev_handle *dev unsigned int ep usb_clear_halt clears any halt status on the specified endpoint. The ep parameter is the value specified in the descriptor field bEndpointAddress. Returns 0 on success or < 0 on error.
usb_reset
Resets a device int usb_reset usb_dev_handle *dev usb_reset resets the specified device by sending a RESET down the port it is connected to. Returns 0 on success or < 0 on error. After calling usb_reset, the device will need to re-enumerate and thusly, requires you to find the new device and open a new handle. The handle used to call usb_reset will no longer work.
usb_claim_interface
Claim an interface of a device int usb_claim_interface usb_dev_handle *dev int interface usb_claim_interface claims the interface with the Operating System. The interface parameter is the value as specified in the descriptor field bInterfaceNumber. Returns 0 on success or < 0 on error. usb_claim_interface must be called before you perform any operations related to this interface (like , , etc). code description -EBUSY Interface is not available to be claimed -ENOMEM Insufficient memory
usb_release_interface
Releases a previously claimed interface int usb_release_interface usb_dev_handle *dev int interface usb_release_interface releases an interface previously claimed with . The interface parameter is the value as specified in the descriptor field bInterfaceNumber. Returns 0 on success or < 0 on error. This group of functions allow applications to send messages to the default control pipe.
usb_control_msg
Send a control message to a device int usb_control_msg usb_dev_handle *dev int requesttype int request int value int index char *bytes int size int timeout usb_control_msg performs a control request to the default control pipe on a device. The parameters mirror the types of the same name in the USB specification. Returns number of bytes written/read or < 0 on error.
usb_get_string
Retrieves a string descriptor from a device int usb_get_string usb_dev_handle *dev int index int langid char *buf size_t buflen usb_get_string retrieves the string descriptor specified by index and langid from a device. The string will be returned in Unicode as specified by the USB specification. Returns the number of bytes returned in buf or < 0 on error. usb_get_string_simple Retrieves a string descriptor from a device using the first language int usb_get_string_simple usb_dev_handle *dev int index char *buf size_t buflen
usb_get_string_simple
is a wrapper around usb_get_string that retrieves the string description specified by index in the first language for the descriptor and converts it into C style ASCII. Returns number of bytes returned in buf or < 0 on error.
usb_get_descriptor
Retrieves a descriptor from a device's default control pipe int usb_get_descriptor usb_dev_handle *dev unsigned char type unsigned char index void *buf int size usb_get_descriptor retrieves a descriptor from the device identified by the type and index of the descriptor from the default control pipe. Returns number of bytes read for the descriptor or < 0 on error. See for a function that allows the control endpoint to be specified.
usb_get_descriptor_by_endpoint
Retrieves a descriptor from a device int usb_get_descriptor_by_endpoint usb_dev_handle *dev int ep unsigned char type unsigned char index void *buf int size usb_get_descriptor_by_endpoint retrieves a descriptor from the device identified by the type and index of the descriptor from the control pipe identified by ep. Returns number of bytes read for the descriptor or < 0 on error. This group of functions allow applications to send and receive data via bulk pipes.
usb_bulk_write Write
data to a bulk endpoint int usb_bulk_write usb_dev_handle *dev int ep char *bytes int size int timeout usb_bulk_write performs a bulk write request to the endpoint specified by ep. Returns number of bytes written on success or < 0 on error.
usb_bulk_read
Read data from a bulk endpoint int usb_bulk_read usb_dev_handle *dev int ep char *bytes int size int timeout usb_bulk_read performs a bulk read request to the endpoint specified by ep. Returns number of bytes read on success or < 0 on error. This group of functions allow applications to send and receive data via interrupt pipes.
usb_interrupt_write
Write data to an interrupt endpoint int usb_interrupt_write usb_dev_handle *dev int ep char *bytes int size int timeout usb_interrupt_write performs an interrupt write request to the endpoint specified by ep. Returns number of bytes written on success or < 0 on error.
usb_interrupt_read
Read data from a interrupt endpoint int usb_interrupt_read usb_dev_handle *dev int ep char *bytes int size int timeout usb_interrupt_read performs a interrupt read request to the endpoint specified by ep. Returns number of bytes read on success or < 0 on error. These functions are non portable. They may expose some part of the USB API on one OS or perhaps a couple, but not all. They are all marked with the string _np at the end of the function name. A C preprocessor macro will be defined if the function is implemented. The form is LIBUSB_HAS_ prepended to the function name, without the leading "usb_", in all caps. For example, if usb_get_driver_np is implemented, LIBUSB_HAS_GET_DRIVER_NP will be defined.
usb_get_driver_np
Get driver name bound to interface int usb_get_driver_np usb_dev_handle *dev int interface char *name int namelen This function will obtain the name of the driver bound to the interface specified by the parameter interface and place it into the buffer named name limited to namelen characters. Returns 0 on success or < 0 on error. Implemented on Linux only.
usb_detach_kernel_driver_np
Detach kernel driver from interface int usb_detach_kernel_driver_np usb_dev_handle *dev int interface This function will detach a kernel driver from the interface specified by parameter interface. Applications using libusb can then try claiming the interface. Returns 0 on success or < 0 on error. Implemented on Linux only.

je hebt dus nog een stel structures nodig zoals ik het lees. maar die heb ik nog niet gevonden...

Henry S.

Moderator

Deze post is niet door ChatGPT gegenereerd. De 2019 CO labvoeding.

Kan je misschien iets highlighten wat van belang is? Of zijn alle enters vervallen?

Deze Cut&Paste is een onleesbare brei, post een linkje.

Martijn v

KIS!!: Keep It Simple

Op 28 december 2006 17:11:19 schreef free_electron:
is dat de libusb van sourceforge ? vroeger was het simpel klikkerdeklik om iets te downloaden daar. nu ben je 1) verblind door alle toeters en bellen , alle reclame die rond je oren zoeft , en moet je ene half uur lezen om te vinden waar je nu juist moet klikken om iets te krijgen... )
Dependency Walker.

ja dus, libusb.dll versie x.1.12
'k heb ook een versie x.1.17 gevonden, maar om een *.exe te draaien met dat soort rotzooi, nee dankje

Dependency Walker zit standaard bij de enterprise edition van VB6 :)

- wat voor USB gebruik TS, en heeft die fabriekant geen code voorbeelden?
- het werkt al wel in delphi ?, laat die code zien dan :)

@ henry: 'k heb geen vieuwer voor *.sgml, maar als je *.html van maakt wordt het dus dit.

Henry S.

Moderator

Deze post is niet door ChatGPT gegenereerd. De 2019 CO labvoeding.

Zo is het tenminste leesbaar.

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

post eens de delphi code.

diene C rommel is compleet onleesbaar. structs met struct in , structs die naar elkaar pointen ... zucht ... 'open sores' ...

kan er nu echt eens niemand meer leesbare, niet cryptische, simpele code schrijven...

[Bericht gewijzigd door free_electron op donderdag 28 december 2006 20:44:24 ]

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

de function prototypes zijn het probleem niet

tis die structs converteren.
laat eens de pascl definietie zien van bijvoorbeeld
USB_device... ( das ene waar een geforwarde struct gebruikt wordt. als ik dat opgelost krijg is het probleme weg . )

Martijn v

KIS!!: Keep It Simple

als je het nou ff hier neerzet..

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

dit heb ik al

' twee woorden uitleg
' shortint in C is een Integer in VB
' Char is een byte in VB

'Device and/or Interface Class codes
    Const USB_CLASS_PER_INTERFACE = 0
    Const USB_CLASS_AUDIO = 1
    Const USB_CLASS_COMM = 2
    Const USB_CLASS_HID = 3
    Const USB_CLASS_PRINTER = 7
    Const USB_CLASS_MASS_STORAGE = 8
    Const USB_CLASS_HUB = 9
    Const USB_CLASS_DATA = 10
    Const USB_CLASS_VENDOR_SPEC = &HFF
'Descriptor types
    Const USB_DT_DEVICE = &H1
    Const USB_DT_CONFIG = &H2
    Const USB_DT_STRING = &H3
    Const USB_DT_INTERFACE = &H4
    Const USB_DT_ENDPOINT = &H5
    Const USB_DT_HID = &H21
    Const USB_DT_REPORT = &H22
    Const USB_DT_PHYSICAL = &H23
    Const USB_DT_HUB = &H29
'Descriptor sizes per descriptor type
    Const USB_DT_DEVICE_SIZE = 18
    Const USB_DT_CONFIG_SIZE = 9
    Const USB_DT_INTERFACE_SIZE = 9
    Const USB_DT_ENDPOINT_SIZE = 7
    Const USB_DT_ENDPOINT_AUDIO_SIZE = 9
    Const USB_DT_HUB_NONVAR_SIZE = 7
'Enpoint Descriptors...
    Const USB_MAXENDPOINTS = 32
    Const USB_ENDPOINT_ADDRESS_MASK = &HF
    Const USB_ENDPOINT_DIR_MASK = &H80
    Const USB_ENDPOINT_TYPE_MASK = &H3
    Const USB_ENDPOINT_TYPE_CONTROL = 0
    Const USB_ENDPOINT_TYPE_ISOCHRONOUS = 1
    Const USB_ENDPOINT_TYPE_BULK = 2
    Const USB_ENDPOINT_TYPE_INTERRUPT = 3
'Diverse
    Const USB_MAXINTERFACES = 32
    Const USB_MAXALTSETTING = 128
    Const USB_MAXCONFIG = 8
'Standard requests
    Const USB_REQ_GET_STATUS = &H0
    Const USB_REQ_CLEAR_FEATURE = &H1
    Const USB_REQ_SET_FEATURE = &H3
    Const USB_REQ_SET_ADDRESS = &H5
    Const USB_REQ_GET_DESCRIPTOR = &H6
    Const USB_REQ_SET_DESCRIPTOR = &H7
    Const USB_REQ_GET_CONFIGURATION = &H8
    Const USB_REQ_SET_CONFIGURATION = &H9
    Const USB_REQ_GET_INTERFACE = &HA
    Const USB_REQ_SET_INTERFACE = &HB
    Const USB_REQ_SYNCH_FRAME = &HC
    Const USB_TYPE_STANDARD = 0
    Const USB_TYPE_CLASS = &H20       ' (0x01 << 5)  waarschijnlijk shift left ...
    Const USB_TYPE_VENDOR = &H40      ' (0x02 << 5) dus ik heb de boel al geshift
    Const USB_TYPE_RESERVED = &H60     '(0x03 << 5) hier
    Const USB_RECIP_DEVICE = &H0
    Const USB_RECIP_INTERFACE = &H1
    Const USB_RECIP_ENDPOINT = &H2
    Const USB_RECIP_OTHER = &H3
    Const LIBUSB_PATH_MAX = 512
    Const USB_ENDPOINT_IN = &H80
    Const USB_ENDPOINT_OUT = &H0
    Const USB_ERROR_BEGIN = 500000
' Data structures
Type USB_Descriptor_Header
     bLength As Byte
     bDescriptorType As Byte
End Type
Type USB_String_descriptor
     bLength As Byte
     bDescriptorType As Byte
     wdata As Integer
End Type
Type USB_Hid_Descriptor
     bLength As Byte
     bDescriptorType As Byte
     bcdHID As Integer
     bCountrycode As Byte
     bNumdescriptors As Byte
End Type
Type USB_Endpoint_Descriptor
     bLength As Byte
     bDescriptorType As Byte
     bEndpointaddress As Byte
     bmAttributes As Byte
     wMaxPacketSize As Integer
     bInterval As Byte
     bRefresh As Byte
     bSynchAddress As Byte
     '  hier zit een klotepointer naar een andere struct :    *extra as Byte
     extralen As Integer
End Type

Type USB_Device
     filename(LIBUSB_PATH_MAX) As Byte
     Bus As Byte ' USB_Bus
     Descriptor As Byte ' dit is een geforwarde struct :  USB_Device_Descriptor
     Config As Byte ' dit is een geforwarde struct : USB_Config_Descriptor
End Type

Type USB_Bus
     DirName(LIBUSB_PATH_MAX) As Byte
     Devices As Byte ' geforwarde struct: USB_Device
     Location As Single
End Type
 
Type USB_Device_Descriptor
     bLength As Byte
     bDescriptorType As Byte
     bcdUSB As Long ' short
     bDeviceClass As Byte
     bDeviceSubClass As Byte
     bDeviceProtocol As Byte
     bMaxPacketSize0 As Byte
     idVendor As Integer
     idProduct As Integer
     bcdDevice As Integer
     iManufacturer As Byte
     iProduct As Byte
     iSerialNumber As Byte
     bNumConfigurations As Byte
End Type
 
Type USB_Config_Descriptor
     bLength As Byte
     bDescriptorType As Byte
     wTotalLength As Integer
     bNumInterfaces As Byte
     bConfigurationValue As Byte
     iConfiguration As Byte
     bmAttributes As Byte
     MaxPower As Byte
     Interface As Byte ' geforwarde struct USB_Interface
     Extra As Byte
     extralen As Long
End Type
 
Type USB_Interface
     AltSetting As Byte 'geforwarde struct USB_Interface_Descriptor
     Num_AltSetting As Integer
End Type
 
Type USB_Interface_Descriptor
     bLength As Byte
     bDescriptorType As Byte
     bInterfaceNumber As Byte
     bAlternateSetting As Byte
     bNumEndpoints As Byte
     bInterfaceClass As Byte
     bInterfaceSubClass As Byte
     bInterfaceProtocol As Byte
     iInterface As Byte
     EndPoint As Byte 'geforwarde struct USB_EndPoint_Descriptor
     Extra As Byte
     extralen As Integer
End Type

Type USB_dev_handle
     zever As Byte  ' efkese zever gedclareerd omdat ik hier de definieite niet van terugvind in de .h file
End Type

' procedures
Declare Sub USB_Init Lib "libusb0.dll" ()
Declare Function USB_Find_Busses Lib "libusb0.dll" () As Integer
Declare Function USB_Find_Devices Lib "libusb0.dll" () As Integer
Declare Function USB_Get_Busses Lib "libusb0.dll" () As USB_Bus
Declare Function USB_Open Lib "libusb0.dll" _
        (ByRef Device As USB_Device) As USB_dev_handle
Declare Function USB_Close Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle) As Integer
Declare Function USB_Set_Configuration Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Configuration As Integer) As Integer
Declare Function USB_Set_AltInterface Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Alternate As Integer) As Integer
Declare Function USB_ResetEp Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Long) As Integer
Declare Function USB_Clear_Halt Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Long) As Integer
Declare Function USB_Reset Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle) As Integer
Declare Function USB_Claim_Interface Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Interface As Integer) As Integer
Declare Function USB_Release_Interface Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Interface As Integer) As Integer
Declare Function USB_Control_Msg Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal RequestType As Integer, _
         ByVal Request As Integer, _
         ByVal Value As Integer, _
         ByVal Index As Integer, _
         ByRef Bytes As String, _
         ByVal Size As Integer, _
         ByVal TimeOut As Integer) As Integer
Declare Function USB_Get_String Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Index As Integer, _
         ByVal LangId As Integer, _
         ByRef Buf As String, _
         ByVal BufLen As Long) As Integer
Declare Function USB_Get_String_Simple Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal Index As Integer, _
         ByRef Buf As String, _
         ByVal BufLen As Long) As Integer
Declare Function USB_Get_Descriptor Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal sType As String, _
         ByVal Index As String, _
         ByRef Buf, _
         ByVal Size As Integer) As Integer
Declare Function USB_Get_Descriptor_By_EndPoint Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Integer, _
         ByVal sType As String, _
         ByVal Index As String, _
         ByRef Buf, _
         ByVal Size As Integer) As Integer
Declare Function USB_Bulk_Write Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Integer, _
         ByRef Bytes As String, _
         ByVal Size As Integer, _
         ByVal TimeOut As Integer) As Integer
Declare Function USB_Bulk_Read Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Integer, _
         ByRef Bytes As Byte, _
         ByVal Size As Integer, _
         ByVal TimeOut As Integer) As Integer
Declare Function USB_Interrupt_Write Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Integer, _
         ByRef Bytes As Byte, _
         ByVal Size As Integer, _
         ByVal TimeOut As Integer) As Integer
Declare Function USB_Interrupt_Read Lib "libusb0.dll" _
        (ByRef Device As USB_dev_handle, _
         ByVal EndPoint As Integer, _
         ByRef Bytes As Byte, _
         ByVal Size As Integer, _
         ByVal TimeOut As Integer) As Integer

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

nog efkes geduld .. bent aant properder schrijven : MODS : niet editeren . ik ben bezig :p

klaar. zo past het beter in CO format en ist ook leesbaarder in VB

[Bericht gewijzigd door free_electron op donderdag 28 december 2006 23:38:52 ]

Martijn v

KIS!!: Keep It Simple

ja was vaag zeg.. kon niet editten..

'k snap niet wat je met geforward bedoeld, maar volgens mij bedoel je dit:


Type USB_Device
     filename(LIBUSB_PATH_MAX) As Byte
     Bus As Byte ' USB_Bus
     Descriptor As USB_Device_Descriptor  '<<<<<<
     Config As USB_Config_Descriptor      '<<<<<<
End Type

Type USB_Bus
     DirName(LIBUSB_PATH_MAX) As Byte
     Devices As USB_Device              '<<<<<<<<
     Location As Single
End Type

sneakie; je wel zorgen dat die 'geforwarde'/ 'geneste' struct erboven in de code is gedeclareert.

en dan al die constants:
je kan daar Enum's van maken.


'Descriptor types
public enum Descriptor_types
  USB_DT_DEVICE = &H1
  USB_DT_CONFIG = &H2
  USB_DT_STRING = &H3
  USB_DT_INTERFACE = &H4
  USB_DT_ENDPOINT = &H5
  USB_DT_HID = &H21
  USB_DT_REPORT = &H22
  USB_DT_PHYSICAL = &H23
  USB_DT_HUB = &H29
end enum
Type USB_Device_Descriptor
     bLength As Byte
     bDescriptorType As Descriptor_types  '<<<<<<<
     bcdUSB As Long ' short
     bDeviceClass As Byte
     bDeviceSubClass As Byte
     bDeviceProtocol As Byte
     bMaxPacketSize0 As Byte
     idVendor As Integer
     idProduct As Integer
     bcdDevice As Integer
     iManufacturer As Byte
     iProduct As Byte
     iSerialNumber As Byte
     bNumConfigurations As Byte
End Type

f_e: zekerweten al die byte's en integer's ?
meeste API gebruiken Long's.

[Bericht gewijzigd door Martijn v op donderdag 28 december 2006 23:53:35 ]

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

VB long is 4 byte...

unsigned short in C is 2 byte. een VB integer mapt daar perfect op.

ik ben niet zeker van die enums. het is niet op te maken uit usb.h wie er waar bij hoort....

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

dit is onleesbaar voor mij ( ik ken niet genoeg C. ik krijg hoofdpijn van die taal)


struct usb_interface {
  struct usb_interface_descriptor *altsetting;
  int num_altsetting;
};

dit is dus een struct met een struct in ? of hoe moet ik dat lezen ? en wat doet die pointer daar ? (*altsetting)

of passeren ze daar een pointer naar die andere struct ?


/* String descriptor */
struct usb_string_descriptor {
  unsigned char  bLength;
  unsigned char  bDescriptorType;
  unsigned short wData[1];
};

wat bedoelen ze met die [1] ? dat dat een array is van 2 elementen ?

[Bericht gewijzigd door free_electron op vrijdag 29 december 2006 00:06:37 ]

Martijn v

KIS!!: Keep It Simple

weet ik veel :)

is het een string?

String*60 kan wel, dat is dan een strin van 60 charachters lang.

array van 2, tja, zou kunnen, beetje vaag alleen.

[Bericht gewijzigd door Martijn v op vrijdag 29 december 2006 00:14:30 ]

Op 29 december 2006 00:02:52 schreef free_electron:


struct usb_interface {
  struct usb_interface_descriptor *altsetting;
  int num_altsetting;
};

dit is dus een struct met een struct in ? of hoe moet ik dat lezen ? en wat doet die pointer daar ? (*altsetting)

Gewoon wat er staat: een pointer (altsetting) naar een struct van het type usb_interface_descriptor

of passeren ze daar een pointer naar die andere struct ?

Ja.


/* String descriptor */
struct usb_string_descriptor {
  unsigned char  bLength;
  unsigned char  bDescriptorType;
  unsigned short wData[1];
};

wat bedoelen ze met die [1] ? dat dat een array is van 2 elementen ?

Nee een array van 1 element. Vraag me niet waarom.

free_electron

Silicon Member

Professioneel ElectronenTemmer - siliconvalleygarage.com - De voltooid verleden tijd van 'halfgeleider' is 'zand' ... US 8,032,693 / US 7,714,746 / US 7,355,303 / US 7,098,557 / US 6,762,632 / EP 1804159 - Real programmers write Hex into ROM

ok. dus dat wordt stoeien met varptr in vb om die rommel te kunnen oplossen.

Martijn v

KIS!!: Keep It Simple

varptr??

edit: pointer = Varptr(object as any) as long