Commit c69fc100 authored by Federico Vaga's avatar Federico Vaga

sw:py: use the proper strerror for Mock Turtle

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent e375d87b
......@@ -156,6 +156,10 @@ class TrtlDevice(object):
self.libtrtl.trtl_open_by_id.argtypes = [c_uint]
self.libtrtl.trtl_open_by_id.restype = c_void_p
self.libtrtl.trtl_open_by_id.errcheck = self.__errcheck_pointer
# ERROR
self.libtrtl.trtl_strerror.argtypes = [c_int]
self.libtrtl.trtl_strerror.restype = c_char_p
self.libtrtl.trtl_open_by_id.errcheck = self.__errcheck_pointer
# SHM READ
self.libtrtl.trtl_smem_read.argtypes = [c_void_p, c_uint,
POINTER(c_int), c_size_t,
......@@ -252,7 +256,8 @@ class TrtlDevice(object):
def __errcheck_pointer(self, ret, func, args):
"""Generic error handler for functions returning pointers"""
if ret is None:
raise OSError(get_errno(), os.strerror(get_errno()), "")
raise OSError(get_errno(),
self.libtrtl.trtl_strerror(get_errno()), "")
else:
return ret
......@@ -260,7 +265,8 @@ class TrtlDevice(object):
"""Generic error checker for functions returning 0 as success
and -1 as error"""
if ret < 0:
raise OSError(get_errno(), os.strerror(get_errno()), "")
raise OSError(get_errno(),
self.libtrtl.trtl_strerror(get_errno()), "")
else:
return ret
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment