Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iio_attr: accept negative numbers as data to write to
getopt doesn't understand the difference between the '-' before an option and the '-' before a negative number. It can not - they are both the same, and in some applications option zero (-0) might be valid. in iio_attr this causes problems when we try to write negative numbers root@analog:~# iio_attr -o -c adrv9002-phy voltage0 hardwaregain -10 iio_attr: invalid option -- '1' Since the only time we do this in in iio_attr, handle the last option differently (if the last option is a negative number). This does mean we still don't pass -foo to an attribute to be written, since iio_attr thinks that is an unknown "-f" option. ./tests/iio_attr -v -a usb -o -c ad9361-phy voltage0 hardwaregain -foo Using auto-detected IIO context at URI "usb:3.39.5" ./tests/iio_attr: invalid option -- 'f' but this does fix the reported bug #573 ./tests/iio_attr -v -a usb -o -c ad9361-phy voltage0 hardwaregain -1 Using auto-detected IIO context at URI "usb:3.39.5" dev 'ad9361-phy', channel 'voltage0' (output), attr 'hardwaregain', value '-10.000000 dB' wrote 3 bytes to hardwaregain dev 'ad9361-phy', channel 'voltage0' (output), attr 'hardwaregain', value '-1.000000 dB' Signed-off-by: Robin Getz <[email protected]>
- Loading branch information