/* * This file is part of the DSView project. * DSView is based on PulseView. * * Copyright (C) 2022 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libsigrok-internal.h" #include "log.h" struct device_all_info { struct sr_device_info _base_info; }; #define SR_DEVICE_MAX_COUNT 100 static char DS_RES_PATH[500] = {0}; static struct sr_context *var_sr_context = NULL; static libsigrok_event_callback_t *var_event_callback = NULL; static struct device_all_info* var_device_array[SR_DEVICE_MAX_COUNT] = {0}; static int var_cur_device_count = 0; //----------------------------private function---------------- /** * Free device resource */ static sr_free_device(struct device_all_info *dev) { if (dev){ free(dev); } } /** * Must call first */ SR_API int sr_lib_init() { int ret = 0; struct sr_dev_driver **drivers = NULL; struct sr_dev_driver **dr = NULL; ret = sr_init(&var_sr_context); if (ret != SR_OK){ return ret; } // Initialise all libsigrok drivers drivers = sr_driver_list(); for (dr = drivers; *dr; dr++) { if (sr_driver_init(var_sr_context, *dr) != SR_OK) { sr_err("Failed to initialize driver '%s'", (*dr)->name); return SR_ERR; } } return SR_OK; } /** * Free all resource before program exits */ SR_API int sr_lib_exit() { struct sr_dev_driver **drivers = NULL; struct sr_dev_driver **dr = NULL; int i = 0; // free all device for (i=0; i