[IE Myriad] "printf" methods were replaced with mvLog (#552)
This commit is contained in:
parent
d337b4ed97
commit
2012d084f2
@ -104,8 +104,7 @@ int XLinkPlatformBootRemote(deviceDesc_t* deviceDesc, const char* binaryPath)
|
|||||||
file = fopen(binaryPath, "rb");
|
file = fopen(binaryPath, "rb");
|
||||||
|
|
||||||
if(file == NULL) {
|
if(file == NULL) {
|
||||||
if(usb_loglevel)
|
mvLog(MVLOG_ERROR, "Cannot open file by path: %s", binaryPath);
|
||||||
perror(binaryPath);
|
|
||||||
return -7;
|
return -7;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,15 +113,13 @@ int XLinkPlatformBootRemote(deviceDesc_t* deviceDesc, const char* binaryPath)
|
|||||||
rewind(file);
|
rewind(file);
|
||||||
if(file_size <= 0 || !(image_buffer = (char*)malloc(file_size)))
|
if(file_size <= 0 || !(image_buffer = (char*)malloc(file_size)))
|
||||||
{
|
{
|
||||||
if(usb_loglevel)
|
mvLog(MVLOG_ERROR, "cannot allocate image_buffer. file_size = %ld", file_size);
|
||||||
perror("buffer");
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if(fread(image_buffer, 1, file_size, file) != file_size)
|
if(fread(image_buffer, 1, file_size, file) != file_size)
|
||||||
{
|
{
|
||||||
if(usb_loglevel)
|
mvLog(MVLOG_ERROR, "cannot read file to image_buffer");
|
||||||
perror(binaryPath);
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
free(image_buffer);
|
free(image_buffer);
|
||||||
return -7;
|
return -7;
|
||||||
@ -158,8 +155,8 @@ int XLinkPlatformBootRemote(deviceDesc_t* deviceDesc, const char* binaryPath)
|
|||||||
rc = usb_boot(deviceDesc->name, image_buffer, file_size);
|
rc = usb_boot(deviceDesc->name, image_buffer, file_size);
|
||||||
free(image_buffer);
|
free(image_buffer);
|
||||||
|
|
||||||
if(!rc && usb_loglevel > 1) {
|
if(!rc) {
|
||||||
fprintf(stderr, "Boot successful, device address %s\n", deviceDesc->name);
|
mvLog(MVLOG_DEBUG, "Boot successful, device address %s", deviceDesc->name);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
} else {
|
} else {
|
||||||
@ -249,7 +246,7 @@ libusb_device_handle *usbLinkOpen(const char *path)
|
|||||||
if (libusb_rc < 0)
|
if (libusb_rc < 0)
|
||||||
{
|
{
|
||||||
if(last_open_dev_err[0])
|
if(last_open_dev_err[0])
|
||||||
fprintf(stderr, "%s\n", last_open_dev_err);
|
mvLog(MVLOG_ERROR, "Last opened device name: %s", last_open_dev_err);
|
||||||
|
|
||||||
usb_close_device(h);
|
usb_close_device(h);
|
||||||
usb_free_device(dev);
|
usb_free_device(dev);
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "win_usb.h"
|
#include "win_usb.h"
|
||||||
|
|
||||||
|
#define MVLOG_UNIT_NAME xLinkWinUsb
|
||||||
|
#include "XLinkLog.h"
|
||||||
#include "XLinkStringUtils.h"
|
#include "XLinkStringUtils.h"
|
||||||
|
|
||||||
#define USB_DIR_OUT 0
|
#define USB_DIR_OUT 0
|
||||||
@ -85,7 +87,7 @@ static const char *format_win32_msg(DWORD errId) {
|
|||||||
|
|
||||||
static void wperror(const char *errmsg) {
|
static void wperror(const char *errmsg) {
|
||||||
DWORD errId = GetLastError();
|
DWORD errId = GetLastError();
|
||||||
fprintf(stderr, "%s: System err %d\n", errmsg, errId);
|
mvLog(MVLOG_DEBUG, "%s: System err %d\n", errmsg, errId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wstrerror(char *buff, const char *errmsg) {
|
static void wstrerror(char *buff, const char *errmsg) {
|
||||||
@ -462,7 +464,7 @@ int usb_bulk_write(usb_hwnd han, uint8_t ep, const void *buffer, size_t sz, uint
|
|||||||
if(last_bulk_errcode == ERROR_SEM_TIMEOUT)
|
if(last_bulk_errcode == ERROR_SEM_TIMEOUT)
|
||||||
return USB_ERR_TIMEOUT;
|
return USB_ERR_TIMEOUT;
|
||||||
wperror("WinUsb_WritePipe");
|
wperror("WinUsb_WritePipe");
|
||||||
printf("\nWinUsb_WritePipe failed with error:=%d\n", GetLastError());
|
mvLog(MVLOG_ERROR, "\nWinUsb_WritePipe failed with error:=%d\n", GetLastError());
|
||||||
return USB_ERR_FAILED;
|
return USB_ERR_FAILED;
|
||||||
}
|
}
|
||||||
last_bulk_errcode = 0;
|
last_bulk_errcode = 0;
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
#define DEFAULT_SEND_FILE_TIMEOUT 10000
|
#define DEFAULT_SEND_FILE_TIMEOUT 10000
|
||||||
#define USB1_CHUNKSZ 64
|
#define USB1_CHUNKSZ 64
|
||||||
|
|
||||||
|
#define MVLOG_UNIT_NAME xLinkUsb
|
||||||
|
#include "XLinkLog.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ADDRESS_BUFF_SIZE 35 = 4*7+7.
|
* ADDRESS_BUFF_SIZE 35 = 4*7+7.
|
||||||
* '255-' x 7 (also gives us nul-terminator for last entry)
|
* '255-' x 7 (also gives us nul-terminator for last entry)
|
||||||
@ -70,7 +73,6 @@ static deviceBootInfo_t supportedDevices[] = {
|
|||||||
// for now we'll only use the loglevel for usb boot. can bring it into
|
// for now we'll only use the loglevel for usb boot. can bring it into
|
||||||
// the rest of usblink later
|
// the rest of usblink later
|
||||||
// use same levels as mvnc_loglevel for now
|
// use same levels as mvnc_loglevel for now
|
||||||
int usb_loglevel = 0;
|
|
||||||
#if (defined(_WIN32) || defined(_WIN64) )
|
#if (defined(_WIN32) || defined(_WIN64) )
|
||||||
void initialize_usb_boot()
|
void initialize_usb_boot()
|
||||||
{
|
{
|
||||||
@ -123,9 +125,6 @@ static const char *get_pid_name(int pid)
|
|||||||
return supportedDevices[i].name;
|
return supportedDevices[i].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usb_loglevel)
|
|
||||||
fprintf(stderr, "%s(): Error pid:=%i not supported\n", __func__, pid);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +137,7 @@ int get_pid_by_name(const char* name)
|
|||||||
{
|
{
|
||||||
char* p = strchr(name, '-');
|
char* p = strchr(name, '-');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
if (usb_loglevel) {
|
mvLog(MVLOG_DEBUG, "Device name (%s) not supported", name);
|
||||||
fprintf(stderr, "%s(): Error name (%s) not supported\n", __func__, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p++; //advance to point to the name
|
p++; //advance to point to the name
|
||||||
@ -253,7 +249,7 @@ static pthread_mutex_t globalMutex = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
||||||
unsigned addrsize, void **device, int vid, int pid, uint16_t* bcdusb) {
|
unsigned addrsize, void **device, int vid, int pid, uint16_t* bcdusb) {
|
||||||
if (pthread_mutex_lock(&globalMutex)) {
|
if (pthread_mutex_lock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex lock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex lock failed");
|
||||||
return USB_BOOT_ERROR;
|
return USB_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
int searchByName = 0;
|
int searchByName = 0;
|
||||||
@ -265,10 +261,9 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (usb_loglevel)
|
mvLog(MVLOG_ERROR, "Library has not been initialized when loaded");
|
||||||
fprintf(stderr, "Library has not been initialized when loaded\n");
|
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_ERROR;
|
return USB_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
@ -284,10 +279,9 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
devs = 0;
|
devs = 0;
|
||||||
}
|
}
|
||||||
if ((res = libusb_get_device_list(NULL, &devs)) < 0) {
|
if ((res = libusb_get_device_list(NULL, &devs)) < 0) {
|
||||||
if (usb_loglevel)
|
mvLog(MVLOG_DEBUG, "Unable to get USB device list: %s", libusb_strerror(res));
|
||||||
fprintf(stderr, "Unable to get USB device list: %s\n", libusb_strerror(res));
|
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_ERROR;
|
return USB_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
@ -297,8 +291,7 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
i = 0;
|
i = 0;
|
||||||
while ((dev = devs[i++]) != NULL) {
|
while ((dev = devs[i++]) != NULL) {
|
||||||
if ((res = libusb_get_device_descriptor(dev, &desc)) < 0) {
|
if ((res = libusb_get_device_descriptor(dev, &desc)) < 0) {
|
||||||
if (usb_loglevel)
|
mvLog(MVLOG_DEBUG, "Unable to get USB device descriptor: %s", libusb_strerror(res));
|
||||||
fprintf(stderr, "Unable to get USB device descriptor: %s\n", libusb_strerror(res));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,10 +313,8 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
if (device) {
|
if (device) {
|
||||||
const char *dev_addr = gen_addr(dev, get_pid_by_name(input_addr));
|
const char *dev_addr = gen_addr(dev, get_pid_by_name(input_addr));
|
||||||
if (!strcmp(dev_addr, input_addr)) {
|
if (!strcmp(dev_addr, input_addr)) {
|
||||||
if (usb_loglevel > 1) {
|
mvLog(MVLOG_DEBUG, "Found Address: %s - VID/PID %04x:%04x",
|
||||||
fprintf(stderr, "Found Address: %s - VID/PID %04x:%04x\n",
|
|
||||||
input_addr, desc.idVendor, desc.idProduct);
|
input_addr, desc.idVendor, desc.idProduct);
|
||||||
}
|
|
||||||
|
|
||||||
libusb_ref_device(dev);
|
libusb_ref_device(dev);
|
||||||
libusb_free_device_list(devs, 1);
|
libusb_free_device_list(devs, 1);
|
||||||
@ -333,7 +324,7 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
devs = 0;
|
devs = 0;
|
||||||
|
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -341,24 +332,21 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
const char *dev_addr = gen_addr(dev, desc.idProduct);
|
const char *dev_addr = gen_addr(dev, desc.idProduct);
|
||||||
// If the same add as input
|
// If the same add as input
|
||||||
if (!strcmp(dev_addr, input_addr)) {
|
if (!strcmp(dev_addr, input_addr)) {
|
||||||
if (usb_loglevel > 1) {
|
mvLog(MVLOG_DEBUG, "Found Address: %s - VID/PID %04x:%04x",
|
||||||
fprintf(stderr, "Found Address: %s - VID/PID %04x:%04x\n",
|
|
||||||
input_addr, desc.idVendor, desc.idProduct);
|
input_addr, desc.idVendor, desc.idProduct);
|
||||||
}
|
|
||||||
|
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
}
|
}
|
||||||
} else if (idx == count) {
|
} else if (idx == count) {
|
||||||
const char *caddr = gen_addr(dev, desc.idProduct);
|
const char *caddr = gen_addr(dev, desc.idProduct);
|
||||||
if (usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Device %d Address: %s - VID/PID %04x:%04x",
|
||||||
fprintf(stderr, "Device %d Address: %s - VID/PID %04x:%04x\n",
|
|
||||||
idx, caddr, desc.idVendor, desc.idProduct);
|
idx, caddr, desc.idVendor, desc.idProduct);
|
||||||
mv_strncpy(input_addr, addrsize, caddr, addrsize - 1);
|
mv_strncpy(input_addr, addrsize, caddr, addrsize - 1);
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -368,7 +356,7 @@ usbBootError_t usb_find_device_with_bcd(unsigned idx, char *input_addr,
|
|||||||
libusb_free_device_list(devs, 1);
|
libusb_free_device_list(devs, 1);
|
||||||
devs = 0;
|
devs = 0;
|
||||||
if (pthread_mutex_unlock(&globalMutex)) {
|
if (pthread_mutex_unlock(&globalMutex)) {
|
||||||
fprintf(stderr, "Mutex unlock failed\n");
|
mvLog(MVLOG_ERROR, "globalMutex unlock failed");
|
||||||
}
|
}
|
||||||
return USB_BOOT_DEVICE_NOT_FOUND;
|
return USB_BOOT_DEVICE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -396,15 +384,13 @@ usbBootError_t usb_find_device(unsigned idx, char *addr, unsigned addrsize, void
|
|||||||
|
|
||||||
if(!initialized)
|
if(!initialized)
|
||||||
{
|
{
|
||||||
if(usb_loglevel)
|
mvLog(MVLOG_ERROR, "Library has not been initialized when loaded");
|
||||||
fprintf(stderr, "Library has not been initialized when loaded\n");
|
|
||||||
return USB_BOOT_ERROR;
|
return USB_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
if (devs_cnt == 0 || idx == 0) {
|
if (devs_cnt == 0 || idx == 0) {
|
||||||
devs_cnt = 0;
|
devs_cnt = 0;
|
||||||
if (((res = usb_list_devices(vid, pid, devs)) < 0)) {
|
if (((res = usb_list_devices(vid, pid, devs)) < 0)) {
|
||||||
if (usb_loglevel)
|
mvLog(MVLOG_DEBUG, "Unable to get USB device list: %s", libusb_strerror(res));
|
||||||
fprintf(stderr, "Unable to get USB device list: %s\n", libusb_strerror(res));
|
|
||||||
return USB_BOOT_ERROR;
|
return USB_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
devs_cnt = res;
|
devs_cnt = res;
|
||||||
@ -436,8 +422,7 @@ usbBootError_t usb_find_device(unsigned idx, char *addr, unsigned addrsize, void
|
|||||||
const char *caddr = &devs[res][4];
|
const char *caddr = &devs[res][4];
|
||||||
if (strncmp(addr, caddr, XLINK_MAX_NAME_SIZE) == 0)
|
if (strncmp(addr, caddr, XLINK_MAX_NAME_SIZE) == 0)
|
||||||
{
|
{
|
||||||
if (usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Found Address: %s - VID/PID %04x:%04x", caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
||||||
fprintf(stderr, "Found Address: %s - VID/PID %04x:%04x\n", caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
|
||||||
*device = enumerate_usb_device(vid, pid, caddr, 0);
|
*device = enumerate_usb_device(vid, pid, caddr, 0);
|
||||||
devs_cnt = 0;
|
devs_cnt = 0;
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
@ -447,16 +432,14 @@ usbBootError_t usb_find_device(unsigned idx, char *addr, unsigned addrsize, void
|
|||||||
const char *caddr = &devs[res][4];
|
const char *caddr = &devs[res][4];
|
||||||
if (strncmp(addr, caddr, XLINK_MAX_NAME_SIZE) == 0)
|
if (strncmp(addr, caddr, XLINK_MAX_NAME_SIZE) == 0)
|
||||||
{
|
{
|
||||||
if (usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Found Address: %s - VID/PID %04x:%04x", caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
||||||
fprintf(stderr, "Found Address: %s - VID/PID %04x:%04x\n", caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (idx == count)
|
else if (idx == count)
|
||||||
{
|
{
|
||||||
const char *caddr = &devs[res][4];
|
const char *caddr = &devs[res][4];
|
||||||
if (usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Device %d Address: %s - VID/PID %04x:%04x", idx, caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
||||||
fprintf(stderr, "Device %d Address: %s - VID/PID %04x:%04x\n", idx, caddr, (int)(devs[res][0] << 8 | devs[res][1]), (int)(devs[res][2] << 8 | devs[res][3]));
|
|
||||||
mv_strncpy(addr, addrsize, caddr, addrsize - 1);
|
mv_strncpy(addr, addrsize, caddr, addrsize - 1);
|
||||||
return USB_BOOT_SUCCESS;
|
return USB_BOOT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -503,8 +486,7 @@ static libusb_device_handle *usb_open_device(libusb_device *dev, uint8_t *endpoi
|
|||||||
ifdesc = cdesc->interface->altsetting;
|
ifdesc = cdesc->interface->altsetting;
|
||||||
for(i=0; i<ifdesc->bNumEndpoints; i++)
|
for(i=0; i<ifdesc->bNumEndpoints; i++)
|
||||||
{
|
{
|
||||||
if(usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Found EP 0x%02x : max packet size is %u bytes",
|
||||||
fprintf(stderr, "Found EP 0x%02x : max packet size is %u bytes\n",
|
|
||||||
ifdesc->endpoint[i].bEndpointAddress, ifdesc->endpoint[i].wMaxPacketSize);
|
ifdesc->endpoint[i].bEndpointAddress, ifdesc->endpoint[i].wMaxPacketSize);
|
||||||
if((ifdesc->endpoint[i].bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) != LIBUSB_TRANSFER_TYPE_BULK)
|
if((ifdesc->endpoint[i].bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) != LIBUSB_TRANSFER_TYPE_BULK)
|
||||||
continue;
|
continue;
|
||||||
@ -542,14 +524,13 @@ static int wait_findopen(const char *device_address, int timeout, libusb_device
|
|||||||
}
|
}
|
||||||
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
if(usb_loglevel > 1)
|
|
||||||
{
|
|
||||||
if(timeout == -1)
|
if(timeout == -1)
|
||||||
fprintf(stderr, "Starting wait for connect, no timeout\n");
|
mvLog(MVLOG_DEBUG, "Starting wait for connect, no timeout");
|
||||||
else if(timeout == 0)
|
else if(timeout == 0)
|
||||||
fprintf(stderr, "Trying to connect\n");
|
mvLog(MVLOG_DEBUG, "Trying to connect");
|
||||||
else fprintf(stderr, "Starting wait for connect with %ums timeout\n", timeout);
|
else mvLog(MVLOG_DEBUG, "Starting wait for connect with %ums timeout", timeout);
|
||||||
}
|
|
||||||
last_open_dev_err[0] = 0;
|
last_open_dev_err[0] = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
@ -574,8 +555,7 @@ static int wait_findopen(const char *device_address, int timeout, libusb_device
|
|||||||
#endif
|
#endif
|
||||||
if(*devh != NULL)
|
if(*devh != NULL)
|
||||||
{
|
{
|
||||||
if(usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Found and opened device");
|
||||||
fprintf(stderr, "Found and opened device\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if (!defined(_WIN32) && !defined(_WIN64) )
|
#if (!defined(_WIN32) && !defined(_WIN64) )
|
||||||
@ -587,13 +567,12 @@ static int wait_findopen(const char *device_address, int timeout, libusb_device
|
|||||||
elapsedTime += highres_elapsed_ms(&t1, &t2);
|
elapsedTime += highres_elapsed_ms(&t1, &t2);
|
||||||
|
|
||||||
if(timeout != -1)
|
if(timeout != -1)
|
||||||
{
|
|
||||||
if(usb_loglevel)
|
|
||||||
{
|
{
|
||||||
if(last_open_dev_err[0])
|
if(last_open_dev_err[0])
|
||||||
fprintf(stderr, "%s", last_open_dev_err);
|
mvLog(MVLOG_ERROR, "Last opened device name: %s", last_open_dev_err);
|
||||||
fprintf(stderr, "error: device not found!\n");
|
|
||||||
}
|
mvLog(MVLOG_ERROR, "error: device not found!");
|
||||||
|
|
||||||
return rc ? USB_BOOT_DEVICE_NOT_FOUND : USB_BOOT_TIMEOUT;
|
return rc ? USB_BOOT_DEVICE_NOT_FOUND : USB_BOOT_TIMEOUT;
|
||||||
} else if (elapsedTime > (double)timeout) {
|
} else if (elapsedTime > (double)timeout) {
|
||||||
return rc ? USB_BOOT_DEVICE_NOT_FOUND : USB_BOOT_TIMEOUT;
|
return rc ? USB_BOOT_DEVICE_NOT_FOUND : USB_BOOT_TIMEOUT;
|
||||||
@ -625,8 +604,7 @@ static int send_file(libusb_device_handle *h, uint8_t endpoint, const uint8_t *t
|
|||||||
bulk_chunklen = USB1_CHUNKSZ;
|
bulk_chunklen = USB1_CHUNKSZ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(usb_loglevel > 1)
|
mvLog(MVLOG_DEBUG, "Performing bulk write of %u bytes...", filesize);
|
||||||
fprintf(stderr, "Performing bulk write of %u bytes...\n", filesize);
|
|
||||||
while((unsigned)twb < filesize)
|
while((unsigned)twb < filesize)
|
||||||
{
|
{
|
||||||
highres_gettime(&t1);
|
highres_gettime(&t1);
|
||||||
@ -643,8 +621,7 @@ static int send_file(libusb_device_handle *h, uint8_t endpoint, const uint8_t *t
|
|||||||
{
|
{
|
||||||
if(rc == LIBUSB_ERROR_NO_DEVICE)
|
if(rc == LIBUSB_ERROR_NO_DEVICE)
|
||||||
break;
|
break;
|
||||||
if(usb_loglevel)
|
mvLog(MVLOG_WARN, "bulk write: %s (%d bytes written, %d bytes to write)", libusb_strerror(rc), wbr, wb);
|
||||||
fprintf(stderr, "bulk write: %s (%d bytes written, %d bytes to write)\n", libusb_strerror(rc), wbr, wb);
|
|
||||||
if(rc == LIBUSB_ERROR_TIMEOUT)
|
if(rc == LIBUSB_ERROR_TIMEOUT)
|
||||||
return USB_BOOT_TIMEOUT;
|
return USB_BOOT_TIMEOUT;
|
||||||
else return USB_BOOT_ERROR;
|
else return USB_BOOT_ERROR;
|
||||||
@ -657,11 +634,12 @@ static int send_file(libusb_device_handle *h, uint8_t endpoint, const uint8_t *t
|
|||||||
twb += wbr;
|
twb += wbr;
|
||||||
p += wbr;
|
p += wbr;
|
||||||
}
|
}
|
||||||
if(usb_loglevel > 1)
|
|
||||||
{
|
#ifndef NDEBUG
|
||||||
double MBpS = ((double)filesize / 1048576.) / (elapsedTime * 0.001);
|
double MBpS = ((double)filesize / 1048576.) / (elapsedTime * 0.001);
|
||||||
fprintf(stderr, "Successfully sent %u bytes of data in %lf ms (%lf MB/s)\n", filesize, elapsedTime, MBpS);
|
mvLog(MVLOG_DEBUG, "Successfully sent %u bytes of data in %lf ms (%lf MB/s)", filesize, elapsedTime, MBpS);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int usb_loglevel;
|
|
||||||
|
|
||||||
#define AUTO_VID 0
|
#define AUTO_VID 0
|
||||||
#define AUTO_PID 0
|
#define AUTO_PID 0
|
||||||
#define AUTO_UNBOOTED_PID -1
|
#define AUTO_UNBOOTED_PID -1
|
||||||
|
Loading…
Reference in New Issue
Block a user