# HG changeset patch
# User jfp <jf.pieronne@laposte.net>
# Date 1738326599 -3600
#      Fri Jan 31 13:29:59 2025 +0100
# Node ID 181aebe205c5ba36f0b8561f8bb4bab7d468849d
# Parent  f95a3736a0ecd03b7d510c697a9e499df738e945
Raise an OSError if a read is already pending

diff --git a/python/local/ovms_module/ovms/ptd/_vmsptd.pyx b/python/local/ovms_module/ovms/ptd/_vmsptd.pyx
--- a/python/local/ovms_module/ovms/ptd/_vmsptd.pyx
+++ b/python/local/ovms_module/ovms/ptd/_vmsptd.pyx
@@ -364,11 +364,9 @@
     "status, res = readw(handler)"
     cdef int efn = EFN_C_ENF
     cdef unsigned short s
-    # if a read is already pending, wait for completion
+    # if a read is already pending, raise an Error
     if handler.handler.read_status != 0:
-        while handler.handler.read_status != 2:
-            s = sys_hiber()
-        s = SS__NORMAL
+        raise OSError("Read already active on this Ptd")
     handler.handler.read_status = 0
     (<ptd_buf *>(handler.handler.read_buf)).status = 0
     with nogil: