Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht Das deutsche QBasic- und FreeBASIC-Forum
Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
 
FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen  RegistrierenRegistrieren
ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin
Zur Begleitseite des Forums / Chat / Impressum
Aktueller Forenpartner:

LibUSB-1.0 unter Raspbian Jessie in FreeBASIC 1.06 einbinden
Gehe zu Seite 1, 2  Weiter
 
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Linux-spezifische Fragen
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 06.08.2016, 13:16    Titel: LibUSB-1.0 unter Raspbian Jessie in FreeBASIC 1.06 einbinden Antworten mit Zitat

Ich habe das Problem libusb-1.0 mit FreeBASIC zu nutzen. Eine alte libusb.bi für libusb-0.9 bringt mir bei der Compilierung nur Fehlermeldungen, da sich wohl die gesamte Struktur (Namensgebung der Funktionen etc.) geändert hat.

Mein FreeBASIC Compiler - Version 1.06.0 (06-03-2016), built for linux-arm (32bit) läuft auf einem Raspberry Pi 3B unter Raspbian Jessie.

Leider habe ich trotz intensiver Suche im Web keine aktuelle libusb.bi gefunden. Da sicher auch andere hier mittels libusb-1.0 auf USB-Geräte zugreifen, hoffe ich, dass mir hier evtl. weitergeholfen werden kann.

Ein Beispielcode für einen lesenden Zugriff auf ein USB-Device wäre prima.

Der Grund, wozu ich übberhaupt RAW-mäßig auf ein USB-Gerät zugreifen möchte sind diverse Temperatursensoren DS18B20, die an eine USB-Interfaceplatine mit AT90USB162 angeschlossen sind.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
St_W



Anmeldungsdatum: 22.07.2007
Beiträge: 949
Wohnort: Austria

BeitragVerfasst am: 06.08.2016, 17:16    Titel: Antworten mit Zitat

Dasselbe Problem trat kürzlich auch im engl. Forum auf: http://www.freebasic.net/forum/viewtopic.php?p=222162#p222162

Aktuelle Header gibts meines Wissens noch nicht, aber es sollte nicht allzu schwer sein mit fbfrog (o.ä.) neue zu generieren.
_________________
Aktuelle FreeBasic Builds, Projekte, Code-Snippets unter http://users.freebasic-portal.de/stw/
http://www.mv-lacken.at Musikverein Lacken (MV Lacken)
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 07.08.2016, 16:00    Titel: Antworten mit Zitat

@St_W: Vielen Dank für deine Antwort.

Auf diesen Thread war ich bei meiner erfolglosen Suche auch gestoßen. Derjenige hat dann sein Programm in C geschrieben, weil es dafür Header-Dateien gibt.

Meine Versuche mit h_2_bi.bas verliefen erfolglos. fbc hängte sich schon beim Compilieren auf und der Pi musste von mir neu gestartet werden, weil per ssh kein Zugriff mehr funktionierte.

Inzwischen habe ich von github - wie von dir vorgeschlagen - fbfrog geladen und mit make eine ausführbare fbfrog erzeugt. Danke für den Tipp.

Das Umwandeln von libusb.h zu libusb.bi brachte dies als Ergebnis:

libusb.bi
Code:
#pragma once

#include once "crt/stdint.bi"
#include once "crt/sys/types.bi"

#if defined(__FB_LINUX__) or defined(__FB_DARWIN__) or defined(__FB_CYGWIN__)
   #include once "sys/time.bi"
#endif

#include once "crt/time.bi"
#include once "crt/limits.bi"

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   #include once "windows.bi"
#endif

#ifdef __FB_WIN32__
   #include once "winsock.bi"
#endif

extern "C"

#define LIBUSB_H

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   #define LIBUSB_CALL WINAPI
#else
   #define LIBUSB_CALL
#endif

const LIBUSB_API_VERSION = &h01000103
const LIBUSBX_API_VERSION = LIBUSB_API_VERSION

private function libusb_cpu_to_le16(byval x as const ushort) as ushort
   union _tmp
      b8(0 to 1) as ubyte
      b16 as ushort
   end union
   dim _tmp as _tmp
   _tmp.b8[1] = cubyte(x shr 8)
   _tmp.b8[0] = cubyte(x and &hff)
   return _tmp.b16
end function

declare function libusb_le16_to_cpu alias "libusb_cpu_to_le16"(byval x as const ushort) as ushort

type libusb_class_code as long
enum
   LIBUSB_CLASS_PER_INTERFACE = 0
   LIBUSB_CLASS_AUDIO = 1
   LIBUSB_CLASS_COMM = 2
   LIBUSB_CLASS_HID = 3
   LIBUSB_CLASS_PHYSICAL = 5
   LIBUSB_CLASS_PRINTER = 7
   LIBUSB_CLASS_PTP = 6
   LIBUSB_CLASS_IMAGE = 6
   LIBUSB_CLASS_MASS_STORAGE = 8
   LIBUSB_CLASS_HUB = 9
   LIBUSB_CLASS_DATA = 10
   LIBUSB_CLASS_SMART_CARD = &h0b
   LIBUSB_CLASS_CONTENT_SECURITY = &h0d
   LIBUSB_CLASS_VIDEO = &h0e
   LIBUSB_CLASS_PERSONAL_HEALTHCARE = &h0f
   LIBUSB_CLASS_DIAGNOSTIC_DEVICE = &hdc
   LIBUSB_CLASS_WIRELESS = &he0
   LIBUSB_CLASS_APPLICATION = &hfe
   LIBUSB_CLASS_VENDOR_SPEC = &hff
end enum

type libusb_descriptor_type as long
enum
   LIBUSB_DT_DEVICE = &h01
   LIBUSB_DT_CONFIG = &h02
   LIBUSB_DT_STRING = &h03
   LIBUSB_DT_INTERFACE = &h04
   LIBUSB_DT_ENDPOINT = &h05
   LIBUSB_DT_BOS = &h0f
   LIBUSB_DT_DEVICE_CAPABILITY = &h10
   LIBUSB_DT_HID = &h21
   LIBUSB_DT_REPORT = &h22
   LIBUSB_DT_PHYSICAL = &h23
   LIBUSB_DT_HUB = &h29
   LIBUSB_DT_SUPERSPEED_HUB = &h2a
   LIBUSB_DT_SS_ENDPOINT_COMPANION = &h30
end enum

const LIBUSB_DT_DEVICE_SIZE = 18
const LIBUSB_DT_CONFIG_SIZE = 9
const LIBUSB_DT_INTERFACE_SIZE = 9
const LIBUSB_DT_ENDPOINT_SIZE = 7
const LIBUSB_DT_ENDPOINT_AUDIO_SIZE = 9
const LIBUSB_DT_HUB_NONVAR_SIZE = 7
const LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE = 6
const LIBUSB_DT_BOS_SIZE = 5
const LIBUSB_DT_DEVICE_CAPABILITY_SIZE = 3
const LIBUSB_BT_USB_2_0_EXTENSION_SIZE = 7
const LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE = 10
const LIBUSB_BT_CONTAINER_ID_SIZE = 20
const LIBUSB_DT_BOS_MAX_SIZE = ((LIBUSB_DT_BOS_SIZE + LIBUSB_BT_USB_2_0_EXTENSION_SIZE) + LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) + LIBUSB_BT_CONTAINER_ID_SIZE
const LIBUSB_ENDPOINT_ADDRESS_MASK = &h0f
const LIBUSB_ENDPOINT_DIR_MASK = &h80

type libusb_endpoint_direction as long
enum
   LIBUSB_ENDPOINT_IN = &h80
   LIBUSB_ENDPOINT_OUT = &h00
end enum

const LIBUSB_TRANSFER_TYPE_MASK = &h03

type libusb_transfer_type as long
enum
   LIBUSB_TRANSFER_TYPE_CONTROL = 0
   LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1
   LIBUSB_TRANSFER_TYPE_BULK = 2
   LIBUSB_TRANSFER_TYPE_INTERRUPT = 3
   LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4
end enum

type libusb_standard_request as long
enum
   LIBUSB_REQUEST_GET_STATUS = &h00
   LIBUSB_REQUEST_CLEAR_FEATURE = &h01
   LIBUSB_REQUEST_SET_FEATURE = &h03
   LIBUSB_REQUEST_SET_ADDRESS = &h05
   LIBUSB_REQUEST_GET_DESCRIPTOR = &h06
   LIBUSB_REQUEST_SET_DESCRIPTOR = &h07
   LIBUSB_REQUEST_GET_CONFIGURATION = &h08
   LIBUSB_REQUEST_SET_CONFIGURATION = &h09
   LIBUSB_REQUEST_GET_INTERFACE = &h0A
   LIBUSB_REQUEST_SET_INTERFACE = &h0B
   LIBUSB_REQUEST_SYNCH_FRAME = &h0C
   LIBUSB_REQUEST_SET_SEL = &h30
   LIBUSB_SET_ISOCH_DELAY = &h31
end enum

type libusb_request_type as long
enum
   LIBUSB_REQUEST_TYPE_STANDARD = &h00 shl 5
   LIBUSB_REQUEST_TYPE_CLASS = &h01 shl 5
   LIBUSB_REQUEST_TYPE_VENDOR = &h02 shl 5
   LIBUSB_REQUEST_TYPE_RESERVED = &h03 shl 5
end enum

type libusb_request_recipient as long
enum
   LIBUSB_RECIPIENT_DEVICE = &h00
   LIBUSB_RECIPIENT_INTERFACE = &h01
   LIBUSB_RECIPIENT_ENDPOINT = &h02
   LIBUSB_RECIPIENT_OTHER = &h03
end enum

const LIBUSB_ISO_SYNC_TYPE_MASK = &h0C

type libusb_iso_sync_type as long
enum
   LIBUSB_ISO_SYNC_TYPE_NONE = 0
   LIBUSB_ISO_SYNC_TYPE_ASYNC = 1
   LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2
   LIBUSB_ISO_SYNC_TYPE_SYNC = 3
end enum

const LIBUSB_ISO_USAGE_TYPE_MASK = &h30

type libusb_iso_usage_type as long
enum
   LIBUSB_ISO_USAGE_TYPE_DATA = 0
   LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1
   LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2
end enum

type libusb_device_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bcdUSB as ushort
   bDeviceClass as ubyte
   bDeviceSubClass as ubyte
   bDeviceProtocol as ubyte
   bMaxPacketSize0 as ubyte
   idVendor as ushort
   idProduct as ushort
   bcdDevice as ushort
   iManufacturer as ubyte
   iProduct as ubyte
   iSerialNumber as ubyte
   bNumConfigurations as ubyte
end type

type libusb_endpoint_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bEndpointAddress as ubyte
   bmAttributes as ubyte
   wMaxPacketSize as ushort
   bInterval as ubyte
   bRefresh as ubyte
   bSynchAddress as ubyte
   extra as const ubyte ptr
   extra_length as long
end type

type libusb_interface_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bInterfaceNumber as ubyte
   bAlternateSetting as ubyte
   bNumEndpoints as ubyte
   bInterfaceClass as ubyte
   bInterfaceSubClass as ubyte
   bInterfaceProtocol as ubyte
   iInterface as ubyte
   endpoint as const libusb_endpoint_descriptor ptr
   extra as const ubyte ptr
   extra_length as long
end type

type libusb_interface
   altsetting as const libusb_interface_descriptor ptr
   num_altsetting as long
end type

type libusb_config_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   wTotalLength as ushort
   bNumInterfaces as ubyte
   bConfigurationValue as ubyte
   iConfiguration as ubyte
   bmAttributes as ubyte
   MaxPower as ubyte
   interface as const libusb_interface ptr
   extra as const ubyte ptr
   extra_length as long
end type

type libusb_ss_endpoint_companion_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bMaxBurst as ubyte
   bmAttributes as ubyte
   wBytesPerInterval as ushort
end type

type libusb_bos_dev_capability_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bDevCapabilityType as ubyte
   dev_capability_data(0 to ...) as ubyte
end type

type libusb_bos_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   wTotalLength as ushort
   bNumDeviceCaps as ubyte
   dev_capability(0 to ...) as libusb_bos_dev_capability_descriptor ptr
end type

type libusb_usb_2_0_extension_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bDevCapabilityType as ubyte
   bmAttributes as ulong
end type

type libusb_ss_usb_device_capability_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bDevCapabilityType as ubyte
   bmAttributes as ubyte
   wSpeedSupported as ushort
   bFunctionalitySupport as ubyte
   bU1DevExitLat as ubyte
   bU2DevExitLat as ushort
end type

type libusb_container_id_descriptor
   bLength as ubyte
   bDescriptorType as ubyte
   bDevCapabilityType as ubyte
   bReserved as ubyte
   ContainerID(0 to 15) as ubyte
end type

type libusb_control_setup
   bmRequestType as ubyte
   bRequest as ubyte
   wValue as ushort
   wIndex as ushort
   wLength as ushort
end type

#define LIBUSB_CONTROL_SETUP_SIZE sizeof(libusb_control_setup)

type libusb_version
   major as const ushort
   minor as const ushort
   micro as const ushort
   nano as const ushort
   rc as const zstring ptr
   describe as const zstring ptr
end type

type libusb_speed as long
enum
   LIBUSB_SPEED_UNKNOWN = 0
   LIBUSB_SPEED_LOW = 1
   LIBUSB_SPEED_FULL = 2
   LIBUSB_SPEED_HIGH = 3
   LIBUSB_SPEED_SUPER = 4
end enum

type libusb_supported_speed as long
enum
   LIBUSB_LOW_SPEED_OPERATION = 1
   LIBUSB_FULL_SPEED_OPERATION = 2
   LIBUSB_HIGH_SPEED_OPERATION = 4
   LIBUSB_SUPER_SPEED_OPERATION = 8
end enum

type libusb_usb_2_0_extension_attributes as long
enum
   LIBUSB_BM_LPM_SUPPORT = 2
end enum

type libusb_ss_usb_device_capability_attributes as long
enum
   LIBUSB_BM_LTM_SUPPORT = 2
end enum

type libusb_bos_type as long
enum
   LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1
   LIBUSB_BT_USB_2_0_EXTENSION = 2
   LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3
   LIBUSB_BT_CONTAINER_ID = 4
end enum

type libusb_error as long
enum
   LIBUSB_SUCCESS = 0
   LIBUSB_ERROR_IO = -1
   LIBUSB_ERROR_INVALID_PARAM = -2
   LIBUSB_ERROR_ACCESS = -3
   LIBUSB_ERROR_NO_DEVICE = -4
   LIBUSB_ERROR_NOT_FOUND = -5
   LIBUSB_ERROR_BUSY = -6
   LIBUSB_ERROR_TIMEOUT = -7
   LIBUSB_ERROR_OVERFLOW = -8
   LIBUSB_ERROR_PIPE = -9
   LIBUSB_ERROR_INTERRUPTED = -10
   LIBUSB_ERROR_NO_MEM = -11
   LIBUSB_ERROR_NOT_SUPPORTED = -12
   LIBUSB_ERROR_OTHER = -99
end enum

const LIBUSB_ERROR_COUNT = 14

type libusb_transfer_status as long
enum
   LIBUSB_TRANSFER_COMPLETED
   LIBUSB_TRANSFER_ERROR
   LIBUSB_TRANSFER_TIMED_OUT
   LIBUSB_TRANSFER_CANCELLED
   LIBUSB_TRANSFER_STALL
   LIBUSB_TRANSFER_NO_DEVICE
   LIBUSB_TRANSFER_OVERFLOW
end enum

type libusb_transfer_flags as long
enum
   LIBUSB_TRANSFER_SHORT_NOT_OK = 1 shl 0
   LIBUSB_TRANSFER_FREE_BUFFER = 1 shl 1
   LIBUSB_TRANSFER_FREE_TRANSFER = 1 shl 2
   LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 shl 3
end enum

type libusb_iso_packet_descriptor
   length as ulong
   actual_length as ulong
   status as libusb_transfer_status
end type

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: typedef void (WINAPI *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);

   type libusb_transfer
      dev_handle as libusb_device_handle ptr
      flags as ubyte
      endpoint as ubyte
      as ubyte type
      timeout as ulong
      status as libusb_transfer_status
      length as long
      actual_length as long
      callback as libusb_transfer_cb_fn
      user_data as any ptr
      buffer as ubyte ptr
      num_iso_packets as long
      iso_packet_desc(0 to ...) as libusb_iso_packet_descriptor
   end type
#else
   type libusb_transfer as libusb_transfer_
   type libusb_transfer_cb_fn as sub(byval transfer as libusb_transfer ptr)

   type libusb_transfer_
      dev_handle as libusb_device_handle ptr
      flags as ubyte
      endpoint as ubyte
      as ubyte type
      timeout as ulong
      status as libusb_transfer_status
      length as long
      actual_length as long
      callback as libusb_transfer_cb_fn
      user_data as any ptr
      buffer as ubyte ptr
      num_iso_packets as long
      iso_packet_desc(0 to ...) as libusb_iso_packet_descriptor
   end type
#endif

type libusb_capability as long
enum
   LIBUSB_CAP_HAS_CAPABILITY = &h0000
   LIBUSB_CAP_HAS_HOTPLUG = &h0001
   LIBUSB_CAP_HAS_HID_ACCESS = &h0100
   LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = &h0101
end enum

type libusb_log_level as long
enum
   LIBUSB_LOG_LEVEL_NONE = 0
   LIBUSB_LOG_LEVEL_ERROR
   LIBUSB_LOG_LEVEL_WARNING
   LIBUSB_LOG_LEVEL_INFO
   LIBUSB_LOG_LEVEL_DEBUG
end enum

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: int WINAPI libusb_init(libusb_context **ctx);
   '' TODO: void WINAPI libusb_exit(libusb_context *ctx);
   '' TODO: void WINAPI libusb_set_debug(libusb_context *ctx, int level);
   '' TODO: const struct libusb_version * WINAPI libusb_get_version(void);
   '' TODO: int WINAPI libusb_has_capability(uint32_t capability);
   '' TODO: const char * WINAPI libusb_error_name(int errcode);
   '' TODO: int WINAPI libusb_setlocale(const char *locale);
   '' TODO: const char * WINAPI libusb_strerror(enum libusb_error errcode);
   '' TODO: ssize_t WINAPI libusb_get_device_list(libusb_context *ctx, libusb_device ***list);
   '' TODO: void WINAPI libusb_free_device_list(libusb_device **list, int unref_devices);
   '' TODO: libusb_device * WINAPI libusb_ref_device(libusb_device *dev);
   '' TODO: void WINAPI libusb_unref_device(libusb_device *dev);
   '' TODO: int WINAPI libusb_get_configuration(libusb_device_handle *dev, int *config);
   '' TODO: int WINAPI libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc);
   '' TODO: int WINAPI libusb_get_active_config_descriptor(libusb_device *dev, struct libusb_config_descriptor **config);
   '' TODO: int WINAPI libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config);
   '' TODO: int WINAPI libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
   '' TODO: void WINAPI libusb_free_config_descriptor( struct libusb_config_descriptor *config);
   '' TODO: int WINAPI libusb_get_ss_endpoint_companion_descriptor( struct libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
   '' TODO: void WINAPI libusb_free_ss_endpoint_companion_descriptor( struct libusb_ss_endpoint_companion_descriptor *ep_comp);
   '' TODO: int WINAPI libusb_get_bos_descriptor(libusb_device_handle *handle, struct libusb_bos_descriptor **bos);
   '' TODO: void WINAPI libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
   '' TODO: int WINAPI libusb_get_usb_2_0_extension_descriptor( struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
   '' TODO: void WINAPI libusb_free_usb_2_0_extension_descriptor( struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
   '' TODO: int WINAPI libusb_get_ss_usb_device_capability_descriptor( struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
   '' TODO: void WINAPI libusb_free_ss_usb_device_capability_descriptor( struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
   '' TODO: int WINAPI libusb_get_container_id_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id);
   '' TODO: void WINAPI libusb_free_container_id_descriptor( struct libusb_container_id_descriptor *container_id);
   '' TODO: uint8_t WINAPI libusb_get_bus_number(libusb_device *dev);
   '' TODO: uint8_t WINAPI libusb_get_port_number(libusb_device *dev);
   '' TODO: int WINAPI libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
   '' TODO: __attribute__((deprecated("Use " "libusb_get_port_numbers" " instead")))int WINAPI libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
   '' TODO: libusb_device * WINAPI libusb_get_parent(libusb_device *dev);
   '' TODO: uint8_t WINAPI libusb_get_device_address(libusb_device *dev);
   '' TODO: int WINAPI libusb_get_device_speed(libusb_device *dev);
   '' TODO: int WINAPI libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint);
   '' TODO: int WINAPI libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint);
   '' TODO: int WINAPI libusb_open(libusb_device *dev, libusb_device_handle **handle);
   '' TODO: void WINAPI libusb_close(libusb_device_handle *dev_handle);
   '' TODO: libusb_device * WINAPI libusb_get_device(libusb_device_handle *dev_handle);
   '' TODO: int WINAPI libusb_set_configuration(libusb_device_handle *dev, int configuration);
   '' TODO: int WINAPI libusb_claim_interface(libusb_device_handle *dev, int interface_number);
   '' TODO: int WINAPI libusb_release_interface(libusb_device_handle *dev, int interface_number);
   '' TODO: libusb_device_handle * WINAPI libusb_open_device_with_vid_pid( libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
   '' TODO: int WINAPI libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number, int alternate_setting);
   '' TODO: int WINAPI libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint);
   '' TODO: int WINAPI libusb_reset_device(libusb_device_handle *dev);
   '' TODO: int WINAPI libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
   '' TODO: int WINAPI libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints);
   '' TODO: int WINAPI libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number);
   '' TODO: int WINAPI libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number);
   '' TODO: int WINAPI libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number);
   '' TODO: int WINAPI libusb_set_auto_detach_kernel_driver( libusb_device_handle *dev, int enable);
#else
   declare function libusb_init(byval ctx as libusb_context ptr ptr) as long
   declare sub libusb_exit(byval ctx as libusb_context ptr)
   declare sub libusb_set_debug(byval ctx as libusb_context ptr, byval level as long)
   declare function libusb_get_version() as const libusb_version ptr
   declare function libusb_has_capability(byval capability as ulong) as long
   declare function libusb_error_name(byval errcode as long) as const zstring ptr
   declare function libusb_setlocale(byval locale as const zstring ptr) as long
   declare function libusb_strerror(byval errcode as libusb_error) as const zstring ptr
   declare function libusb_get_device_list(byval ctx as libusb_context ptr, byval list as libusb_device ptr ptr ptr) as integer
   declare sub libusb_free_device_list(byval list as libusb_device ptr ptr, byval unref_devices as long)
   declare function libusb_ref_device(byval dev as libusb_device ptr) as libusb_device ptr
   declare sub libusb_unref_device(byval dev as libusb_device ptr)
   declare function libusb_get_configuration(byval dev as libusb_device_handle ptr, byval config as long ptr) as long
   declare function libusb_get_device_descriptor(byval dev as libusb_device ptr, byval desc as libusb_device_descriptor ptr) as long
   declare function libusb_get_active_config_descriptor(byval dev as libusb_device ptr, byval config as libusb_config_descriptor ptr ptr) as long
   declare function libusb_get_config_descriptor(byval dev as libusb_device ptr, byval config_index as ubyte, byval config as libusb_config_descriptor ptr ptr) as long
   declare function libusb_get_config_descriptor_by_value(byval dev as libusb_device ptr, byval bConfigurationValue as ubyte, byval config as libusb_config_descriptor ptr ptr) as long
   declare sub libusb_free_config_descriptor(byval config as libusb_config_descriptor ptr)
   declare function libusb_get_ss_endpoint_companion_descriptor(byval ctx as libusb_context ptr, byval endpoint as const libusb_endpoint_descriptor ptr, byval ep_comp as libusb_ss_endpoint_companion_descriptor ptr ptr) as long
   declare sub libusb_free_ss_endpoint_companion_descriptor(byval ep_comp as libusb_ss_endpoint_companion_descriptor ptr)
   declare function libusb_get_bos_descriptor(byval handle as libusb_device_handle ptr, byval bos as libusb_bos_descriptor ptr ptr) as long
   declare sub libusb_free_bos_descriptor(byval bos as libusb_bos_descriptor ptr)
   declare function libusb_get_usb_2_0_extension_descriptor(byval ctx as libusb_context ptr, byval dev_cap as libusb_bos_dev_capability_descriptor ptr, byval usb_2_0_extension as libusb_usb_2_0_extension_descriptor ptr ptr) as long
   declare sub libusb_free_usb_2_0_extension_descriptor(byval usb_2_0_extension as libusb_usb_2_0_extension_descriptor ptr)
   declare function libusb_get_ss_usb_device_capability_descriptor(byval ctx as libusb_context ptr, byval dev_cap as libusb_bos_dev_capability_descriptor ptr, byval ss_usb_device_cap as libusb_ss_usb_device_capability_descriptor ptr ptr) as long
   declare sub libusb_free_ss_usb_device_capability_descriptor(byval ss_usb_device_cap as libusb_ss_usb_device_capability_descriptor ptr)
   declare function libusb_get_container_id_descriptor(byval ctx as libusb_context ptr, byval dev_cap as libusb_bos_dev_capability_descriptor ptr, byval container_id as libusb_container_id_descriptor ptr ptr) as long
   declare sub libusb_free_container_id_descriptor(byval container_id as libusb_container_id_descriptor ptr)
   declare function libusb_get_bus_number(byval dev as libusb_device ptr) as ubyte
   declare function libusb_get_port_number(byval dev as libusb_device ptr) as ubyte
   declare function libusb_get_port_numbers(byval dev as libusb_device ptr, byval port_numbers as ubyte ptr, byval port_numbers_len as long) as long
   declare function libusb_get_port_path(byval ctx as libusb_context ptr, byval dev as libusb_device ptr, byval path as ubyte ptr, byval path_length as ubyte) as long
   declare function libusb_get_parent(byval dev as libusb_device ptr) as libusb_device ptr
   declare function libusb_get_device_address(byval dev as libusb_device ptr) as ubyte
   declare function libusb_get_device_speed(byval dev as libusb_device ptr) as long
   declare function libusb_get_max_packet_size(byval dev as libusb_device ptr, byval endpoint as ubyte) as long
   declare function libusb_get_max_iso_packet_size(byval dev as libusb_device ptr, byval endpoint as ubyte) as long
   declare function libusb_open(byval dev as libusb_device ptr, byval handle as libusb_device_handle ptr ptr) as long
   declare sub libusb_close(byval dev_handle as libusb_device_handle ptr)
   declare function libusb_get_device(byval dev_handle as libusb_device_handle ptr) as libusb_device ptr
   declare function libusb_set_configuration(byval dev as libusb_device_handle ptr, byval configuration as long) as long
   declare function libusb_claim_interface(byval dev as libusb_device_handle ptr, byval interface_number as long) as long
   declare function libusb_release_interface(byval dev as libusb_device_handle ptr, byval interface_number as long) as long
   declare function libusb_open_device_with_vid_pid(byval ctx as libusb_context ptr, byval vendor_id as ushort, byval product_id as ushort) as libusb_device_handle ptr
   declare function libusb_set_interface_alt_setting(byval dev as libusb_device_handle ptr, byval interface_number as long, byval alternate_setting as long) as long
   declare function libusb_clear_halt(byval dev as libusb_device_handle ptr, byval endpoint as ubyte) as long
   declare function libusb_reset_device(byval dev as libusb_device_handle ptr) as long
   declare function libusb_alloc_streams(byval dev as libusb_device_handle ptr, byval num_streams as ulong, byval endpoints as ubyte ptr, byval num_endpoints as long) as long
   declare function libusb_free_streams(byval dev as libusb_device_handle ptr, byval endpoints as ubyte ptr, byval num_endpoints as long) as long
   declare function libusb_kernel_driver_active(byval dev as libusb_device_handle ptr, byval interface_number as long) as long
   declare function libusb_detach_kernel_driver(byval dev as libusb_device_handle ptr, byval interface_number as long) as long
   declare function libusb_attach_kernel_driver(byval dev as libusb_device_handle ptr, byval interface_number as long) as long
   declare function libusb_set_auto_detach_kernel_driver(byval dev as libusb_device_handle ptr, byval enable as long) as long
#endif

#define libusb_control_transfer_get_data(transfer) cptr(ubyte ptr, (transfer)->buffer + sizeof(libusb_control_setup))
#define libusb_control_transfer_get_setup(transfer) cptr(libusb_control_setup ptr, cptr(any ptr, (transfer)->buffer))

private sub libusb_fill_control_setup(byval buffer as ubyte ptr, byval bmRequestType as ubyte, byval bRequest as ubyte, byval wValue as ushort, byval wIndex as ushort, byval wLength as ushort)
   dim setup as libusb_control_setup ptr = cptr(libusb_control_setup ptr, cptr(any ptr, buffer))
   setup->bmRequestType = bmRequestType
   setup->bRequest = bRequest
   setup->wValue = libusb_cpu_to_le16(wValue)
   setup->wIndex = libusb_cpu_to_le16(wIndex)
   setup->wLength = libusb_cpu_to_le16(wLength)
end sub

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: struct libusb_transfer * WINAPI libusb_alloc_transfer(int iso_packets);
   '' TODO: int WINAPI libusb_submit_transfer(struct libusb_transfer *transfer);
   '' TODO: int WINAPI libusb_cancel_transfer(struct libusb_transfer *transfer);
   '' TODO: void WINAPI libusb_free_transfer(struct libusb_transfer *transfer);
   '' TODO: void WINAPI libusb_transfer_set_stream_id( struct libusb_transfer *transfer, uint32_t stream_id);
   '' TODO: uint32_t WINAPI libusb_transfer_get_stream_id( struct libusb_transfer *transfer);
#else
   declare function libusb_alloc_transfer(byval iso_packets as long) as libusb_transfer ptr
   declare function libusb_submit_transfer(byval transfer as libusb_transfer ptr) as long
   declare function libusb_cancel_transfer(byval transfer as libusb_transfer ptr) as long
   declare sub libusb_free_transfer(byval transfer as libusb_transfer ptr)
   declare sub libusb_transfer_set_stream_id(byval transfer as libusb_transfer ptr, byval stream_id as ulong)
   declare function libusb_transfer_get_stream_id(byval transfer as libusb_transfer ptr) as ulong
#endif

private sub libusb_fill_control_transfer(byval transfer as libusb_transfer ptr, byval dev_handle as libusb_device_handle ptr, byval buffer as ubyte ptr, byval callback as libusb_transfer_cb_fn, byval user_data as any ptr, byval timeout as ulong)
   dim setup as libusb_control_setup ptr = cptr(libusb_control_setup ptr, cptr(any ptr, buffer))
   transfer->dev_handle = dev_handle
   transfer->endpoint = 0
   transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL
   transfer->timeout = timeout
   transfer->buffer = buffer
   if setup then
      transfer->length = clng(sizeof(libusb_control_setup) + libusb_cpu_to_le16(setup->wLength))
   end if
   transfer->user_data = user_data
   transfer->callback = callback
end sub

private sub libusb_fill_bulk_transfer(byval transfer as libusb_transfer ptr, byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval buffer as ubyte ptr, byval length as long, byval callback as libusb_transfer_cb_fn, byval user_data as any ptr, byval timeout as ulong)
   transfer->dev_handle = dev_handle
   transfer->endpoint = endpoint
   transfer->type = LIBUSB_TRANSFER_TYPE_BULK
   transfer->timeout = timeout
   transfer->buffer = buffer
   transfer->length = length
   transfer->user_data = user_data
   transfer->callback = callback
end sub

private sub libusb_fill_bulk_stream_transfer(byval transfer as libusb_transfer ptr, byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval stream_id as ulong, byval buffer as ubyte ptr, byval length as long, byval callback as libusb_transfer_cb_fn, byval user_data as any ptr, byval timeout as ulong)
   libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer, length, callback, user_data, timeout)
   transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM
   libusb_transfer_set_stream_id(transfer, stream_id)
end sub

private sub libusb_fill_interrupt_transfer(byval transfer as libusb_transfer ptr, byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval buffer as ubyte ptr, byval length as long, byval callback as libusb_transfer_cb_fn, byval user_data as any ptr, byval timeout as ulong)
   transfer->dev_handle = dev_handle
   transfer->endpoint = endpoint
   transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT
   transfer->timeout = timeout
   transfer->buffer = buffer
   transfer->length = length
   transfer->user_data = user_data
   transfer->callback = callback
end sub

private sub libusb_fill_iso_transfer(byval transfer as libusb_transfer ptr, byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval buffer as ubyte ptr, byval length as long, byval num_iso_packets as long, byval callback as libusb_transfer_cb_fn, byval user_data as any ptr, byval timeout as ulong)
   transfer->dev_handle = dev_handle
   transfer->endpoint = endpoint
   transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
   transfer->timeout = timeout
   transfer->buffer = buffer
   transfer->length = length
   transfer->num_iso_packets = num_iso_packets
   transfer->user_data = user_data
   transfer->callback = callback
end sub

private sub libusb_set_iso_packet_lengths(byval transfer as libusb_transfer ptr, byval length as ulong)
   dim i as long
   '' TODO: for (i = 0; i < transfer->num_iso_packets; i++) transfer->iso_packet_desc[i].length = length;
end sub

private function libusb_get_iso_packet_buffer(byval transfer as libusb_transfer ptr, byval packet as ulong) as ubyte ptr
   dim i as long
   dim offset as uinteger = 0
   dim _packet as long
   if packet > INT_MAX then
      return NULL
   end if
   _packet = clng(packet)
   if _packet >= transfer->num_iso_packets then
      return NULL
   end if
   '' TODO: for (i = 0; i < _packet; i++) offset += transfer->iso_packet_desc[i].length;
   return transfer->buffer + offset
end function

private function libusb_get_iso_packet_buffer_simple(byval transfer as libusb_transfer ptr, byval packet as ulong) as ubyte ptr
   dim _packet as long
   if packet > INT_MAX then
      return NULL
   end if
   _packet = clng(packet)
   if _packet >= transfer->num_iso_packets then
      return NULL
   end if
   return transfer->buffer + (clng(transfer->iso_packet_desc[0].length) * _packet)
end function

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: int WINAPI libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout);
   '' TODO: int WINAPI libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout);
   '' TODO: int WINAPI libusb_interrupt_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout);
#else
   declare function libusb_control_transfer(byval dev_handle as libusb_device_handle ptr, byval request_type as ubyte, byval bRequest as ubyte, byval wValue as ushort, byval wIndex as ushort, byval data as ubyte ptr, byval wLength as ushort, byval timeout as ulong) as long
   declare function libusb_bulk_transfer(byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval data as ubyte ptr, byval length as long, byval actual_length as long ptr, byval timeout as ulong) as long
   declare function libusb_interrupt_transfer(byval dev_handle as libusb_device_handle ptr, byval endpoint as ubyte, byval data as ubyte ptr, byval length as long, byval actual_length as long ptr, byval timeout as ulong) as long
#endif

#define libusb_get_descriptor(dev, desc_type, desc_index, data, length) clng(libusb_control_transfer((dev), LIBUSB_ENDPOINT_IN, LIBUSB_REQUEST_GET_DESCRIPTOR, cushort(((desc_type) shl 8) or (desc_index)), 0, (data), cushort(length), 1000))
#define libusb_get_string_descriptor(dev, desc_index, langid, data, length) clng(libusb_control_transfer((dev), LIBUSB_ENDPOINT_IN, LIBUSB_REQUEST_GET_DESCRIPTOR, cushort((LIBUSB_DT_STRING shl 8) or (desc_index)), (langid), (data), cushort(length), 1000))

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: int WINAPI libusb_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t desc_index, unsigned char *data, int length);
   '' TODO: int WINAPI libusb_try_lock_events(libusb_context *ctx);
   '' TODO: void WINAPI libusb_lock_events(libusb_context *ctx);
   '' TODO: void WINAPI libusb_unlock_events(libusb_context *ctx);
   '' TODO: int WINAPI libusb_event_handling_ok(libusb_context *ctx);
   '' TODO: int WINAPI libusb_event_handler_active(libusb_context *ctx);
   '' TODO: void WINAPI libusb_lock_event_waiters(libusb_context *ctx);
   '' TODO: void WINAPI libusb_unlock_event_waiters(libusb_context *ctx);
   '' TODO: int WINAPI libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
   '' TODO: int WINAPI libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv);
   '' TODO: int WINAPI libusb_handle_events_timeout_completed(libusb_context *ctx, struct timeval *tv, int *completed);
   '' TODO: int WINAPI libusb_handle_events(libusb_context *ctx);
   '' TODO: int WINAPI libusb_handle_events_completed(libusb_context *ctx, int *completed);
   '' TODO: int WINAPI libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv);
   '' TODO: int WINAPI libusb_pollfds_handle_timeouts(libusb_context *ctx);
   '' TODO: int WINAPI libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv);
#else
   declare function libusb_get_string_descriptor_ascii(byval dev as libusb_device_handle ptr, byval desc_index as ubyte, byval data as ubyte ptr, byval length as long) as long
   declare function libusb_try_lock_events(byval ctx as libusb_context ptr) as long
   declare sub libusb_lock_events(byval ctx as libusb_context ptr)
   declare sub libusb_unlock_events(byval ctx as libusb_context ptr)
   declare function libusb_event_handling_ok(byval ctx as libusb_context ptr) as long
   declare function libusb_event_handler_active(byval ctx as libusb_context ptr) as long
   declare sub libusb_lock_event_waiters(byval ctx as libusb_context ptr)
   declare sub libusb_unlock_event_waiters(byval ctx as libusb_context ptr)
   declare function libusb_wait_for_event(byval ctx as libusb_context ptr, byval tv as timeval ptr) as long
   declare function libusb_handle_events_timeout(byval ctx as libusb_context ptr, byval tv as timeval ptr) as long
   declare function libusb_handle_events_timeout_completed(byval ctx as libusb_context ptr, byval tv as timeval ptr, byval completed as long ptr) as long
   declare function libusb_handle_events(byval ctx as libusb_context ptr) as long
   declare function libusb_handle_events_completed(byval ctx as libusb_context ptr, byval completed as long ptr) as long
   declare function libusb_handle_events_locked(byval ctx as libusb_context ptr, byval tv as timeval ptr) as long
   declare function libusb_pollfds_handle_timeouts(byval ctx as libusb_context ptr) as long
   declare function libusb_get_next_timeout(byval ctx as libusb_context ptr, byval tv as timeval ptr) as long
#endif

type libusb_pollfd
   fd as long
   events as short
end type

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: typedef void (WINAPI *libusb_pollfd_added_cb)(int fd, short events, void *user_data);
   '' TODO: typedef void (WINAPI *libusb_pollfd_removed_cb)(int fd, void *user_data);
   '' TODO: const struct libusb_pollfd ** WINAPI libusb_get_pollfds( libusb_context *ctx);
   '' TODO: void WINAPI libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data);
#else
   type libusb_pollfd_added_cb as sub(byval fd as long, byval events as short, byval user_data as any ptr)
   type libusb_pollfd_removed_cb as sub(byval fd as long, byval user_data as any ptr)
   declare function libusb_get_pollfds(byval ctx as libusb_context ptr) as const libusb_pollfd ptr ptr
   declare sub libusb_set_pollfd_notifiers(byval ctx as libusb_context ptr, byval added_cb as libusb_pollfd_added_cb, byval removed_cb as libusb_pollfd_removed_cb, byval user_data as any ptr)
#endif

type libusb_hotplug_callback_handle as long

type libusb_hotplug_flag as long
enum
   LIBUSB_HOTPLUG_ENUMERATE = 1
end enum

type libusb_hotplug_event as long
enum
   LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = &h01
   LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = &h02
end enum

const LIBUSB_HOTPLUG_MATCH_ANY = -1

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
   '' TODO: typedef int (WINAPI *libusb_hotplug_callback_fn)(libusb_context *ctx, libusb_device *device, libusb_hotplug_event event, void *user_data);
   '' TODO: int WINAPI libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle);
   '' TODO: void WINAPI libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle);
#else
   type libusb_hotplug_callback_fn as function(byval ctx as libusb_context ptr, byval device as libusb_device ptr, byval event as libusb_hotplug_event, byval user_data as any ptr) as long
   declare function libusb_hotplug_register_callback(byval ctx as libusb_context ptr, byval events as libusb_hotplug_event, byval flags as libusb_hotplug_flag, byval vendor_id as long, byval product_id as long, byval dev_class as long, byval cb_fn as libusb_hotplug_callback_fn, byval user_data as any ptr, byval handle as libusb_hotplug_callback_handle ptr) as long
   declare sub libusb_hotplug_deregister_callback(byval ctx as libusb_context ptr, byval handle as libusb_hotplug_callback_handle)
#endif

end extern


Irgendwie komme ich aber noch nicht wirklich weiter, um an meine RAW-Daten zum Auslesen zu gelangen. Da sich sämtliche Funktionsnamen geändert haben, suche ich nach dem Einstieg.


  • Finden des USB-Device anhand seiner ID (VENDOR ID kenne ich, aber wie das USB-Device finden)
  • Einlesen des RAW-Output (Funktion dafür mir unbekannt, muss vorher das Device als "Datei" geöffnet werden?)
  • Weiterverarbeitung der 64 Bytes des Ausgabestroms (Bei Rücklieferung eines Binärstrings ist die Weiterverarbeitung dann kein Problem)


Vielleicht hat jemand noch eine Idee für ein Grundgerüst für den Zugriff?

In Python sieht das Ganze so aus:

tempusb.py
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import usb.core
import usb.util
# ┌──────────────────────────────┐
# │ Geraet: USB-Temperatursensor │
# └──────────────────────────────┘
idhersteller=0x16c0
idprodukt=0x0480
interface=0
# ┌─────────┐
# │ Abfrage │
# └─────────┘
nummer=0
alle=10
while nummer<alle:
   nummer+=1
   try:
      dev=usb.core.find(idVendor=idhersteller,idProduct=idprodukt)
      cfg=dev.get_active_configuration()
      intf=cfg[(0,0)]
      if dev.is_kernel_driver_active(interface) is True:
         dev.detach_kernel_driver(interface)
         usb.util.claim_interface(dev, interface)
      collected=0
      attempts=3
      while collected<attempts:
         try:
            ep=usb.util.find_descriptor(intf,custom_match=lambda e:usb.util.endpoint_direction(e.bEndpointAddress)==usb.util.ENDPOINT_IN)
            data=dev.read(ep.bEndpointAddress,ep.wMaxPacketSize)
            collected+=1
            if collected==2:
               temp=data[4]+data[5]*256
               if temp>32768:
                  temp-=65536
               print temp
               collected=attempts
               nummer=alle
         except:
            data=None
            continue
      usb.util.release_interface(dev,interface)
      dev.attach_kernel_driver(interface)
      break
   except:
      continue
#
#EOF
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 09.08.2016, 11:16    Titel: Antworten mit Zitat

Hat jemand eine Idee, wie ich das Python-Script ins FreeBASIC transferieren könnte?

Irgendwie komme ich da immer noch nicht weiter.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
nemored



Anmeldungsdatum: 22.02.2007
Beiträge: 4594
Wohnort: ~/

BeitragVerfasst am: 09.08.2016, 11:30    Titel: Antworten mit Zitat

Ich würde mal vermuten, die Haupt-Übersetzungsaufgabe liegt hier:
Code:
import sys
import usb.core
import usb.util

Keine Ahnung, was in der usb.core.py und der usb.util.py (wenn ich den import-Befehl richtig verstehe) so drin steht, aber ganz simpel ist das vermutlich nicht.
_________________
Deine Chance beträgt 1:1000. Also musst du folgendes tun: Vergiss die 1000 und konzentriere dich auf die 1.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
St_W



Anmeldungsdatum: 22.07.2007
Beiträge: 949
Wohnort: Austria

BeitragVerfasst am: 09.08.2016, 14:03    Titel: Antworten mit Zitat

BD hat Folgendes geschrieben:
Hat jemand eine Idee, wie ich das Python-Script ins FreeBASIC transferieren könnte?

Wenn du mit der API-Dokumentation der libusb nichts anfangen kannst, dann kannst du auch ganz einfach das Python Skript genauer anschaun.

z.b. für dein Problem "Finden des USB-Device anhand seiner ID (VENDOR ID kenne ich, aber wie das USB-Device finden)":

Im Python Code passiert das so:
Code:
idhersteller=0x16c0
idprodukt=0x0480
dev=usb.core.find(idVendor=idhersteller,idProduct=idprodukt)


Also schaust du in die usb.core.find() methode:
https://github.com/walac/pyusb/blob/master/usb/core.py#L1177

Dort siehst du dass einfach über alle Devices iteriert wird und das erste passende zurückgegeben wird. Und zwar mit "backend.enumerate_devices()", dessen eigentliche Implementierung in einem der Backends steckt, in unserem Fall (für die libusb 1.0 API) in:
https://github.com/walac/pyusb/blob/master/usb/backend/libusb1.py#L716

Die Methode erstellt dort einen "_DevIterator", der schlussendlich "libusb_get_device_list" aus libusb aufruft.

Die Methode ist auch ganz gut dokumentiert: http://libusb.sourceforge.net/api-1.0/group__dev.html

Wenn du dich in der Doku noch ein wenig umschaust siehst du auch dass eine Hilfsfunktion existiert, die dir noch ein wenig Arbeit abnimmt:
libusb_open_device_with_vid_pid

Du kannst dir also das iterieren über die devices (wie es die python lib macht) sparen, da es schon eine Hilfsmethode in libusb dafür gibt.

usw. usf.

________________________


Was ich mich allerdings frage ist wieso du den Python Code unbedingt in FreeBasic umsetzen willst, wenn dir das Programmieren im C/FB Stil offenbar schwer fällt und es zudem eine nette Python Bibliothek inkl. Beispielprogramm für dein Vorhaben gibt.
_________________
Aktuelle FreeBasic Builds, Projekte, Code-Snippets unter http://users.freebasic-portal.de/stw/
http://www.mv-lacken.at Musikverein Lacken (MV Lacken)
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 09.08.2016, 16:17    Titel: Antworten mit Zitat

Vielen Dank für die schnellen Antworten.

@St_W:
Ja, da versuche ich mal mein Glück.

Mich hat bei Python
Code:
         dev.detach_kernel_driver(interface)

irritiert, aber das scheint bei libusb_open_device_with_vid_pid nicht nötig zu sein. Sobald ich ein lauffähiges Programm habe, poste ich es hier.

-------------------

PS: Ich will es in FreeBASIC schreiben, weil ich daraus ein Stand-Alone-Programm machen möchte und kein Script. Außerdem programmiere ich auch lieber in FreeBASIC als in Python. Meist allerdings Programme für Windows, wo ich mich mit der Windows-API für die korrekte Darstellung herumschlagen muss.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 09.08.2016, 22:06    Titel: Antworten mit Zitat

libusb.bi bringt mir beim compilieren einen Haufen Fehlermeldungen.

Er meckert
Code:
#include once "sys/time.bi"

an, da diese nicht vorhanden ist.

Korrigiert man den Pfad zu
Code:
#include once "crt/sys/time.bi"
, so kommen trotzdem eine Menge Fehlermeldungen:
Code:
/root/libusb.bi(40) error 72: Array access, index expected, found '[' in '_tmp.b8[1] = cubyte(x shr 8)'
/root/libusb.bi(41) error 72: Array access, index expected, found '[' in '_tmp.b8[0] = cubyte(x and &hff)'
/root/libusb.bi(248) error 76: '...' ellipsis upper bound given for array field (this is not supported), found ')' in 'dev_capability_data(0 to ...) as ubyte'
/root/libusb.bi(256) error 76: '...' ellipsis upper bound given for array field (this is not supported), found ')' in 'dev_capability(0 to ...) as libusb_bos_dev_capability_descriptor ptr'
/root/libusb.bi(407) error 14: Expected identifier, found 'libusb_device_handle' in 'dev_handle as libusb_device_handle ptr'
/root/libusb.bi(419) error 76: '...' ellipsis upper bound given for array field (this is not supported), found ')' in 'iso_packet_desc(0 to ...) as libusb_iso_packet_descriptor'
/root/libusb.bi(495) error 58: Illegal specification, at parameter 1 (ctx) of libusb_init() in 'declare function libusb_init(byval ctx as libusb_context ptr ptr) as long'
/root/libusb.bi(496) error 58: Illegal specification, at parameter 1 (ctx) of libusb_exit() in 'declare sub libusb_exit(byval ctx as libusb_context ptr)'
/root/libusb.bi(497) error 58: Illegal specification, at parameter 1 (ctx) of libusb_set_debug() in 'declare sub libusb_set_debug(byval ctx as libusb_context ptr, byval level as long)'
/root/libusb.bi(503) error 58: Illegal specification, at parameter 1 (ctx) of libusb_get_device_list() in 'declare function libusb_get_device_list(byval ctx as libusb_context ptr, byval list as libusb_device ptr ptr ptr) as integer'
/root/libusb.bi(503) error 132: Too many errors, exiting

bis der Compiler die Arbeit wegen zu vieler Fehler beendet.

Kann jemand damit etwas anfangen?
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1837
Wohnort: [JN58JR]

BeitragVerfasst am: 10.08.2016, 09:26    Titel: Antworten mit Zitat

zugriffe mit [] sind Pointerzugriffe.
Zugriffe mit () sind Arrayzugriffe.

Entsprechend dieser Definition muss hier beispielhaft

Code:
_tmp.b8[1] = cubyte(x shr 8)


nach

Code:
_tmp.b8(1) = cubyte(x shr 8)


abgeändert werden.

Die Convertierung der Headerdatei wirde zwar aufgeführt, jedoch teilweise fehlerhaft. Du musst hier ganz einfach alle Fehlermeldungen durchgehen, und die entsprechenden Fehler in der Header-Datei reparieren. Illegale Parameter deuten meist auf fehler bei einer Datenübergabe hin (type, byval, byref, Ptr, usw.)

So kann es sein, das z.B. eine weiterer deiner fehlermeldungen (libusb_context bla) garnicht definiert ist. Suche im Source, ob sich ein

type libusb_context darin befindet. wenn nicht, dann muss diese hinzugefügt werden. (Eventuell befindet sie sich in einer anderen Headerdatei)


MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 12:49    Titel: Antworten mit Zitat

@ThePuppetMaster: Vielen Dank für die Tipps. Einige konnte ich korrigieren, allerdings kenne ich mich in der C-Syntax der Headerdatei von libusb.h nicht aus. Hier finde ich z. B. folgenden Eintrag:
Code:
int LIBUSB_CALL libusb_init(libusb_context **ctx);
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
   libusb_device ***list);

Eine vermutlich dumme Frage. Was sagen die vorangestellten Sterne zum Typ aus?

Ich habe einmal die libusb.h mit geposted, sodass man den Header - wie er mir vorliegt - auch vor sich hat:
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 12:52    Titel: Antworten mit Zitat

Link zu libusb.h folgt hier... http://bluedragon.bplaced.net/libusb.h

Zuletzt bearbeitet von BD am 10.08.2016, 13:11, insgesamt 2-mal bearbeitet
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1837
Wohnort: [JN58JR]

BeitragVerfasst am: 10.08.2016, 12:52    Titel: Antworten mit Zitat

Sterne sind Pointer referenzierungen.

Sprich:
Code:
int libusb_init(libusb_context **ctx);


wird zu:
Code:
declare function libusb_init(byval ctx as libusb_context Ptr Ptr) as Integer



MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 12:55    Titel: Antworten mit Zitat

Super, danke für die schnelle Antwort. lächeln
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 13:27    Titel: Antworten mit Zitat

Sorry, ich hänge immer noch:

Zeile:
Code:
   declare function libusb_init(byval ctx as libusb_context ptr ptr) as long

bringt Fehler:
Code:
/root/libusb.bi(495) error 58: Illegal specification, at parameter 1 (ctx) of libusb_init() in 'declare function libusb_init(byval ctx as libusb_context ptr ptr) as long'

Beschreibung in LibUSB-Documentation:
Code:
ssize_t libusb_get_device_list    (    libusb_context *     ctx,
      libusb_device ***     list

wobei ssize_t wohl integer sein müsste.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1837
Wohnort: [JN58JR]

BeitragVerfasst am: 10.08.2016, 13:33    Titel: Antworten mit Zitat

ssize_t wird in der libusb.h definiert und ist je nach verwendetem betriebssystem unterschiedlich definiert.

Code:
#ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED
#undef ssize_t
#ifdef _WIN64
  typedef __int64 ssize_t;
#else
  typedef int ssize_t;
#endif /* _WIN64 */
#endif /* _SSIZE_T_DEFINED */


Unter win64 ist es ein integer von 64bit länge.
Unter linux ein integer.

das Problem mit libusb_context liegt vermutlich daran, weil libusb_context nicht in der .bi definiert ist. Der FB Compiler sucht nach der typenstruktur "libusb_context", kann sie jedoch nicht finden, und gibt dir dann diese fehlermeldung aus.

Du musst daher eine typenstruktur mit der bezeichnung libusb_context erzeugen, bzw aus der c++ header nach fb header konvertieren.

Code:
Type libusb_context
'...
End Type


Danach sollten diese fehler verschwinden.


MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 22:32    Titel: Antworten mit Zitat

In libusb.h steht:
Code:
typedef struct libusb_context libusb_context;


in libusb.bi habe ich dafür:
Code:
type libusb_context as libusb_context

geschrieben.

Bei meinem Test von test.bas:
Code:
#include once "libusb.bi"
libusb_init()

kommt nun beim Compilieren:
Code:
test.bas(2) error 1: Argument count mismatch, found ')' in 'libusb_init()'

übergebe ich NULL, so kommt:
Code:
test.o: In function `main':
test.c:(.text+0x30): undefined reference to `libusb_init'

Da mache ich wohl irgendwas falsch...
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1837
Wohnort: [JN58JR]

BeitragVerfasst am: 10.08.2016, 22:50    Titel: Antworten mit Zitat

"Argument count mismatch" bedeutet, das die "Anzahl an Parameter" des Funktionsaufrufes fehlerhaft ist.

Sprich, die Funktion "libusb_init()" benötigt Parameter, um aufgerufen werden zu können.

Wie du vieleicht schon in der letzten Fehlermeldung beim Kompilieren gesehen hast lautet die Deklaration dieser Funktion:

Code:
declare function libusb_init(byval ctx as libusb_context ptr ptr) as long


Demzufolge benötigt diese Funktion eine Variable in der (vermutlich) die context-Daten der für dich geöffneten USB API gespeichert wird.

Hier könnte etwas in folgender Art helfen:

Code:

Dim MyUSBContext as libusb_context ptr
Print libusb_init(@MyUSBContext)


Zuerst wird eine Variable als Pointer mit der Passenden Typenstruktur Deklariert (Dim).
Anschliessend wird die Funktion aufgerufen, und die Adresse unserer Deklarierten Variable (und nicht deren Inhalt) durch das @ an die Funktion übergeben. Damit kennt die Funktion die Adresse unserer Variable im Speicher, und kann somit Daten in die Variable scheiben. (vergleichbar mit ByRef).

Nach dem Erfolgreichem Aufruf wird mit "Print" die Rückgabe des Funktionsaufrufes ausgebene. Hier sollte natürlich mit einem If...Then überprüft werden, ob der Funktionsaufruf auch erfolgreich war, bevor weitere USB API-Funktionen aufgerufen werden.


Zu 2.
"undefined reference to" bedeutet, das nach dem Kompilieren das sogenannte Linken fehl schlägt.
Hier versucht der Linker aus den vom Kompiler erzeugen Objekt-Datein (Dateiname.o) eine Binärdatei zu bauen (.exe / .bin). Bei diesem Prozess wird versucht auch alle API-Funktionen (in deinem Fall auch die USB-Aufrufe) mit ein zu bauen. ierzu sucht er in der entsprechenden Bibliothek (libusb.xxx) nach der entsprechenden Funktion. Findet er diese, schreibt er den Zugriffspunkt in der bibliothek in das Programm, um die Funktion aufrufen zu können.

Dies scheint jedoch nicht funktioniert zu haben. Der Linker kann die Position der Funktion "libusb_init" in keiner ihm bekannten Bibliothek finden.

Um das zu lösen gibt es mehrere möglichkeiten.
Zum einem kann man im Quellcode spezifizieren, das eine spezifische Bibliothek integriert werden soll, oder aber man übergibt den Ort der Bibliothek wärend des Compilvorganges per Commandozeile, oder aber, man spezifiziert die Deklaration expliziet als "extern", um C Spezifisch verarbeitet zu werden. Als letzt möglichkeit gibt es noch die "Detailiertere" Deklaration der Funktion mithilfe der Bibliotheksangabe.

Vorletztes und Letzteres sind gängig, und sollte helfen.

Bibliothek bekannt machen
Code:
inclib <Bibliothek>


Per Commandozeile die Bibliothek mitteilen
Code:
fbc <Codename.bas> -l <bibliotheksname>


oder, um den compiler suchen zu lassen
Code:
fbc <Codename.bas> -p <Verzeichniss der bibliothek>


Bibliothek mit in die Deklaration aufnehmen:
Code:
Declare <Funktionsname in der Bibliothek> alias <Funktionsname für FB> lib <Bibliotheksname> (Parameter) ....


"Extern" nutzen
Code:

Extern "C"
'Deklarationen hier einfügen
End Extern



MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]


Zuletzt bearbeitet von ThePuppetMaster am 10.08.2016, 23:07, insgesamt einmal bearbeitet
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
nemored



Anmeldungsdatum: 22.02.2007
Beiträge: 4594
Wohnort: ~/

BeitragVerfasst am: 10.08.2016, 22:51    Titel: Antworten mit Zitat

Du hattest vorher deklariert
Code:
declare function libusb_init(byval ctx as libusb_context ptr ptr) as long

deswegen muss auch ein Argument (vom Typ libusb_context ptr ptr) übergeben werden. Das erklärt die erste Fehlermeldung.
Die zweite Fehlermeldung bedeutet, dass du eine Funktion aufzurufen versuchst, die zwar deklariert wurde (obige declare-Zeile), deren Definition sich aber nirgendwo findet.

TPM hat ja schon ausführlich geantwortet. lächeln
_________________
Deine Chance beträgt 1:1000. Also musst du folgendes tun: Vergiss die 1000 und konzentriere dich auf die 1.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
ThePuppetMaster



Anmeldungsdatum: 18.02.2007
Beiträge: 1837
Wohnort: [JN58JR]

BeitragVerfasst am: 10.08.2016, 23:04    Titel: Antworten mit Zitat

(Ein EDIT spare ich mir jetzt mal, da bereits ne folgeantwort vorliegt.)

Zu beachten gilt "in der Regel", das Deklarationen in denen Parameter mit "Ptr Ptr" spezifiziert sind meistens den Inhalt der Variable abändern möchten.

Sprich: Die Funktion erzeugt einen Speicherplatz im Hauptspeicher und möchte dort Daten ablegen, welche später für andere Funktionsaufrufe benötigt werden.

Damit die Funktion die Daten nicht kopieren muss, übergibt diese deinem Programm nur die Adresse des Speicherbereiches (Pointer bzw. Ptr) an dein Programm zurück. Damit das Klappt, Muss der Funktion eine Variable mitgeteilt werden. Da die Funktionen meist im C-Stil geschrieben sind, arbeiten Sie meist mit Pointer, was die sache für ungeübte oft unübersichtlich gestaltet.

Um der Funktion nun unsere Variable mitteilen zu können, müssen wir der Funktion die Adresse unserer Variable im Speicher mitteilen. Dies geschied durch das @ (Adresse der Variable, anstat deren Inhalt).

Hier Erkennt man auch das doppelte Ptr Ptr.

Einfach ausgedrückt bedeutet das Erste Ptr, das es sich um einen Pointer auf die Informationsstruktur handelt. Das Zweite Ptr deutet auf die Adresse der Variable hin.

Wie in der Header zu erkennen, wird eigentlich nut bei den Inizisierenden Funktionen eine doppeltes Ptr verlangt, damit die Funktion die möglichkeit hat, dir die Adresse mitzuteilen.

die Anderen Funktionen verlangen in der Regel nur ein Ptr. Hier möchte die Funktion nur die Adresse wissen. Darum erfolgt bei diesen Funktionen der Aufruf ohne ein @ vor dem Variablenname.

(Das nur noch mal so am Rande)


MfG
TPM
_________________
[ WebFBC ][ OPS ][ ToOFlo ][ Wiemann.TV ]
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
BD



Anmeldungsdatum: 14.01.2014
Beiträge: 38

BeitragVerfasst am: 10.08.2016, 23:32    Titel: Antworten mit Zitat

Gerade habe ich mir nochmal die libusb.bi angeschaut. Dort steht die declare-Anweisung im "extern"-Bereich.

In der Beschreibung der libusb_init() steht:
Zitat:
int libusb_init ( libusb_context ** context )

Initialize libusb.

This function must be called before calling any other libusb function.

If you do not provide an output location for a context pointer, a default context will be created. If there was already a default context, it will be reused (and nothing will be initialized/reinitialized).

Parameters
context Optional output location for context pointer. Only valid on return code 0.

Returns
0 on success, or a LIBUSB_ERROR code on failure

See also
contexts

context ist demnach ein optionaler Parameter. Wie kann ich ihn auch in der libusb.bi optional machen?

Die Einbindung mit #inclib "libusb-1.0" funktioniert leider nicht
Zitat:
... cannot find -llibusb-1.0

Die Bibliothek ist aber vorhanden.

Für heute gebe ich es auf. Irgendwie stehe ich mit C auf Kriegsfuß.

Aber zunächst schon einmal vielen Dank an alle für die vielen Hilfestellungen. lächeln

------------------------------------------------------------------------

Nachtrag: Mit usb-1.0 statt libusb-1.0 findet er die Bibliothek. Problem ist noch der optionale Parameter in der libusb_init().

------------------------------------------------------------------------

Nachtrag 2:

Es wurde von fbfrog wohl auch das hier nicht umgesetzt:
Code:
int LIBUSB_CALL libusb_init(libusb_context **ctx);
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
const char * LIBUSB_CALL libusb_error_name(int errcode);
int LIBUSB_CALL libusb_setlocale(const char *locale);
const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);

ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
   libusb_device ***list);
void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
   int unref_devices);
libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
void LIBUSB_CALL libusb_unref_device(libusb_device *dev);

int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
   int *config);
int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
   struct libusb_device_descriptor *desc);
int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
   struct libusb_config_descriptor **config);
int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
   uint8_t config_index, struct libusb_config_descriptor **config);
int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
   uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
void LIBUSB_CALL libusb_free_config_descriptor(
   struct libusb_config_descriptor *config);
int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
   struct libusb_context *ctx,
   const struct libusb_endpoint_descriptor *endpoint,
   struct libusb_ss_endpoint_companion_descriptor **ep_comp);
void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
   struct libusb_ss_endpoint_companion_descriptor *ep_comp);
int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *handle,
   struct libusb_bos_descriptor **bos);
void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
   struct libusb_context *ctx,
   struct libusb_bos_dev_capability_descriptor *dev_cap,
   struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
   struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
   struct libusb_context *ctx,
   struct libusb_bos_dev_capability_descriptor *dev_cap,
   struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
   struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
   struct libusb_bos_dev_capability_descriptor *dev_cap,
   struct libusb_container_id_descriptor **container_id);
void LIBUSB_CALL libusb_free_container_id_descriptor(
   struct libusb_container_id_descriptor *container_id);
uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
   unsigned char endpoint);
int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
   unsigned char endpoint);

int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **handle);
void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);

int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev,
   int configuration);
int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev,
   int interface_number);
int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev,
   int interface_number);

libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
   libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);

int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev,
   int interface_number, int alternate_setting);
int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
   unsigned char endpoint);
int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);

int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev,
   uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev,
   unsigned char *endpoints, int num_endpoints);

int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
   int interface_number);
int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
   int interface_number);
int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev,
   int interface_number);
int LIBUSB_CALL libusb_set_auto_detach_kernel_driver(
   libusb_device_handle *dev, int enable);

Wie kann ich dies händisch machen?


Zuletzt bearbeitet von BD am 11.08.2016, 13:36, insgesamt 2-mal bearbeitet
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Linux-spezifische Fragen Alle Zeiten sind GMT + 1 Stunde
Gehe zu Seite 1, 2  Weiter
Seite 1 von 2

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.

 Impressum :: Datenschutz