Skip to content

Commit

Permalink
python: Fix Channel.read() / Channel.write()
Browse files Browse the repository at this point in the history
Channel.read() was using an undefined variable; and both methods were
using an invalid prototype for the underlying C function.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Nov 29, 2023
1 parent e6c6ddc commit f5b7f6a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bindings/python/iio.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class ChannelType(Enum):
_c_read.restype = c_ssize_t
_c_read.argtypes = (
_ChannelPtr,
_BufferPtr,
_BlockPtr,
c_void_p,
c_size_t,
c_bool,
Expand All @@ -582,7 +582,7 @@ class ChannelType(Enum):
_c_write.restype = c_ssize_t
_c_write.argtypes = (
_ChannelPtr,
_BufferPtr,
_BlockPtr,
c_void_p,
c_size_t,
c_bool,
Expand Down Expand Up @@ -853,7 +853,7 @@ def read(self, block, raw=False):
returns: type=bytearray
An array containing the samples for this channel
"""
array = bytearray(buf._length)
array = bytearray(len(block))
mytype = c_char * len(array)
c_array = mytype.from_buffer(array)
length = _c_read(self._channel, block._block, c_array, len(array), raw)
Expand Down

0 comments on commit f5b7f6a

Please sign in to comment.