Commit Graph

178 Commits

Author SHA1 Message Date
Peter Stuge 1ebe4b4e69 hw_init(): Save struct sr_context * parameter in struct drv_context 2012-12-03 12:07:40 +01:00
Peter Stuge 34f06b903e Add a struct sr_context * parameter to hw_init() 2012-12-03 12:07:40 +01:00
Uwe Hermann a54dd31e38 serial: Use OS-independent flags for serial port opening.
Add SERIAL_RDWR, SERIAL_RDONLY, and SERIAL_NONBLOCK (for now), which are
mapped to the respective OS-specific mechanism in serial_open().
2012-12-02 12:45:54 +01:00
Bert Vermeulen 90165efe55 ols: if no serial port specified, this driver is not used. 2012-11-16 15:26:47 +01:00
Bert Vermeulen 530f201eb8 ols: use new serial API 2012-11-12 02:24:47 +01:00
Bert Vermeulen fe1c50fba6 ols: fix device discovery 2012-11-11 03:12:10 +01:00
Alexandru Gagniuc a99e0d2a0c ols: Do not randomly probe serial ports
ols driver used to probe a series of available serial ports obtained
by regexp matching of common serial port names.
There are a number of problems with this approach:
1. It will probe all serial devices, including devices that do not
like to be probed, potentially causing them to act up.
2. It will try to probe serial ports which may already be opened in
other applications for other purposes.
3. It assumes the naming of the serial ports is set in stone, and
creates an unnecessary OS-specific list.
4. It produces unnecessary debug output even when an OLS device is
not connected.
5. etc...

Do not implicitly probe serial ports. Only probe the port specified
by the frontend, if any; otherwise, just quit.
Also get rid of all functionality in serial.c which was designed
specifically for random probing.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2012-11-11 03:12:10 +01:00
Bert Vermeulen 69b07d14db allow for intermediate stage in stopping acquisition
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.
2012-11-06 15:16:22 +01:00
Uwe Hermann 886a52b6fb Return SR_ERR_MALLOC upon allocation errors.
Add some TODOs.
2012-10-30 20:25:54 +01:00
Bert Vermeulen e9022f596d sr: make struct drv_context global 2012-09-11 21:27:26 +02:00
Bert Vermeulen 811deee4af sr/drivers: add API calls sr_dev_inst_list() and sr_dev_inst_clear()
These are used to list the device instances currently known to the driver,
and clear that list.

Drivers that don't necessarily clear their list of instances on every scan,
such as genericdmm, need to provide these to the frontend to keep instance
management sane.
2012-08-06 00:59:25 +02:00
Bert Vermeulen 014359e329 sr/drivers: obsolete SR_HWCAP_PROBECONFIG
Since probes now live in a struct sr_dev_inst owned by the driver, it
already knows about them. Instead of a frontend telling the driver to
configure probes, all driver now do this just before starting acquisition.
2012-08-05 18:56:12 +02:00
Bert Vermeulen 26bf9d56c0 ols: remove serial source from session when done 2012-08-03 11:29:01 +02:00
Bert Vermeulen fefc4b858e ols: use driver-private storage for instances 2012-08-03 11:29:00 +02:00
Bert Vermeulen 6f57fd9694 sr: remove obsolete SR_DI_INST 2012-08-03 11:29:00 +02:00
Bert Vermeulen b35c829306 sr/drivers: fix off-by-one if frontend-initiated probe configuration 2012-08-03 11:29:00 +02:00
Bert Vermeulen 9e90dcba9c sr/drivers: remove driver API call dev_status_get()
It's obsolete: no frontend ever used it, and neither did libsigrok.
The sdi->status field is only used internally by some drivers, and
should probably be moved to the driver-specific context structs.
2012-08-03 11:27:31 +02:00
Bert Vermeulen 5d9ed643e9 ols: change driver dev_acquisition_start/_stop calls to use sdi
...yeah, forgot OLS.
2012-08-03 11:27:31 +02:00
Bert Vermeulen 25a0f108f4 sr/drivers: change driver dev_open/dev_close calls to use sdi 2012-08-03 11:27:31 +02:00
Bert Vermeulen 6f4b1868e8 sr/drivers: use sr_dev_inst instead of device index for dev_config_set()
All driver API calls using device index as a parameter will instead use a
const struct sr_dev_inst.
2012-08-03 10:27:39 +02:00
Bert Vermeulen 2ca4465b3d ols: don't use deprecated hwcap_get_all() driver API call 2012-08-03 10:27:39 +02:00
Bert Vermeulen 2efc5948b6 ols: scan fix 2012-08-03 10:27:39 +02:00
Bert Vermeulen dddfb3dbf0 ols: use new driver info_get() API call 2012-08-03 10:27:38 +02:00
Bert Vermeulen 10e5cbede8 ols: use new scan API 2012-08-03 10:27:38 +02:00
Bert Vermeulen e5e81856b4 ols: use driver struct-based device instance list 2012-08-03 10:27:38 +02:00
Bert Vermeulen 61136ea603 sr: add new driver API call: scan()
This changes the semantics of the init() call as well. That now only
initializes the driver -- an administrative affair, no hardware gets
touched during this call. It returns a standard SR_OK or SR_ERR* code.

The scan() call does a discovery run for devices it knows, and returns
the number found. It can be called at any time.
2012-08-03 10:27:36 +02:00
Bert Vermeulen 40dda2c3a5 sr: remove unused argument from hardware driver function init()
It was actually used in one way: the session file loaded abused it for
passing in the filename -- something it definitely wasn't intended for.
This now uses the proper way to pass arguments to a driver: the new
SR_HWCAP_SESSIONFILE.

The OLS driver could also use it as an indication of the serial port to
use instead of actively probing all serial ports on the system, but there
wasn't any frontend code that passed in such a parameter, making it
entirely useless. That will soon be handled differently with the new
scan() API call, regardless.
2012-08-03 10:27:36 +02:00
Bert Vermeulen 45c59c8bdd sr: moved sigrok.h so libsigrok/libsigrok.h
All frontends will have to include <libsigrok/libsigrok.h> from now on.
This header includes proto.h and version.h, both installed from the
distribution into $INCLUDE/libsigrok/ as well.

The only dynamically changed header is now version.h, which has both
libsigrok and libtool compile-time versions in it.
2012-07-05 01:17:28 +02:00
Bert Vermeulen f8c1fcda46 sr: use proper definitions for parity setting
ols driver fixed to use these as well.
2012-07-01 22:31:31 +02:00
Uwe Hermann 9edfee3ee3 sr: ols: Fix incorrect comment. 2012-06-21 23:59:27 +02:00
Joel Holdsworth a533743dd1 sr: Made sample rate lists const 2012-05-31 19:51:11 +01:00
Joel Holdsworth 1b79df2f57 sr: Made the dev_config_set parameter a const pointer 2012-05-31 19:51:11 +01:00
Joel Holdsworth b7f578bef5 sr: Made the dev_info_get return value const 2012-05-31 19:51:10 +01:00
Joel Holdsworth 915f7cc87a sr: Made hwcap const 2012-05-31 19:51:09 +01:00
Bert Vermeulen f366e86c68 sr: change all drivers to use SR_DF_META_LOGIC 2012-05-30 23:55:36 +02:00
Matt Ranostay 13d0d2698c ols: fixed *ctx null dereferences that would SEGFAULT on probing for a OLS or attempting to read from it.
Signed-off-by: Matt Ranostay <mranostay@gmail.com>
2012-03-08 22:27:33 -08:00
Uwe Hermann 0abee5076f sr: Fix some TODOs, improve comments/docs. 2012-03-04 15:10:12 +01:00
Uwe Hermann 3cd3a20b35 sr: More callback param renames.
Start/stop acquisition callbacks: Consistently name the 'void *' parameter
cb_data for now. The per-device-instance device pointer is called
'session_dev_id' everywhere for now, but this should be renamed to
something more clear.
2012-03-04 15:10:09 +01:00
Uwe Hermann 1f9813eb6c sr: Name all callback data 'cb_data'. 2012-03-02 02:25:42 +01:00
Uwe Hermann 31ccebc492 sr: s/sr_session_bus/sr_session_send/. 2012-03-01 23:49:25 +01:00
Uwe Hermann c09f0b578c sr/cli/gtk/qt/: s/plugin/driver/. 2012-02-28 23:52:30 +01:00
Uwe Hermann d261dbbfcc sr: Fix/document probe names. 2012-02-28 01:09:29 +01:00
Uwe Hermann ea9cfed7a5 sr: Consistent ctx name for per-dev-inst context. 2012-02-18 18:07:42 +01:00
Uwe Hermann ee61b340da sr: Remove unneeded temp. variable use. 2012-02-18 12:16:49 +01:00
Uwe Hermann a9a245b428 sr: s/config_set/dev_config_set/.
This functions is per-device-instance, so use dev_ as prefix as with
the other ones.
2012-02-18 12:11:15 +01:00
Uwe Hermann 69040b7c8f sr: s/acquisition_*/dev_acquisition_*/.
These functions are per-device-instance, so use dev_ as prefix as with
the other ones.
2012-02-18 12:03:49 +01:00
Uwe Hermann e7eb703fff sr: opendev/closedev -> dev_open/dev_close. 2012-02-18 11:57:43 +01:00
Uwe Hermann 8105505d06 sr: s/st*_acquisition/acquisition_st*/. 2012-02-18 11:46:51 +01:00
Uwe Hermann 5097b0d091 sr/cli/gtk/qt: s/get_dev_info/dev_info_get/. 2012-02-18 11:41:21 +01:00
Uwe Hermann a7d05fcb38 sr/cli/gtk/qt: s/configuration/config/. 2012-02-18 00:31:35 +01:00
Uwe Hermann ffedd0bf5d sr/cli/gtk: s/capability/hwcap/. 2012-02-18 00:17:18 +01:00
Uwe Hermann 1d9a8a5fe1 sr/cli/gtk: A few more s/instance/inst/. 2012-02-17 23:55:27 +01:00
Uwe Hermann bb7ef79377 sr/cli/gtk/qt: s/device/dev/ in many places.
Also, a few s/instance/inst/ occurences.
2012-02-17 23:47:00 +01:00
Uwe Hermann d68e2d1a21 sr: Some more s/device_instance/dev_inst/. 2012-02-17 22:40:51 +01:00
Bert Vermeulen da1466d677 sr: rename more functions to sr_thing_action format
Also improved the interface to find capabilities in a hardware plugin.
2012-02-14 00:23:51 +01:00
Bert Vermeulen d3683c42e7 sr: rename all sr_device_instance_* functions to sr_dev_inst_* 2012-02-13 22:45:49 +01:00
Uwe Hermann 57ab7d9f92 sr: cleanup callback: Return int. 2012-02-13 19:49:01 +01:00
Uwe Hermann 3010f21c91 sr: stop_acquisition callback: Return int. 2012-02-13 19:49:00 +01:00
Bert Vermeulen c73d2ea421 sr: adjust copyright year 2012-02-13 14:31:51 +01:00
Uwe Hermann 133a37bfba Use g_try_malloc/g_free/g_strdup consistently.
Avoid plain malloc()/free() in sr/srd, especially in the API calls.
Also avoid g_malloc*() in favor of g_try_malloc*().

Use g_strdup() instead of strdup() so that we can use g_free()
consistently everywhere.

Exceptions: Stuff that is allocated via other libs (not using glib),
should also be properly free'd using the respective free-ing function
(instead of g_free()). Examples: Stuff allocated by libusb, libftdi, etc.

Also, use sr_err() instead of sr_warn() for actual errors. sr_warn() is
meant for non-fatal/uncritical warnings.
2012-02-11 22:34:16 +01:00
Uwe Hermann 0f8522bf74 Project-wide consistent naming for #include guards.
Document the naming scheme in HACKING.
2012-02-05 15:05:13 +01:00
Uwe Hermann 5c64390e5a sr/cli/gtk: Remove analog left-overs from API.
This will come back in some form or another later, but for now
don't clutter the API with non-working stuff. Removing stuff from APIs
is not possible without breaking the API, adding stuff later is simpler.
2012-02-05 15:05:12 +01:00
Uwe Hermann ca070ed9a0 sr: Make more symbols private via static/SR_PRIV.
Additional zeroplus fixes:

 - Remove unneeded function prototypes from .h files.

 - Remove unused variables and/or use standard libusb #defines instead.

 - Remove unused GL_* error code #defines.
2012-02-02 21:46:10 +01:00
Bert Vermeulen 0146970797 sr: remove unused time/duration fields from datafeed packets 2012-02-01 02:59:41 +01:00
Uwe Hermann 69890f7399 sr: Eliminate usb/serial instances from API.
The API should be generic and only provide sr_device_instance_new() and
friends, but not sr_usb_device_instance_new(), sr_serial_device_instance_new(),
or others for other device types we may have in the future. The
frontends shouldn't have to know or care about this implementation detail.

This also fixes the problem that parts of sigrok.h contained
'#ifdef HAVE_LIBUSB_1_0' and such, which is even less desirable for the API.

The usb/serial instance specifics are now private, and each driver that
needs them keeps a pointer in its driver-specific context.
2012-01-31 02:04:35 +01:00
Uwe Hermann db8ae7b941 sr/srd: Remove/fix non-applicable autotools stuff. 2011-12-30 11:14:24 +01:00
Uwe Hermann c37d2b1ba1 probe names: Fix cosmetics, add docs, fix off-by-one. 2011-12-29 19:50:14 +01:00
Kristoffer Sjöberg 464d12c72a Move the probe naming to the creator of the device, and let each driver name its own probes. 2011-12-29 17:04:31 +01:00
Uwe Hermann b7f09cf86d libsigrok: Fix #includes.
In the lib, we should only #include "sigrok.h" or "sigrok-internal.h",
but not the (possibly installed and thus different/older versions) via
<sigrok.h> or <sigrok-internal.h>.

Frontends should of course use <sigrok.h> and <sigrok-internal.h>.
2011-12-28 23:07:08 +01:00
Uwe Hermann cb93f8a927 Other method to avoid "unused var" compiler warnings.
The '(void)varname' method is nicer than 'varname = varname' and also
prevents warnings when compiling sigrok with clang instead of gcc.
2011-11-24 22:57:48 +01:00
Gareth McMullin 4d436e71ba Changed SR_T_NULL to SR_T_BOOL and adjusted RLE option. 2011-11-19 13:41:41 +13:00
Gareth McMullin 7583b99dbb OLS: Calculate actual sample rate used. 2011-10-31 11:19:10 +01:00
Uwe Hermann baf1d71477 ols: Minor whitespace and coding style fixes. 2011-10-30 02:10:32 +02:00
Gareth McMullin 3a4d09c0de Run-Length Encoding support for the OLS. 2011-10-30 01:56:54 +02:00
Gareth McMullin 221304219e Prevent reading past end of OLS hardware buffer. 2011-10-30 01:56:40 +02:00
Bert Vermeulen 9c939c5132 use new datafeed packet format 2011-06-19 14:28:50 +02:00
Bert Vermeulen 8722c31e26 better cleanup of device/plugin resources 2011-06-05 01:51:49 +02:00
Uwe Hermann 697785d1ae libsigrok: closedev() now has a return code.
This is useful to allow frontends to react upon close failures in a
way they see fit (e.g. a popup in the GUI, or error message in the CLI).
They can also still ignore the error if they want, of course.
2011-05-05 13:06:14 +02:00
Uwe Hermann 86f5e3d826 libsigrok: Rename open/close to opendev/closedev. 2011-05-05 13:06:11 +02:00
Uwe Hermann 4af22da595 Fix two small warnings. 2011-04-19 00:27:29 +02:00
Uwe Hermann e519ba8645 Hardware drivers: Use names for struct entries. 2011-04-19 00:18:06 +02:00
Uwe Hermann c0a4b9716d ols: Always use glib's memory allocation functions. 2011-04-19 00:18:05 +02:00
Uwe Hermann b53738baf7 Replace g_malloc{0,} with g_try_malloc{0,}.
The g_malloc()/g_malloc0() versions exit/segfault if not enough memory
is available, which is not a good thing in libsigrok.

Instead, we use the g_try_malloc()/g_try_malloc0() variants, which
return NULL if not enough memory is available, so that the caller can
handle the error properly.
2011-04-16 18:08:15 +02:00
Uwe Hermann b08024a836 libsigrok: Introduce sr_dbg/sr_info/sr_warn/sr_err.
We should use these (internal) functions in libsigrok exclusively from
now on, i.e. no more use of glib's g_debug() etc.

These functions are only for libsigrok, the frontends use whatever
logging mechanism is suitable there.
2011-04-14 10:11:08 +02:00
Bert Vermeulen 4fe9a6da79 OLS driver overhaul
support for metadata in recent versions of the FPGA code
moved constants and structs out to separate header file
got rid of all device instance-specific globals
2011-04-03 06:18:05 +02:00
Uwe Hermann c91404191e Add SR_HZ macro for consistency. 2011-03-03 20:24:24 +01:00
Uwe Hermann 59df0c77e2 Add SR_ prefix to the KHZ/MHZ/GHZ macros. 2011-03-03 20:24:24 +01:00
Uwe Hermann 54ac5277c5 Constify some more 'char *' parameters. 2011-02-20 21:16:26 +01:00
Uwe Hermann 6f1be0a2d4 Add sr_ prefix to session_{add,remove}. 2011-02-20 21:16:22 +01:00
Uwe Hermann 60679b18e6 Add sr_ prefix to 'struct samplerates'. 2011-02-08 22:28:01 +01:00
Uwe Hermann 8a2efef2d5 Add sr_ prefix to session related API functions. 2011-02-08 22:28:00 +01:00
Uwe Hermann 1afe89897c Add sr_ prefix for 'struct probe'. 2011-02-08 22:27:58 +01:00
Bert Vermeulen 904e0b589e ols: default to 200KHz samplerate 2011-02-04 06:29:41 +01:00
Uwe Hermann a9f54bcd7b MinGW: Build fixes. 2011-02-02 13:13:26 +01:00
Uwe Hermann 5a2326a71b SR_ prefix for all public enums. 2011-01-30 18:32:59 +01:00
Uwe Hermann 6c29007211 Prefixes for *_device_instance. 2011-01-30 18:32:59 +01:00
Uwe Hermann 5c2d46d1db Prefix device structs with sr_. 2011-01-30 18:32:58 +01:00
Uwe Hermann 9f8274a544 Add a field for the full name of a device.
Also, show this long/full name in 'sigrok-cli -V'.
2011-01-30 18:32:58 +01:00
Uwe Hermann b9c735a275 Prefix datafeed structs with sr_. 2011-01-30 18:32:57 +01:00
Uwe Hermann d32d961d17 get_sr_device_instance() -> sr_get_device_instance(). 2011-01-30 18:32:56 +01:00