The store confirm times, and surport the old version hardware

This commit is contained in:
dreamsourcelabTAI 2023-06-20 15:29:34 +08:00
parent b0b91469b8
commit 7053af0a8f
6 changed files with 95 additions and 89 deletions

View File

@ -2007,6 +2007,8 @@ namespace pv
break;
case DSV_MSG_SAVE_COMPLETE:
_session->clear_store_confirm_flag();
if (_is_auto_switch_device)
{
_is_auto_switch_device = false;

View File

@ -199,6 +199,10 @@ public:
bool is_first_store_confirm();
bool get_capture_status(bool &triggered, int &progress);
inline void clear_store_confirm_flag(){
_confirm_store_time_id = _work_time_id;
}
std::vector<view::Signal*>& get_signals();
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus,

View File

@ -190,7 +190,7 @@ static GSList *scan(GSList *options)
struct libusb_device_descriptor des;
libusb_device **devlist;
libusb_device *device_handle = NULL;
int devcnt, ret, i, j;
int ret, i, j;
const char *conn;
enum libusb_speed usb_speed;
struct sr_usb_dev_inst *usb_dev_info;
@ -316,67 +316,63 @@ static GSList *scan(GSList *options)
address = libusb_get_device_address(device_handle);
sr_info("Found a new device,handle:%p", device_handle);
devc = DSCope_dev_new(prof);
if (!devc)
return NULL;
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, SR_ST_INITIALIZING,
prof->vendor, prof->model, prof->model_version);
if (!sdi) {
g_free(devc);
return NULL;
}
sdi->priv = devc;
sdi->driver = di;
sdi->dev_type = DEV_TYPE_USB;
sdi->handle = (ds_device_handle)device_handle;
/* Fill in probelist according to this device's profile. */
if (dsl_setup_probes(sdi, channel_modes[devc->ch_mode].num) != SR_OK){
sr_err("dsl_setup_probes() error");
dev_destroy(sdi);
return NULL;
}
devices = g_slist_append(devices, sdi);
num++;
if (dsl_check_conf_profile(device_handle)) {
/* Already has the firmware, so fix the new address. */
sr_info("Found a DSCope device,name:\"%s\",handle:%p", prof->model, device_handle);
devc = DSCope_dev_new(prof);
if (devc == NULL){
break;
}
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, SR_ST_INITIALIZING,
prof->vendor, prof->model, prof->model_version);
if (sdi == NULL) {
free(devc);
break;
}
sdi->priv = devc;
sdi->driver = di;
sdi->dev_type = DEV_TYPE_USB;
sdi->handle = (ds_device_handle)device_handle;
/* Fill in probelist according to this device's profile. */
if (dsl_setup_probes(sdi, channel_modes[devc->ch_mode].num) != SR_OK){
sr_err("dsl_setup_probes() error");
dev_destroy(sdi);
break;
}
usb_dev_info = sr_usb_dev_inst_new(bus, address);
usb_dev_info->usb_dev = device_handle;
sdi->conn = usb_dev_info;
sdi->status = SR_ST_INACTIVE;
sdi->status = SR_ST_INACTIVE;
devices = g_slist_append(devices, sdi);
num++;
}
else {
char *firmware;
char *res_path = DS_RES_PATH;
if (!(firmware = malloc(strlen(res_path)+strlen(prof->firmware) + 5))) {
sr_err("Firmware path malloc error!");
return NULL;
break;
}
strcpy(firmware, res_path);
strcat(firmware, "/");
strcat(firmware, prof->firmware);
sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware);
if (ezusb_upload_firmware(device_handle, USB_CONFIGURATION,
firmware) == SR_OK)
/* Store when this device's FW was updated. */
devc->fw_updated = g_get_monotonic_time();
else
sr_err("Firmware upload failed for "
"device %d.", devcnt);
if (ezusb_upload_firmware(device_handle, USB_CONFIGURATION, firmware) != SR_OK){
sr_err("Firmware upload failed for device %s", prof->model);
}
g_free(firmware);
usb_dev_info = sr_usb_dev_inst_new(bus, 0xff);
usb_dev_info->usb_dev = device_handle;
sdi->conn = usb_dev_info;
sr_info("Waitting for device reconnect, name:\"%s\"", prof->model);
}
}

View File

@ -1824,14 +1824,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
* Just wait for renumerate -> detach -> attach
*/
ret = SR_ERR;
if (devc->fw_updated > 0) {
sr_info("%s: Firmware upload have done.", __func__);
return SR_ERR;
}
else {
sr_info("%s: Firmware upload was not needed.", __func__);
ret = hw_dev_open(di, sdi);
}
ret = hw_dev_open(di, sdi);
if (ret != SR_OK) {
sr_err("%s: Unable to open device.", __func__);
@ -1963,7 +1956,15 @@ SR_PRIV int dsl_dev_close(struct sr_dev_inst *sdi)
{
struct sr_usb_dev_inst *usb;
assert(sdi);
usb = sdi->conn;
if (usb == NULL){
sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
if (usb->devhdl == NULL){
sr_detail("dsl_dev_close(),libusb_device_handle is null.");
return SR_ERR;

View File

@ -276,7 +276,7 @@ static GSList *scan(GSList *options)
struct libusb_device_descriptor des;
libusb_device **devlist;
libusb_device *device_handle = NULL;
int devcnt, ret, i, j;
int ret, i, j;
const char *conn;
enum libusb_speed usb_speed;
struct sr_usb_dev_inst *usb_dev_info;
@ -403,46 +403,49 @@ 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", device_handle);
devc = DSLogic_dev_new(prof);
if (!devc)
return NULL;
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, SR_ST_INITIALIZING,
prof->vendor, prof->model, prof->model_version);
if (!sdi) {
g_free(devc);
return NULL;
}
sdi->priv = devc;
sdi->driver = di;
sdi->dev_type = DEV_TYPE_USB;
sdi->handle = (ds_device_handle)device_handle;
/* Fill in probelist according to this device's profile. */
if (dsl_setup_probes(sdi, channel_modes[devc->ch_mode].num) != SR_OK){
sr_err("dsl_setup_probes() error");
dev_destroy(sdi);
return NULL;
}
devices = g_slist_append(devices, sdi);
num++;
if (dsl_check_conf_profile(device_handle)) {
/* Already has the firmware, so fix the new address. */
sr_info("Found a DSLogic device,name:\"%s\",handle:%p", prof->model,device_handle);
devc = DSLogic_dev_new(prof);
if (devc == NULL){
break;
}
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, SR_ST_INITIALIZING,
prof->vendor, prof->model, prof->model_version);
if (sdi == NULL) {
free(devc);
break;
}
sdi->priv = devc;
sdi->driver = di;
sdi->dev_type = DEV_TYPE_USB;
sdi->handle = (ds_device_handle)device_handle;
/* Fill in probelist according to this device's profile. */
if (dsl_setup_probes(sdi, channel_modes[devc->ch_mode].num) != SR_OK){
sr_err("dsl_setup_probes() error");
dev_destroy(sdi);
break;
}
usb_dev_info = sr_usb_dev_inst_new(bus, address);
usb_dev_info->usb_dev = device_handle;
sdi->conn = usb_dev_info;
sdi->status = SR_ST_INACTIVE;
sdi->status = SR_ST_INACTIVE;
devices = g_slist_append(devices, sdi);
num++;
}
else {
char *firmware;
char *res_path = DS_RES_PATH;
if (!(firmware = malloc(strlen(res_path)+strlen(prof->firmware) + 5))) {
sr_err("Firmware path malloc error!");
return NULL;
break;
}
strcpy(firmware, res_path);
strcat(firmware, "/");
@ -450,18 +453,13 @@ static GSList *scan(GSList *options)
sr_info("Install firmware bin file, device:\"%s\", file:\"%s\"", prof->model, firmware);
if (ezusb_upload_firmware(device_handle, USB_CONFIGURATION,
firmware) == SR_OK)
/* Store when this device's FW was updated. */
devc->fw_updated = g_get_monotonic_time();
else
sr_err("Firmware upload failed for "
"device %d.", devcnt);
g_free(firmware);
usb_dev_info = sr_usb_dev_inst_new(bus, 0xff);
usb_dev_info->usb_dev = device_handle;
sdi->conn = usb_dev_info;
if (ezusb_upload_firmware(device_handle, USB_CONFIGURATION, firmware) != SR_OK){
sr_err("Firmware upload failed for device %s.", prof->model);
}
free(firmware);
sr_info("Waitting for device reconnect, name:\"%s\"", prof->model);
}
}

View File

@ -1362,6 +1362,7 @@ static void process_detach_event()
struct sr_dev_driver *driver_ins;
libusb_device *ev_dev;
int ev;
int bFind;
sr_info("Process device detach event.");
@ -1375,6 +1376,7 @@ static void process_detach_event()
}
lib_ctx.detach_device_handle = NULL;
bFind = 0;
pthread_mutex_lock(&lib_ctx.mutext);
for (l = lib_ctx.device_list; l; l = l->next)
@ -1397,13 +1399,16 @@ static void process_detach_event()
destroy_device_instance(dev);
}
bFind = 1;
break;
}
}
pthread_mutex_unlock(&lib_ctx.mutext);
// Tell user a new device detached, and the list is updated.
post_event_async(ev);
if (bFind){
post_event_async(ev);
}
}
static void usb_hotplug_process_proc()