In the case of USB drivers, a driver's dev_acquisition_stop() cannot
simply remove its fd sources from the session and close its devices:
a USB transfer might still be underway, and it needs to be finished
(and its memory freed) properly.
An sr_dev_inst->status value is added: SR_ST_STOPPING, which should
be set when the driver's dev_acquisition_stop() is called, and acts
as a marker for the USB event handler to wind up its operations.
In order for dev_acquisition_stop() to be able to set the sdi status,
however, it needs to be unconstified.
- Default to 1MHz.
The default sample rate is the lowest frequency (100Hz),
but it takes a very long time until 128K memory is full.
- Fix the 1MHz setting.
- Use samplerate list.
- Fix 10MHz frequency.
- Fix trigger.
- Change the size of memory according to the number of samples.
- Add pre-trigger (capture ratio) setting.
- Fix the first acquisition after power on.
Move sr_usb_connect() and sr_usb_open() to hardware/common/usb.c in a
slightly more generic form and add more error checks and logging.
Let genericdmm use the new/moved functions.
Whenever we added a field to the enums in libsigrok.h, we were running
the risk of breaking ABI compatibility. Any reordering of existing values
or the addition of entries other than at the bottom of the list would
cause an ABI breakage.
By hardcoding the values we ensure that any added field will have an
unused value, and will not take a value previously used by a different
flag. By doing this, we avoid confusing frontends compiled with an
earlier API.
We use 10000 as the first entry of each enum, and each "category" gets
an explicit number (10000, 20000, 30000, and so on).
Also avoid making the first value of an enum zero. A value of zero is
used as terminator item in some lists.
Remove explicit "DUMMY" (terminator) enum entries, they're not needed.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Merge parts of the tekpower-dmm code (the chip of the TekPower
TP4000ZC seems to be an FS9721_LP3 too) and rework parts of the functions.
Adapt the tekpower-dmm and uni-t-dmm code accordingly.
So far, it seems we can make this work with just hw_init() needing to
be subdriver-specific (it will point 'di' to the respective per-subdriver
entry), the rest of the API functions can then use a strcmp() on di->name to
learn which subdriver they belong to.
The 'uni-t-dmm' driver/directory will not appear as a "driver" to
frontends anymore, it's just an internal thing.
The frontends will see a uni-t-ut61d and voltcraft-vc820 driver now,
with the correct names and parsers etc. attached to them.
This is not fully finished yet, but it's a start (and works mostly):
$ sigrok-cli -D
The following devices were found:
UNI-T UT61D with 1 probe: P1
Voltcraft VC-820 with 1 probe: P1
$ sigrok-cli --driver voltcraft-vc820 -D
The following devices were found:
Voltcraft VC-820 with 1 probe: P1
$ sigrok-cli --driver uni-t-ut61d -D
The following devices were found:
UNI-T UT61D with 1 probe: P1
# Now attaching a UNI-T UT61D device via USB.
$ sigrok-cli --driver uni-t-ut61d --samples 3 -O analog
P1: -0.017800 V DC
P1: -0.017600 V DC
P1: -0.017700 V DC
# Now attaching a Voltcraft VC-820 device via USB instead.
$ sigrok-cli --driver voltcraft-vc820 --samples 3 -O analog
P1: -0.319200 V DC
P1: -0.319300 V DC
P1: -0.319300 V DC