Commit Graph

3759 Commits

Author SHA1 Message Date
Hannu Vuolasaho b16d975a5c Support for regulation status and fix for mysterious M
Added support for SR_CONF_REGULATION which returns value for CH1
Also VELLEMAN LABPS3005D (only device currently supported) sends single
'M' character in beginning of return value, which is specially discarded.
2015-10-29 18:43:09 +01:00
Daniel Elstner 865de99391 Java: Avoid dangerous writes via casted pointers
Writing to an object through a pointer of incompatible type is
really evil. Even when the data size matches, it is still a
violation of strict aliasing rules.

Replace all instances by direct casts of the value, without the
unnecessary and dangerous indirection.
2015-10-26 07:29:50 +01:00
Daniel Elstner b0b0e2009c SWIG: Avoid unseparated template closing brackets
SWIG 2.0.12 fails with a syntax error on ">>".
2015-10-26 07:18:55 +01:00
Martin Ling 4aa9a1e569 C++: Catch exceptions from stoi() and stod().
Fixes bug #483.
2015-10-26 07:17:50 +01:00
Martin Ling 90bd8829b1 java: Add doxygen output directory to .gitignore. 2015-10-26 07:17:50 +01:00
Martin Ling f2831ab35b java: Usable wrapping of Configurable.config_keys(). 2015-10-26 07:17:01 +01:00
Martin Ling 36e3f6a9ce Makefile.am: Make SWIG wrappers also depend on new templates.i file. 2015-10-26 07:17:01 +01:00
Martin Ling df979d6dc6 python: Give all enum values __doc__ strings. 2015-10-26 07:17:01 +01:00
Martin Ling ef9643a2bb python: Add docstrings for enum constants. 2015-10-26 07:17:01 +01:00
Martin Ling 8fb7efe203 java: Add docstrings for enum constants. 2015-10-26 07:17:01 +01:00
Martin Ling 0bcdeb90c4 C++: Include enum classes when generating documentation. 2015-10-26 07:17:01 +01:00
Martin Ling ace872d529 C++: Declare namespace in enums.hpp so it can be used independently. 2015-10-26 07:17:01 +01:00
Martin Ling e5c22906e8 java: Make enum values available as normal constants. 2015-10-26 07:17:01 +01:00
Daniel Elstner 564d009e88 Java: Remove obsolete SourceCallback interface 2015-10-26 07:11:20 +01:00
Daniel Elstner 9e7176bd00 C++: Avoid const ref args to appease Java bindings
The Java bindings currently have some weird problem with function
arguments passed by const reference. Not all types are affected,
but the collection types that involve custom typemaps are.

For now, revert back to pass-by-value for the problematic types.
2015-10-26 07:04:10 +01:00
Daniel Elstner bf03d63565 C++: Use C++98 syntax for default arguments to appease SWIG
Looks like SWIG silently ignores default arguments specified via
aggregate initialization. This is rather unfortunate, especially
if the argument types are complex.
2015-10-26 06:45:56 +01:00
Daniel Elstner a98729a742 C++: Replace custom deleters with std::default_delete
Replace custom Deleter classes with std::default_delete<>, declared
as friend so it can invoke the private destructor. Inexplicably,
std::shared_ptr<> does not use default_delete<> by default, so it
is still necessary to explicitly specify the deleter when creating
shared_ptr instances.

With this, unique_ptr and shared_ptr instances now use the same
default delete mechanism.
2015-10-26 06:45:56 +01:00
Daniel Elstner f17b454655 C++: Use smart pointers instead of manual delete
Make use of std::unique_ptr<> to manage the lifetime of members
or container elements, so that manual invocations of delete can
be avoided. This also provides for exception safety.

Since std::unique_ptr<> is only movable but not copyable, adapt
the code to avoid copies and assignments of these pointers.
2015-10-26 06:45:56 +01:00
Daniel Elstner d5d7b09eb7 C++: Move C struct pointers out of ownership classes
Reduce needless over-generalization. There is no design need
for the ParentOwned and UserOwned classes to contain the C base
struct pointer. Instead, just make the _structure pointer a
private member of each class that needs one.
2015-10-26 06:45:56 +01:00
Daniel Elstner b6ab954d67 C++: Rename get_shared_pointer() to share_owned_by()
This makes it clearer that this method assigns the parent
(owner) reference.
2015-10-26 06:45:56 +01:00
Daniel Elstner 67b82fc9c9 C++: Use shared_from_this() exclusively on this
Never call shared_from_this() on any object other than "this".
Adapt the API so that it can be made protected.
2015-10-26 06:45:56 +01:00
Daniel Elstner 21d1bec60e C++: Make most members private instead of protected
Use protected only for members which are actually needed by
sub-classes. Declare all the rest private.
2015-10-26 06:45:56 +01:00
Daniel Elstner 4c9208a799 SWIG: Hack around SWIG segfault on private destructors
Apparently this problem has been fixed in SWIG 3.0.6. However,
until we can require that version, define "private" as "protected"
when running the SWIG parser.
2015-10-26 06:45:56 +01:00
Daniel Elstner 15bebf575d C++: Make value get accessors const
Declare accessor methods that return value members const. For now,
skip all cases where constness would have to be applied transitively
to shared objects.
2015-10-26 06:45:56 +01:00
Daniel Elstner a73d492636 C++: Make some methods static to match the C API
Context::package_version() and Context::lib_version() do not access
context state and should be static. However, leave the logging
related methods alone for now, as making them static would entail
making the callback data a global static, since the C API lacks
destroy notification callbacks.
2015-10-26 06:45:56 +01:00
Daniel Elstner 0ab8e5d22b C++: Declare all callbacks invoked from C noexcept
If one of these functions does throw an exception, std::terminate()
will be called. Without this, the behavior is undefined since the C
stack is not prepared to deal with exceptions.
2015-10-26 06:45:56 +01:00
Daniel Elstner 15914cdb0f C++: Use noexcept instead of throw()
Runtime-checked exception specifications via throw() are
deprecated in C++11.
2015-10-26 06:45:56 +01:00
Daniel Elstner c6e18e007a SWIG: Define "noexcept" empty to work around SWIG bug
The SWIG 2.0.12 on my system bails out with a syntax error on the
"noexcept" keyword in C++11 code. Define "noexcept" to nothing (for
the SWIG parser only) to work around this problem.
2015-10-26 06:45:56 +01:00
Daniel Elstner 6c11b49607 C++: Make most constructors explicit
Unless implicit conversion is desired, constructors that can be
called with one argument should be marked as "explicit".
2015-10-26 06:45:56 +01:00
Daniel Elstner ce3e1e6132 C++: Do not use C-style casts
Never ever.
2015-10-26 06:45:56 +01:00
Daniel Elstner 58e21229dd C++: Consistently use nullptr instead of NULL 2015-10-26 04:06:12 +01:00
Daniel Elstner d370545d60 C++: Use move() and avoid passing containers by value
Make use of std::move() to transfer arguments passed in by value.
Take complex container arguments by const reference, as passing
those by value is rather unorthodox even for C++11 style code.
2015-10-26 04:06:12 +01:00
Uwe Hermann 211cc97471 tests: Drop another obsolete sr_analog_float_to_string() test. 2015-10-25 23:05:49 +01:00
Martin Ling a00106b7f8 scpi: Move closing of discovered devices to sr_scpi_scan_resource(). 2015-10-25 22:40:35 +01:00
Martin Ling b7b873cea3 rigol-ds: After successfully finding a device, close it properly. 2015-10-24 22:50:37 +02:00
Martin Ling d0fa4ac1e7 java: Don't use SWIG attribute mechanism.
Using the attribute mechanism results in badly named wrappers like
getLog_level(), as well as incompletely applied typemaps for templated
container types. If we just avoid this mechanism entirely, we get the
same foo() and set_foo() accessors as we have in the C++ API.
2015-10-24 22:12:41 +02:00
Martin Ling d4db558810 java: Remove overrides for overloaded methods.
These are now wrapped correctly without needing this.
2015-10-24 22:12:41 +02:00
Martin Ling f3095e7e2e java: Remove need for conversion methods on container wrappers. 2015-10-24 22:12:41 +02:00
Martin Ling c7855def61 SWIG: Declare template specialisations for containers before typemaps.
It seems this is necessary to correctly apply typemaps involving
these template specialisations.
2015-10-24 22:12:41 +02:00
Aurelien Jacobs 7977054d61 scpi_usbtmc_libusb: remove libusb_clear_halt() hack which is not useful anymore 2015-10-24 22:11:38 +02:00
Uwe Hermann a73665a3fa transform/scale: Fix g_variant_new() argument. 2015-10-24 21:44:20 +02:00
Aurelien Jacobs 938bdc25b7 scpi_usbtmc_libusb: set_configuration only if it is not already set
This avoids the issues described here:
http://libusb.sourceforge.net/api-1.0/caveats.html#configsel
2015-10-24 21:32:13 +02:00
Aurelien Jacobs e40e9ca28d scpi_usbtmc_libusb: add Rigol DS2000 to the RL1 blacklist
The Rigol DS2000 series also give a USB timeout when trying to apply
RL1 lock or unlock.
2015-10-24 21:32:13 +02:00
Uwe Hermann 222fdfd526 Drop unneeded sr_analog_float_to_string().
A simple g_strdup_printf() is sufficient, no need for an extra
libsigrok API call here.
2015-10-24 21:21:50 +02:00
Tilman Sauerbeck a5c38703ee drivers: Fix behaviour when trying to set an invalid capture ratio.
Trying to configure an invalid capture ratio would reset the
previously configured value. Instead, we should just reject the
new value and keep the original one.
2015-10-24 21:10:29 +02:00
Uwe Hermann 087c4d59c0 fx2lafw: Drop obsolete macro usage. 2015-10-24 20:55:40 +02:00
Uwe Hermann 3e91de2bd6 fx2lafw: Add the official fx2lafw sigrok VID/PID pairs.
As supported by sigrok-firmware-fx2lafw >= 0.1.3:

 - 1D50:608C: fx2lafw-sigrok-fx2-8ch.fw

 - 1D50:608D: fx2lafw-sigrok-fx2-16ch.fw
2015-10-22 19:19:40 +02:00
Uwe Hermann 22fb1bffc3 analog.c: Various Doxygen additions and improvements. 2015-10-21 00:29:29 +02:00
Uwe Hermann 5cee3d08e4 analog.c: Return SR_ERR_ARG upon invalid arguments.
(instead of segfaulting)
2015-10-21 00:29:29 +02:00
Uwe Hermann 8ea0c90268 sr_analog_float_to_string(): Make 'digits' argument unsigned. 2015-10-21 00:29:29 +02:00