On Tue, Jun 2, 2020 at 3:29 AM Frank Stettner <frank-stett...@gmx.net> wrote: > You might want to add support for SmuView? Then you want to add a mutex > (GMutex) to make the serial read/write thread safe. > Background is that data acquisition and getting/setting of config keys are > running in separate threads in SmuView. > Have a look at the arachnid-labs-re-load-pro driver (acquisition_mutex) or > the korad-kaxxxxp driver (rw_mutex) for examples.
SmuView looks interesting! Got it compiled, and was about to implement mutex stuff on the driver when noticed something odd.. Mutex implementation in arachnid labs driver doesn't seem "right" (?) Driver is making g_mutex_lock()/g_mutex_unlock() calls before the mutex is initialized using g_mutex_init() in dev_acquisition_start() function. Similarly g_mutex_clear() is called from dev_acquisition_stop(), so after acquisition has stopped there can be calls to g_mutex_lock()/g_mutex_unlock() when get_config/set_config/get_list gets called... Is it indeed safe to make g_mutex_lock/unlock calls when there is no "valid" mutex? Also, call to g_mutex_clear() could happen when there is lock on the mutex (SmuView could be querying/setting config items...)? This would seem also potentially problematic since docs say "Calling g_mutex_clear() on a locked mutex leads to undefined behavior." ? Shouldn't the mutex be initialize when driver is loaded (in scan() function), and then freed when driver is freed/closed? > For bonus points you want to add the SR_CONF_LIST capability to the > SR_CONF_REGULATION config key and return something like {"CV", "CC", "UR", > ...}. > This is useful for sigrok-cli and very useful for SmuView. See also the > arachnid-labs-re-load-pro driver for an example. Thanks, this is now implemented. Wiki page has "list: NA, TODO?" for SR_CONF_REGULATION so I had skipped it. > But wait, there are extra bonus points :) > When the status of the device changes (e.g. entering over current protection, > changing the output state, etc.) you can send a meta package, so that SmuView > can show this change or sigrok-cli print a message to the terminal. This is now implemented as well. I'm sending meta frames for these: SR_CONF_ENABLED, SR_CONF_REGULATION, SF_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE, SF_CONF_OVER_CURRENT_PROTECTION_ACTIVE, and SF_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE (Changes are in https://github.com/tjko/libsigrok.git) -- Timo <t...@iki.fi> _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel