108 lines
2.4 KiB
C
108 lines
2.4 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <libusb.h>
|
|
|
|
|
|
#ifndef _usbutes_
|
|
#define _usbutes_
|
|
|
|
|
|
typedef struct _typUSB {
|
|
libusb_context * pctx;
|
|
libusb_device_handle * hdev;
|
|
libusb_device * pdev;
|
|
int iface;
|
|
int config;
|
|
int vendor;
|
|
int device;
|
|
int debug;
|
|
} typUSB;
|
|
|
|
|
|
void hexdump(unsigned char * , int , int );
|
|
void imgdump(unsigned char[], int, int, int);
|
|
unsigned char * ctlxfer(libusb_device_handle * , uint , uint , uint , uint , int );
|
|
int bulkSend(libusb_device_handle * , int , unsigned char * , int );
|
|
unsigned char * bulkReceive(libusb_device_handle * , int , int );
|
|
int usbscan(libusb_context * );
|
|
void usbstats( libusb_device_handle * , libusb_device * , int);
|
|
int usbopen(typUSB * , int, int, int, int);
|
|
int usbclose(typUSB * );
|
|
void usbdump(typUSB * );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
enum libusb_error {
|
|
** Success (no error) *
|
|
LIBUSB_SUCCESS = 0,
|
|
|
|
** Input/output error *
|
|
LIBUSB_ERROR_IO = -1,
|
|
|
|
** Invalid parameter *
|
|
LIBUSB_ERROR_INVALID_PARAM = -2,
|
|
|
|
** Access denied (insufficient permissions) *
|
|
LIBUSB_ERROR_ACCESS = -3,
|
|
|
|
** No such device (it may have been disconnected) *
|
|
LIBUSB_ERROR_NO_DEVICE = -4,
|
|
|
|
** Entity not found *
|
|
LIBUSB_ERROR_NOT_FOUND = -5,
|
|
|
|
** Resource busy *
|
|
LIBUSB_ERROR_BUSY = -6,
|
|
|
|
** Operation timed out *
|
|
LIBUSB_ERROR_TIMEOUT = -7,
|
|
|
|
** Overflow *
|
|
LIBUSB_ERROR_OVERFLOW = -8,
|
|
|
|
** Pipe error *
|
|
LIBUSB_ERROR_PIPE = -9,
|
|
|
|
** System call interrupted (perhaps due to signal) *
|
|
LIBUSB_ERROR_INTERRUPTED = -10,
|
|
|
|
** Insufficient memory *
|
|
LIBUSB_ERROR_NO_MEM = -11,
|
|
|
|
** Operation not supported or unimplemented on this platform *
|
|
LIBUSB_ERROR_NOT_SUPPORTED = -12,
|
|
|
|
* NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
|
|
message strings in strerror.c when adding new error codes here. *
|
|
|
|
** Other error *
|
|
LIBUSB_ERROR_OTHER = -99
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
Copyright (c) Atlantean Technical Solutions Limited (ATSL) 2022
|
|
|
|
This software has been produced by ATSL and is the copyright of ATSL. The
|
|
use of source code for the software is strictly governed by the terms and
|
|
conditions of the source code licence. Any unauthorised use of the source
|
|
source code for the software in any manner shall invalidate the licence,
|
|
any existing warranty and software support agreements by ATSL.
|
|
|
|
@proj usbutes
|
|
@subsys CCL
|
|
@file ccl.c
|
|
@brief <B> *** Useful general purpose common C functions *** </B>
|
|
@author GoodwinC
|
|
@date 2022-10-27
|
|
@spec N.A
|
|
|
|
*/
|