diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 004ce0ae..59ee1e1a 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1023,8 +1023,8 @@ namespace pv spectrum_rebuild(); - dsv_info("Rebuild channnel list, logic channel count:%d, dso channel count:%d, all:%d", - logic_chan_num, dso_chan_num, all_chann_num); + //dsv_info("Rebuild channnel list, logic channel count:%d, dso channel count:%d, all:%d", + // logic_chan_num, dso_chan_num, all_chann_num); } void SigSession::refresh(int holdtime) @@ -1442,7 +1442,7 @@ namespace pv out_trace = NULL; - dsv_info("Create new decoder,name:\"%s\",id:\"%s\"", dec->name, dec->id); + //dsv_info("Create new decoder,name:\"%s\",id:\"%s\"", dec->name, dec->id); try { diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index 85720c4e..eb272a67 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -207,7 +207,7 @@ static GSList *scan(GSList *options) if (options != NULL) sr_info("%s", "Scan DSCope device with options."); else - sr_info("%s", "Scan DSCope device."); + sr_info("%s", "Scan DSCope device..."); conn = NULL; for (l = options; l; l = l->next) { @@ -314,7 +314,7 @@ static GSList *scan(GSList *options) bus = libusb_get_bus_number(device_handle); address = libusb_get_device_address(device_handle); - sr_info("Found a new device,handle:%p,bus:%d,address:%d", device_handle, bus, address); + sr_info("Found a new device,handle:%p", device_handle); devc = DSCope_dev_new(prof); if (!devc) @@ -386,7 +386,7 @@ static GSList *scan(GSList *options) g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free); } - sr_info("Fond new DSCope device count: %d", num); + sr_info("Found new DSCope device count: %d", num); if (is_speed_not_match){ post_message_callback(DS_EV_DEVICE_SPEED_NOT_MATCH); diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 6ac95bfe..7e0bd15a 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -331,6 +331,7 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) if (ret != LIBUSB_SUCCESS){ sr_err("Failed to open device: %s, handle:%p", libusb_error_name(ret), dev_handel); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); return SR_ERR; } //sr_info("------------Open returns the libusb_device_handle: %p, struct:%p", usb->devhdl, usb); @@ -349,6 +350,7 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) if ((ret = command_ctl_rd(usb->devhdl, rd_cmd)) != SR_OK) { sr_err("Failed to get firmware version."); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); return ret; } @@ -377,7 +379,7 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) if ((sdi->status != SR_ST_ACTIVE) && (sdi->status != SR_ST_INCOMPATIBLE)){ - return SR_ERR; + assert(0); } return SR_OK; @@ -1823,7 +1825,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo */ ret = SR_ERR; if (devc->fw_updated > 0) { - sr_info("%s: Firmware upload have done."); + sr_info("%s: Firmware upload have done.", __func__); return SR_ERR; } else { @@ -1881,6 +1883,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo if ((ret = command_ctl_rd(usb->devhdl, rd_cmd)) != SR_OK) { sr_err("Failed to get hardware infos."); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); return SR_ERR; } *fpga_done = (hw_info & bmFPGA_DONE) != 0; @@ -1889,6 +1892,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo if (!(*fpga_done)) { char *fpga_bit; char *res_path = DS_RES_PATH; + if (!(fpga_bit = malloc(strlen(res_path)+strlen(devc->profile->fpga_bit33) + 5))) { sr_err("fpag_bit path malloc error!"); return SR_ERR_MALLOC; @@ -1906,13 +1910,17 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo default: return SR_ERR; } + ret = dsl_fpga_config(usb->devhdl, fpga_bit); g_free(fpga_bit); + if (ret != SR_OK) { sr_err("%s: Configure FPGA failed!", __func__); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); return SR_ERR; } - } else { + } + else { ret = dsl_wr_reg(sdi, CTR0_ADDR, bmNONE); // dessert clear /* Check HDL version */ ret = dsl_hdl_version(sdi, &hw_info); @@ -1939,12 +1947,14 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo ret = dsl_wr_reg(sdi, CTR0_ADDR, bmNONE); // dessert clear if (dsl_rd_nvm(sdi, (unsigned char *)encryption, SECU_EEP_ADDR, SECU_STEPS*2) != SR_OK) { sr_err("Read EEPROM content failed!"); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); return SR_ERR; } - ret = dsl_secuCheck(sdi, encryption, SECU_STEPS); - if (ret != SR_OK) - sr_err("Security check failed!"); + ret = dsl_secuCheck(sdi, encryption, SECU_STEPS); + if (ret != SR_OK){ + sr_err("Security check failed!"); + } return SR_OK; } diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index dd61d08f..fe4c4c48 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -293,7 +293,7 @@ static GSList *scan(GSList *options) if (options != NULL) sr_info("%s", "Scan DSLogic device with options."); else - sr_info("%s", "Scan DSLogic device."); + sr_info("%s", "Scan DSLogic device..."); conn = NULL; for (l = options; l; l = l->next) { @@ -402,7 +402,7 @@ static GSList *scan(GSList *options) bus = libusb_get_bus_number(device_handle); address = libusb_get_device_address(device_handle); - sr_info("Found a new device,handle:%p,bus:%d,address:%d", device_handle, bus, address); + sr_info("Found a new device,handle:%p", device_handle); devc = DSLogic_dev_new(prof); if (!devc) @@ -471,7 +471,7 @@ static GSList *scan(GSList *options) g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free); } - sr_info("Fond new DSLogic device count: %d", num); + sr_info("Found new DSLogic device count: %d", num); if (is_speed_not_match){ post_message_callback(DS_EV_DEVICE_SPEED_NOT_MATCH); @@ -1277,6 +1277,12 @@ static int dev_open(struct sr_dev_inst *sdi) ret = dsl_wr_reg(sdi, VTH_ADDR, (uint8_t)(devc->vth/5.0*(2.5/3.3)*255)); else ret = dsl_wr_reg(sdi, VTH_ADDR, (uint8_t)(devc->vth/5.0*255)); + + if (ret != SR_OK){ + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); + return ret; + } + // set threshold if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_ADF4360) { dsl_config_adc(sdi, adc_clk_init_500m); diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index 315e88e1..f76751b9 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -603,8 +603,6 @@ static GSList *hw_scan(GSList *options) (void)options; devices = NULL; - sr_info("%s", "Scan demo device."); - vdev = malloc(sizeof(struct session_vdev)); if (vdev == NULL) { diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index e97cb3e4..24de076e 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -363,7 +363,7 @@ SR_API int ds_active_device(ds_device_handle handle) if (ds_is_collecting()) { - sr_err("%s", "Error!The current device is collecting, can not switch it."); + sr_err("%s", "Error!The current device is collecting, can not switch to it."); return SR_ERR_CALL_STATUS; } @@ -373,14 +373,17 @@ SR_API int ds_active_device(ds_device_handle handle) { if (lib_ctx.is_delay_destory_actived_device) { - sr_info("The current device is delayed for destruction, handle:%p", lib_ctx.actived_device_instance->handle); + sr_info("The current device is delayed for destruction, name:\"%s\", handle:%p", + lib_ctx.actived_device_instance->name, + lib_ctx.actived_device_instance->handle); destroy_device_instance(lib_ctx.actived_device_instance); lib_ctx.actived_device_instance = NULL; lib_ctx.is_delay_destory_actived_device = 0; } else { - sr_info("Close the previous device \"%s\"", lib_ctx.actived_device_instance->name); + sr_info("Close the previous device, name:\"%s\"", + lib_ctx.actived_device_instance->name); close_device_instance(lib_ctx.actived_device_instance); old_dev = lib_ctx.actived_device_instance; } @@ -399,9 +402,9 @@ SR_API int ds_active_device(ds_device_handle handle) } if (dev->dev_type == DEV_TYPE_FILELOG) - sr_info("virtual device name: \"%s\".", dev->name); + sr_info("Activating virtual device name: \"%s\".", dev->name); else - sr_info("device name: \"%s\".", dev->name); + sr_info("Activating device name: \"%s\".", dev->name); ret = open_device_instance(dev); @@ -413,17 +416,24 @@ SR_API int ds_active_device(ds_device_handle handle) else { // Failed to switch new device. - if (old_dev != NULL && old_dev != dev){ - sr_err("%s", "Open device error! the current device switch failed."); - lib_ctx.actived_device_instance = old_dev; - ret = open_device_instance(old_dev); + if(lib_ctx.device_list != NULL && old_dev == NULL){ + old_dev = lib_ctx.device_list->data; } - else if(lib_ctx.device_list != NULL){ - old_dev = lib_ctx.device_list->data; - sr_err("%s", "Open device error! the current device switch to demo."); + + if (old_dev != NULL){ + if (old_dev->dev_type == DEV_TYPE_USB){ + sr_err("%s", "Open device error! Will switch to \"%s\", handle:%p.", + old_dev->name, + old_dev->handle); + } + else{ + sr_err("%s", "Open device error! Will switch to \"%s\".", + old_dev->name); + } + lib_ctx.actived_device_instance = old_dev; ret = open_device_instance(old_dev); - } + } } break; } @@ -435,7 +445,7 @@ SR_API int ds_active_device(ds_device_handle handle) if (!bFind) { - sr_err("ds_active_device() error, can't find the device."); + sr_err("Active device error, can't find the device."); return SR_ERR_CALL_STATUS; } @@ -858,11 +868,22 @@ SR_API int ds_release_actived_device() if (lib_ctx.actived_device_instance == NULL){ return SR_ERR_CALL_STATUS; } + if (ds_is_collecting()){ ds_stop_collect(); } - sr_info("%s", "Release current actived device."); + if (lib_ctx.actived_device_instance->dev_type == DEV_TYPE_USB) + { + sr_info("%s", "Release current actived device. name:\"%s\", handle:%p", + lib_ctx.actived_device_instance->name, + lib_ctx.actived_device_instance->handle); + } + else + { + sr_info("%s", "Release current actived device. name:\"%s\"", + lib_ctx.actived_device_instance->name); + } close_device_instance(lib_ctx.actived_device_instance); @@ -1215,7 +1236,7 @@ static void hotplug_event_listen_callback(struct libusb_context *ctx, struct lib } if (dev == NULL){ - sr_err("%s", "hotplug_event_listen_callback(), no devices to process"); + sr_err("%s", "hotplug_event_listen_callback(), the device handle is null."); return; } @@ -1311,8 +1332,6 @@ static void process_attach_event(int isEvent) dev_list = dr->scan(NULL); if (dev_list != NULL) { - sr_info("Get new device list by driver \"%s\"", dr->name); - pthread_mutex_lock(&lib_ctx.mutext); for (l = dev_list; l; l = l->next) @@ -1522,6 +1541,7 @@ static int open_device_instance(struct sr_dev_inst *dev) if (driver_ins->dev_open) { + sr_info("To open device, name:\"%s\"", dev->name); return driver_ins->dev_open(dev); } @@ -1567,8 +1587,6 @@ static struct libusb_device* get_new_attached_usb_device() struct libusb_device* dev; struct sr_dev_inst *dev_ins; - sr_info("To find new attached device."); - dev = NULL; num = 0; ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, &array, MAX_DEVCIE_LIST_LENGTH, &num); @@ -1594,8 +1612,8 @@ static struct libusb_device* get_new_attached_usb_device() pthread_mutex_unlock(&lib_ctx.mutext); - if (dev != NULL){ - sr_info("Found new attached usb device:%p", dev); + if (dev == NULL){ + sr_info("Not found attached device."); } return dev; @@ -1611,8 +1629,6 @@ static struct libusb_device* get_new_detached_usb_device() struct libusb_device* dev; struct sr_dev_inst *dev_ins; - sr_info("To find new detached device."); - dev = NULL; num = 0; ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, &array, MAX_DEVCIE_LIST_LENGTH, &num); @@ -1643,8 +1659,8 @@ static struct libusb_device* get_new_detached_usb_device() pthread_mutex_unlock(&lib_ctx.mutext); - if (dev != NULL){ - sr_info("Found new detached usb device:%p", dev); + if (dev == NULL){ + sr_info("Not found detached device."); } return dev; diff --git a/libsigrok4DSL/session.c b/libsigrok4DSL/session.c index 1479c3d5..ceca9b49 100644 --- a/libsigrok4DSL/session.c +++ b/libsigrok4DSL/session.c @@ -100,7 +100,7 @@ SR_PRIV struct sr_session *sr_session_new(void) SR_PRIV int sr_session_destroy(void) { if (session == NULL) { - sr_detail("%s: session was NULL", __func__); + //sr_detail("%s: session was NULL", __func__); return SR_ERR_BUG; }