summaryrefslogtreecommitdiff
path: root/tools/iio
AgeCommit message (Collapse)Author
2016-04-19iio: tools: generic_buffer: auto-enable channelsLinus Walleij
If no channels are enabled when we run generic_buffer on a device, add a command-line option to just enable all of them, run the sampling and disable them all again afterwards. This is extremely useful when I'm low-level testing my sensors with interrupts and triggers, sample session: root@Ux500:/ lsiio Device 000: lsm303dlh_accel Device 001: lis331dl_accel Device 002: l3g4200d Device 003: lsm303dlh_magn Device 004: lps001wp Trigger 000: lsm303dlh_accel-trigger Trigger 001: lis331dl_accel-trigger Trigger 002: l3g4200d-trigger root@Ux500:/ generic_buffer -a -c 10 -n l3g4200d iio device number being used is 2 iio trigger number being used is 2 No channels are enabled, enabling all channels Enabling: in_anglvel_x_en Enabling: in_anglvel_y_en Enabling: in_anglvel_z_en Enabling: in_timestamp_en /sys/bus/iio/devices/iio:device2 l3g4200d-trigger -3.593664 -0.713133 4.870143 946684863662292480 3.225546 0.867357 -4.945878 946684863671875000 -0.676413 0.127296 0.106641 946684863681488037 -0.661113 0.110160 0.128826 946684863690673828 -0.664173 0.113067 0.123471 946684863700683593 -0.664938 0.109395 0.124848 946684863710144042 -0.664173 0.110619 0.130203 946684863719512939 -0.666162 0.111231 0.132651 946684863729125976 -0.668610 0.111690 0.130662 946684863738739013 -0.660501 0.110466 0.131733 946684863748565673 Disabling: in_anglvel_x_en Disabling: in_anglvel_y_en Disabling: in_anglvel_z_en Disabling: in_timestamp_en Pure awesomeness. If some channels have been enabled through scripts or manual interaction, nothing happens. Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-03iio: Add channel for UV indexPeter Meerwald-Stadler
UV index indicating strength of sunburn-producing ultraviolet (UV) radiation Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-03iio: Add modifier for UV lightPeter Meerwald-Stadler
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-03iio: tools: make generic_buffer look for "-trigger"Linus Walleij
All the ST Sensors use the old "<foo>-trigger" rather than the standard "<foo>-devN" new standard suffix for triggers. Now much to do about it since it is ABI, but make the testing tools recognize it too. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-03-20tools: iio: Update iio_event_monitor namesPeter Meerwald-Stadler
add recently added channel types and modifiers Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-16iio: generic_buffer: be helpful about enabling channelsLinus Walleij
Currently if generic_buffer is invoked without first enabling any channels in scan_elements/*_en, it will fail unable to enable the buffer because bytes_per_datum inside the kernel will be zero if no channels are available. It is implied that the user of the program should enable channels manually or with a script before executing generic_buffer. Be more helpful by stopping execution if no enabled channels can be found, and print a helptext that will tell you what is wrong and what needs to be done. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-16iio: event_monitor: report unsupported eventsLinus Walleij
This makes the event monitor bail out with a helpful error message if a device does not support events, as a related fix to iio core now makes it return -ENODEV properly. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-12iio: lsiio: fix error code handling errorLinus Walleij
commit acf50b3586f8d8a7530b905e111dda41876d38f4 "tools:iio:lsiio: add error handling" introduced error handling of errors returned from read_sysfs_string(), but with a simple if (retval), missing the fact that these functions return a positive value if the read was successful. As a result lsiio regresses and does not show any devices on my filesystem. Fix this by checking for only negative error codes. Cc: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-08tools: iio: remove unnecessary double pointerJoo Aun Saw
Remove unnecessary double pointer from channel sorting function. Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-08tools: iio: Set caller's ci_array pointer to NULL after freeJoo Aun Saw
On error, caller's ci_array is freed and set to NULL to avoid potential double free if some other user of this code is not sufficiently careful. Counter is reset to zero for consistency. Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02tools: iio: iio_utils: Make calc_digits staticJoo Aun Saw
Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02tools: iio: iio_utils: remove unnecessary define guardJoo Aun Saw
Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02tools: iio: print error message when buffer enable failsIrina Tirdea
Running generic_buffer without enabling any channel of the sensor will fail without printing any error message. Add an error message that indicates buffer enable failed. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-02tools: iio: fix mask for 32 bit sensor dataIrina Tirdea
When the the sensor data uses 32 bits out of 32, generic_buffer prints the value 0 for all data read. In this case, the mask is shifted 32 bits, which is beyond the size of an integer. This will lead to the mask always being 0. Before printing, the mask is applied to the raw value, thus generating a final value of 0. Fix the mask by shifting a 64 bit value instead of an integer. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-23tools: iio: make scale and offset files optionalJoo Aun Saw
Make scale and offset optional by adding -ENOENT check as not all drivers implement them. Signed-off-by: Joo Aun Saw <jasaw@dius.com.au> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20tools: iio: Send error messages to stderrCristina Opriceana
This patch indends to make some cleanup and send printf error messages to stderr. The changes were performed with coccinelle for failure messages and manual for other cases, such as wrong usage messages. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20tools: iio: Add ARRAY_SIZE macroCristina Opriceana
Calculation of the length of an array can be done with the ARRAY_SIZE macro to make code more abstract and remove the associated checkpatch.pl warning. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20tools: iio: Remove unnecessary bracesCristina Opriceana
Single statement blocks don’t need braces. Found with checkpatch.pl. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Acked-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-20tools: iio: Remove explicit NULL comparisonCristina Opriceana
Remove explicit NULL comparison and write it in its simpler form as recommended by checkpatch.pl. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-05tools: iio: Add single-byte case for generic_bufferTiberiu Breana
Some sensors export data in an 8-bit format. Add a single-byte case for the generic_buffer tool so that these sensors' buffer data can be visualized. Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-21tools:iio:iio_event_monitor: check if event is fully readHartmut Knaack
Check that the read event is of the expected size. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-21tools: iio: Add missing names to iio_event_monitorPeter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-13tools:iio: rename variablesHartmut Knaack
Use more appropriate/common variable names: * namepf instead of nameFile in iio_utils.c * ret instead of retval in lsiio.c Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-13tools:iio: adjust coding styleHartmut Knaack
Fix various coding style issues, including: * have spaces around operators * indentation * consolidate parameters in same line * required braces * adjust/drop comments * multiline comment style * delete unnecessary empty lines * add empty lines to visualize logial code blocks * typos Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_utils: pass strings as constHartmut Knaack
Mark strings, which are not supposed to be changed (basedir, filename, value), as const in function parameters. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio: rework program parametersHartmut Knaack
In generic_buffer.c: sort program parameters alphabetically and provide usage information In lsiio.c: drop unused parameters Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_utils: initialize count during declarationHartmut Knaack
In build_channel_array(), count can be initialized already during variable declaration. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_utils: move up reset of sysfsfpHartmut Knaack
In iioutils_get_type() it is logically better fitting to have sysfsfp assigned zero right after closing it. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_utils: refactor assignment of is_signedHartmut Knaack
Change the assignment of *is_signed in iioutils_get_type() to a one-liner, as already done with *be. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_event_monitor: refactor events outputHartmut Knaack
Refactor the code in print_event() to reduce code duplication and better reflect that the type is output unconditionally, as well as cascade the dependency of the diff-channel. Saves a few lines of code, as well. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio: return values directlyHartmut Knaack
Return directly, if no common cleanup is required. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-01tools:iio:iio_utils: add missing documentationHartmut Knaack
Fully document public functions and elements. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:lsiio: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. This also involves to change the type of dump_devices() from void to int. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. This also sets ret to -ENOENT in iioutils_get_type() and iioutils_get_param_float() to indicate if no matching directory entry was found. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_event_monitor: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: add error handlingHartmut Knaack
Add error handling to calls which can indicate a major problem by returning an error code. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: catch errors for arguments conversionHartmut Knaack
Add handler to catch errors on conversion of numerical arguments. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: catch errors in string allocationHartmut Knaack
This patch catches errors in string allocation in generic_buffer.c, iio_event_monitor.c, iio_utils.c and lsiio.c. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: mark private function staticHartmut Knaack
Functions _write_sysfs_int() and _write_sysfs_string() are supposed to be called only by public wrappers, so make them static. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: implement digit calculationHartmut Knaack
Previously, the return value of sscanf() was treated as an indication of the digits it would have read. Yet, sscanf() only returns the amount of valid matches. Therefore, introduce a function to calculate the decimal digits of the read number and use this one to commence a colon search, as originally intended. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: check amount of matchesHartmut Knaack
fscanf() usually returns the number of input items successfully matched and assigned, which can be fewer than provided (or even zero). Add a check in iioutils_get_type() to make sure all items are matched. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: sign-extend and shift dataHartmut Knaack
Refactor process_scan() to handle signed and unsigned data, respect shifts and the data mask for 2, 4 and 8 byte sized scan elements. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: pass up right error codeHartmut Knaack
find_type_by_name() returns a valid error code in case of an error. Pass this code up instead of an artificial one. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:generic_buffer: fix check of errnoHartmut Knaack
Since errno contains the value of any of the defined error names, a negation will not lead to the desired match. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_event_monitor: save right errnoHartmut Knaack
Move up error handling code to preserve the errno coming from ioctl(), before it may be changed by close(). Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: save errno firstHartmut Knaack
The man-page of errno states, that errno should be saved before doing any library call, as that call may have changed the value of errno. So, when encountering any error, save errno first. This patch affects generic_buffer.c, iio_event_monitor.c and iio_utils.c. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:lsiio: add closedir before exitHartmut Knaack
In dump_channels() the DIR *dp was left open on exit. Close it and check for errors. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: fix allocation handlingHartmut Knaack
In build_channel_array(), count needs to be decreased in more places since current->name and current->generic_name would be freed on the error path, although they have not been allocated, yet. This also requires to free current->name, when it is allocated, but current->generic_name is not yet allocated. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio: free channel-array completelyHartmut Knaack
In iio_utils.c build_channel_array() dynamically allocates the string generic_name in the current iio_channel_info, which doesn't got freed in case of an error. This dynamically allocated channel-array is used by generic_buffer, and needs to be freed on the error/exit path. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-05-31tools:iio:iio_utils: free scan_el_dir on exitHartmut Knaack
In the error path, the string scan_el_dir got freed, while it was missing when build_channel_array() finished without errors. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>