X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fbindings%2Frmr-python%2Frmr%2Frmr.py;h=aeb9e18c468960eefbfe4139ac37d2f7ba9ccd05;hb=f68c2ced7de2bdfc475a9282cde91a67d83325de;hp=bc6523708aadcfeda364958969b895dbcf36e699;hpb=46ae0f44cd0ea713601f16adc5ea709e607eb2e8;p=ric-plt%2Flib%2Frmr.git diff --git a/src/bindings/rmr-python/rmr/rmr.py b/src/bindings/rmr-python/rmr/rmr.py index bc65237..aeb9e18 100644 --- a/src/bindings/rmr-python/rmr/rmr.py +++ b/src/bindings/rmr-python/rmr/rmr.py @@ -18,7 +18,7 @@ import uuid import json from ctypes import RTLD_GLOBAL, Structure, c_int, POINTER, c_char, c_char_p, c_void_p, memmove, cast from ctypes import CDLL -from ctypes import create_string_buffer, pythonapi +from ctypes import create_string_buffer # https://docs.python.org/3.7/library/ctypes.html # https://stackoverflow.com/questions/2327344/ctypes-loading-a-c-shared-library-that-has-dependencies/30845750#30845750 @@ -89,13 +89,6 @@ def _state_to_status(stateno): return sdict.get(stateno, "UNKNOWN STATE") -def _errno(): - """Suss out the C error number value which might be useful in understanding - an underlying reason when RMr returns a failure. - """ - return c_int.in_dll(pythonapi, "errno").value - - ############## # PUBLIC API ############## @@ -116,6 +109,7 @@ class rmr_mbuf_t(Structure): unsigned char* payload; // transported data unsigned char* xaction; // pointer to fixed length transaction id bytes int sub_id; // subscription id + int tp_state; // transport state (a.k.a errno) // these things are off limits to the user application void* tp_buf; // underlying transport allocated pointer (e.g. nng message) void* header; // internal message header (whole buffer: header+payload) @@ -142,6 +136,7 @@ class rmr_mbuf_t(Structure): ), # according to th following the python bytes are already unsinged https://bytes.com/topic/python/answers/695078-ctypes-unsigned-char ("xaction", POINTER(c_char)), ("sub_id", c_int), + ("tp_state", c_int), ] @@ -292,7 +287,7 @@ def message_summary(ptr_to_rmr_buf_t): "payload max size": rmr_payload_size(ptr_to_rmr_buf_t), "meid": meid, "message source": get_src(ptr_to_rmr_buf_t), - "errno": _errno(), + "errno": ptr_to_rmr_buf_t.contents.tp_state, }