mirror of
https://github.com/naruxde/revpimodio2.git
synced 2026-09-30 23:04:29 +02:00
feat: Return -1 to indicate an error in get_switching_cycles method
The old behavior was the return of the maximum value. However, this can also be a valid value. Now all positive values are valid and a negative value of -1 describes an error in the query. close #37 Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
1 parent
a347620a58
commit
f86527b5fd
1 file changed
+8
-3
@@ -1285,7 +1285,8 @@ class RelaisOutput(IOBase):
|
|||||||
This function is only available locally on a Revolution Pi. This
|
This function is only available locally on a Revolution Pi. This
|
||||||
function cannot be used via RevPiNetIO.
|
function cannot be used via RevPiNetIO.
|
||||||
|
|
||||||
:return: Integer of switching cycles as single value or tuple of all
|
:return: Integer of switching cycles as single value or tuple of all. The
|
||||||
|
value -1 indicates an error.
|
||||||
"""
|
"""
|
||||||
# Using ioctl request K+29 = 19229
|
# Using ioctl request K+29 = 19229
|
||||||
if self._parentdevice._modio._run_on_pi:
|
if self._parentdevice._modio._run_on_pi:
|
||||||
@@ -1298,10 +1299,14 @@ class RelaisOutput(IOBase):
|
|||||||
self.__ioctl_arg,
|
self.__ioctl_arg,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If not implemented, we return the max value and set an error
|
|
||||||
ioctl_return_value = b"\xff" * struct.calcsize(self.__ioctl_arg_format)
|
|
||||||
self._parentdevice._modio._gotioerror("rocounter", e)
|
self._parentdevice._modio._gotioerror("rocounter", e)
|
||||||
|
|
||||||
|
# To report an error, return -1 values
|
||||||
|
if self._bitaddress == -1:
|
||||||
|
return -1, -1, -1, -1
|
||||||
|
else:
|
||||||
|
return -1
|
||||||
|
|
||||||
elif hasattr(self._parentdevice._modio._myfh, "ioctl"):
|
elif hasattr(self._parentdevice._modio._myfh, "ioctl"):
|
||||||
# IOCTL over network
|
# IOCTL over network
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in new issue
Block a user