Skip to content

Commit

Permalink
c#: Add channel method to get label
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jan 27, 2025
1 parent c816a9c commit ee14ae2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bindings/csharp/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ public struct DataFormat
[DllImport(IioLib.dllname, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr iio_channel_get_name(IntPtr chn);

[DllImport(IioLib.dllname, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr iio_channel_get_label(IntPtr chn);

[DllImport(IioLib.dllname, CallingConvention = CallingConvention.Cdecl)]
private static extern uint iio_channel_get_attrs_count(IntPtr chn);

Expand Down Expand Up @@ -216,6 +219,9 @@ private static extern uint iio_channel_write(IntPtr chn,
/// <summary>The name of this channel.</summary>
public readonly string name;

/// <summary>The label of this channel.</summary>
public string label { get; private set; }

/// <summary>An identifier of this channel.</summary>
/// <remarks>It is possible that two channels have the same ID,
/// if one is an input channel and the other is an output channel.</remarks>
Expand Down Expand Up @@ -273,6 +279,9 @@ internal Channel(Device dev, IntPtr chn)
name = Marshal.PtrToStringAnsi(name_ptr);
}

IntPtr label_ptr = iio_channel_get_label(this.chn);
label = label_ptr == IntPtr.Zero ? "" : Marshal.PtrToStringAnsi(label_ptr);

id = Marshal.PtrToStringAnsi(iio_channel_get_id(this.chn));
output = iio_channel_is_output(this.chn);
scan_element = iio_channel_is_scan_element(this.chn);
Expand Down

0 comments on commit ee14ae2

Please sign in to comment.