From 431feb0acdd535ab5b7516b91462ab56b5f77d0a Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Wed, 22 Jan 2025 11:20:34 +0200 Subject: [PATCH 1/4] c#: Add new channel type entry (attention) Signed-off-by: Dan Nechita --- bindings/csharp/Channel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/csharp/Channel.cs b/bindings/csharp/Channel.cs index cdc37ec3a..9e818572b 100644 --- a/bindings/csharp/Channel.cs +++ b/bindings/csharp/Channel.cs @@ -122,6 +122,7 @@ public enum ChannelType IIO_DELTA_VELOCITY, IIO_COLORTEMP, IIO_CHROMATICITY, + IIO_ATTENTION, IIO_CHAN_TYPE_UNKNOWN = Int32.MaxValue } From 1fc0561ab68b3b9aee4338205c4918621f77b433 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Wed, 22 Jan 2025 12:28:18 +0200 Subject: [PATCH 2/4] python: Keep channel types and modifiers in sync Signed-off-by: Dan Nechita --- bindings/python/iio.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bindings/python/iio.py b/bindings/python/iio.py index d0ee12dbb..014dd8264 100644 --- a/bindings/python/iio.py +++ b/bindings/python/iio.py @@ -236,6 +236,14 @@ class ChannelModifier(Enum): IIO_MOD_ETHANOL = 42 IIO_MOD_H2 = 43 IIO_MOD_O2 = 44 + IIO_MOD_LINEAR_X = 45 + IIO_MOD_LINEAR_Y = 46 + IIO_MOD_LINEAR_Z = 47 + IIO_MOD_PITCH = 48 + IIO_MOD_YAW = 49 + IIO_MOD_ROLL = 50 + IIO_MOD_LIGHT_UVA = 51 + IIO_MOD_LIGHT_UVB = 52 class ChannelType(Enum): @@ -276,6 +284,11 @@ class ChannelType(Enum): IIO_POSITIONRELATIVE = 32 IIO_PHASE = 33 IIO_MASSCONCENTRATION = 34 + IIO_DELTA_ANGL = 35 + IIO_DELTA_VELOCITY = 36 + IIO_COLORTEMP = 37 + IIO_CHROMATICITY = 38 + IIO_ATTENTION = 39 IIO_CHAN_TYPE_UNKNOWN = 0x7FFFFFFF From af566489d200a7629e1d3b10c1234833eadb01f4 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Thu, 23 Jan 2025 17:12:17 +0200 Subject: [PATCH 3/4] CI: Check C# enums are in sync with latest kernel Signed-off-by: Dan Nechita --- CI/azure/check_kernel.sh | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/CI/azure/check_kernel.sh b/CI/azure/check_kernel.sh index 9b5568148..446c9e2a7 100755 --- a/CI/azure/check_kernel.sh +++ b/CI/azure/check_kernel.sh @@ -5,6 +5,7 @@ KERNEL_TYPES="/tmp/mainline_types.h" KERNEL_MODIFIER="/tmp/modifier.c" IIOH="./include/iio/iio.h" CHANNELC="./channel.c" +CHANNELC_SHARP="./bindings/csharp/Channel.cs" if [ ! -f ${IIOH} ] ; then echo can not find ${IIOH} @@ -16,13 +17,19 @@ if [ ! -f ${CHANNELC} ] ; then exit 1 fi +if [ ! -f ${CHANNELC_SHARP} ] ; then + echo can not find ${CHANNELC_SHARP} + exit 1 +fi + rm -f ${KERNEL_TYPES} ${KERNEL_MODIFIER} wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h wget -O ${KERNEL_MODIFIER} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/drivers/iio/industrialio-core.c +iio_groups=("iio_chan_type" "iio_modifier" "iio_event_type" "iio_event_direction") ret=0 -for enum in iio_chan_type iio_modifier iio_event_type iio_event_direction +for enum in "${iio_groups[@]}"; do echo looking for ${enum} rm -f /tmp/kernel_${enum} /tmp/libiio_${enum} @@ -82,6 +89,34 @@ while IFS="" read -r p ; do fi done < /tmp/kernel_modifier +# Cleanup up leading tabs & spaces and trailing commas +for group in "${iio_groups[@]}"; +do + sed -i -e 's/^[ \t]*//' -e 's/,$//' "/tmp/kernel_${group}" +done + +echo Checking C# bindings + +csharp_enums=("ChannelType" "ChannelModifier") +for i in {0..1} +do + echo "looking for ${csharp_enums[i]}" + sed "0,/^[[:space:]]*public enum ${csharp_enums[i]}/d" ${CHANNELC_SHARP} | \ + sed -n '/}/q;p' | sed '1{/{/d}' | sed -e 's/^[ \t]*//' -e 's/,$//' | \ + grep -v IIO_CHAN_TYPE_UNKNOWN > "/tmp/libiio_csharp_${csharp_enums[i]}" + + echo "Differences in ${csharp_enums[i]}" + set +e + diff -u -w "/tmp/libiio_csharp_${csharp_enums[i]}" "/tmp/kernel_${iio_groups[i]}" + count=$(diff -u -w "/tmp/libiio_csharp_${csharp_enums[i]}" "/tmp/kernel_${iio_groups[i]}" | wc -l) + set -e + if [ "$count" -ne "0" ] ; then + ret=1 + echo "difference between upstream kernel types.h and Channels.cs in ${csharp_enums[i]}" + else + echo none + fi +done rm -f /tmp/kernel_modifier /tmp/libiio_iio_modifier /tmp/libiio_iio_chan_type ${KERNEL_TYPES} ${KERNEL_MODIFIER} exit $ret From 17bc457bd1b68b792811d456bc6bef0d6b7af306 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Thu, 23 Jan 2025 18:37:24 +0200 Subject: [PATCH 4/4] CI: Check Python enums are in sync with latest kernel Signed-off-by: Dan Nechita --- CI/azure/check_kernel.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CI/azure/check_kernel.sh b/CI/azure/check_kernel.sh index 446c9e2a7..605f52ab2 100755 --- a/CI/azure/check_kernel.sh +++ b/CI/azure/check_kernel.sh @@ -6,6 +6,7 @@ KERNEL_MODIFIER="/tmp/modifier.c" IIOH="./include/iio/iio.h" CHANNELC="./channel.c" CHANNELC_SHARP="./bindings/csharp/Channel.cs" +IIO_PY="./bindings/python/iio.py" if [ ! -f ${IIOH} ] ; then echo can not find ${IIOH} @@ -22,6 +23,11 @@ if [ ! -f ${CHANNELC_SHARP} ] ; then exit 1 fi +if [ ! -f ${IIO_PY} ] ; then + echo can not find ${IIO_PY} + exit 1 +fi + rm -f ${KERNEL_TYPES} ${KERNEL_MODIFIER} wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h wget -O ${KERNEL_MODIFIER} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/drivers/iio/industrialio-core.c @@ -118,5 +124,29 @@ do fi done +echo Checking Python bindings + +python_enums=("ChannelType" "ChannelModifier" "EventType" "EventDirection") + +for i in {0..3} +do + echo "looking for ${python_enums[i]}" + sed "0,/^class ${python_enums[i]}/d" ${IIO_PY} | \ + sed '0,/^$/d' | sed -n '/^$/q;p'| sed -e 's/^[ \t]*//' -e 's/ .*//' | \ + grep -v IIO_CHAN_TYPE_UNKNOWN > "/tmp/libiio_py_${python_enums[i]}" + + echo "Differences in ${python_enums[i]}" + set +e + diff -u -w "/tmp/libiio_py_${python_enums[i]}" "/tmp/kernel_${iio_groups[i]}" + count=$(diff -u -w "/tmp/libiio_py_${python_enums[i]}" "/tmp/kernel_${iio_groups[i]}" | wc -l) + set -e + if [ "$count" -ne "0" ] ; then + ret=1 + echo "difference between upstream kernel types.h and iio.py in ${python_enums[i]}" + else + echo none + fi +done + rm -f /tmp/kernel_modifier /tmp/libiio_iio_modifier /tmp/libiio_iio_chan_type ${KERNEL_TYPES} ${KERNEL_MODIFIER} exit $ret