Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c#: Add new channel type entry (attention) #1232

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion CI/azure/check_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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"
IIO_PY="./bindings/python/iio.py"

if [ ! -f ${IIOH} ] ; then
echo can not find ${IIOH}
Expand All @@ -16,13 +18,24 @@ if [ ! -f ${CHANNELC} ] ; then
exit 1
fi

if [ ! -f ${CHANNELC_SHARP} ] ; then
echo can not find ${CHANNELC_SHARP}
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

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}
Expand Down Expand Up @@ -82,6 +95,58 @@ 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

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
1 change: 1 addition & 0 deletions bindings/csharp/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public enum ChannelType
IIO_DELTA_VELOCITY,
IIO_COLORTEMP,
IIO_CHROMATICITY,
IIO_ATTENTION,
IIO_CHAN_TYPE_UNKNOWN = Int32.MaxValue
}

Expand Down
13 changes: 13 additions & 0 deletions bindings/python/iio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down
Loading