7 The xapp python framework repository includes a python submodule
8 called `rmr`. This package (`ricxappframe.rmr`) is a CTYPES wrapper
9 around the RMR shared library. Most Xapp users will never use this
10 package natively; however python apps that need access to the low
11 level RMR API can use this package. Usage of this python package
12 requires that you have the RMR shared-object library installed.
19 Sphinx can generate API documentation by running Python to pull doc strings
20 from the binding code using these Sphinx directives that are commented out:
21 .. automodule:: ricxappframe.rmr.rmr
23 But that approach requires the RMR library to be installed, which is difficult
24 to achieve at ReadTheDocs.io. Instead, the RST below was generated and captured
25 according to the method shown at
26 https://stackoverflow.com/questions/2668187/make-sphinx-generate-rst-class-documentation-from-pydoc
30 .. py:module:: ricxappframe.rmr.rmr
34 !! processed by numpydoc !!
36 .. py:class:: rmr_mbuf_t
37 :module: ricxappframe.rmr.rmr
40 Reimplementation of rmr_mbuf_t which is in an unaccessible header file (src/common/include/rmr.h)
43 | int state; // state of processing
44 | int mtype; // message type
45 | int len; // length of data in the payload (send or received)
46 | unsigned char* payload; // transported data
47 | unsigned char* xaction; // pointer to fixed length transaction id bytes
48 | int sub_id; // subscription id
49 | int tp_state; // transport state (a.k.a errno)
51 | these things are off limits to the user application
53 | void* tp_buf; // underlying transport allocated pointer (e.g. nng message)
54 | void* header; // internal message header (whole buffer: header+payload)
55 | unsigned char* id; // if we need an ID in the message separate from the xaction id
56 | int flags; // various MFL (private) flags as needed
57 | int alloc_len; // the length of the allocated space (hdr+payload)
60 We do not include the fields we are not supposed to mess with
62 RE PAYLOADs type below, see the documentation for c_char_p:
64 Represents the C char * datatype when it points to a zero-terminated string. For a general character pointer that may also point to binary data, POINTER(c_char) must be used. The constructor accepts an integer address, or a bytes object.
81 Structure/Union member
84 Structure/Union member
87 Structure/Union member
90 Structure/Union member
93 Structure/Union member
96 Structure/Union member
99 Structure/Union member
103 !! processed by numpydoc !!
105 .. py:function:: rmr_init(uproto_port, max_msg_size, flags)
106 :module: ricxappframe.rmr.rmr
109 Refer to rmr C documentation for rmr_init
110 extern void* rmr_init(char* uproto_port, int max_msg_size, int flags)
112 This python function checks that the context is not None and raises
113 an excption if it is.
130 !! processed by numpydoc !!
132 .. py:function:: rmr_ready(vctx)
133 :module: ricxappframe.rmr.rmr
136 Refer to rmr C documentation for rmr_ready
137 extern int rmr_ready(void* vctx)
155 !! processed by numpydoc !!
157 .. py:function:: rmr_close(vctx)
158 :module: ricxappframe.rmr.rmr
161 Refer to rmr C documentation for rmr_close
162 extern void rmr_close(void* vctx)
180 !! processed by numpydoc !!
182 .. py:function:: rmr_set_stimeout(vctx, time)
183 :module: ricxappframe.rmr.rmr
186 Refer to the rmr C documentation for rmr_set_stimeout
187 extern int rmr_set_stimeout(void* vctx, int time)
205 !! processed by numpydoc !!
207 .. py:function:: rmr_alloc_msg(vctx, size, payload=None, gen_transaction_id=False, mtype=None, meid=None, sub_id=None, fixed_transaction_id=None)
208 :module: ricxappframe.rmr.rmr
211 Refer to the rmr C documentation for rmr_alloc_msg
212 extern rmr_mbuf_t* rmr_alloc_msg(void* vctx, int size)
213 TODO: on next API break, clean up transaction_id ugliness. Kept for now to preserve API.
215 if payload is not None, attempts to set the payload
216 if gen_transaction_id is True, it generates and sets a transaction id. Note, fixed_transaction_id supersedes this option
217 if mtype is not None, sets the sbuf's message type
218 if meid is not None, sets the sbuf's meid
219 if sub_id is not None, sets the sbud's subscription id
220 if fixed_transaction_id is set, it deterministically sets the transaction_id. This overrides the option gen_transation_id
237 !! processed by numpydoc !!
239 .. py:function:: rmr_realloc_payload(ptr_mbuf, new_len, copy=False, clone=False)
240 :module: ricxappframe.rmr.rmr
243 Refer to the rmr C documentation for rmr_realloc_payload().
244 extern rmr_mbuf_t* rmr_realloc_payload(rmr_mbuf_t*, int, int, int)
262 !! processed by numpydoc !!
264 .. py:function:: rmr_free_msg(mbuf)
265 :module: ricxappframe.rmr.rmr
268 Refer to the rmr C documentation for rmr_free_msg
269 extern void rmr_free_msg(rmr_mbuf_t* mbuf )
287 !! processed by numpydoc !!
289 .. py:function:: rmr_payload_size(ptr_mbuf)
290 :module: ricxappframe.rmr.rmr
293 Refer to the rmr C documentation for rmr_payload_size
294 extern int rmr_payload_size(rmr_mbuf_t* msg)
312 !! processed by numpydoc !!
314 .. py:function:: rmr_send_msg(vctx, ptr_mbuf)
315 :module: ricxappframe.rmr.rmr
318 Refer to the rmr C documentation for rmr_send_msg
319 extern rmr_mbuf_t* rmr_send_msg(void* vctx, rmr_mbuf_t* msg)
337 !! processed by numpydoc !!
339 .. py:function:: rmr_rcv_msg(vctx, ptr_mbuf)
340 :module: ricxappframe.rmr.rmr
343 Refer to the rmr C documentation for rmr_rcv_msg
344 extern rmr_mbuf_t* rmr_rcv_msg(void* vctx, rmr_mbuf_t* old_msg)
362 !! processed by numpydoc !!
364 .. py:function:: rmr_torcv_msg(vctx, ptr_mbuf, ms_to)
365 :module: ricxappframe.rmr.rmr
368 Refer to the rmr C documentation for rmr_torcv_msg
369 extern rmr_mbuf_t* rmr_torcv_msg(void* vctx, rmr_mbuf_t* old_msg, int ms_to)
387 !! processed by numpydoc !!
389 .. py:function:: rmr_rts_msg(vctx, ptr_mbuf, payload=None, mtype=None)
390 :module: ricxappframe.rmr.rmr
393 Refer to the rmr C documentation for rmr_rts_msg
394 extern rmr_mbuf_t* rmr_rts_msg(void* vctx, rmr_mbuf_t* msg)
396 additional features beyond c-rmr:
397 if payload is not None, attempts to set the payload
398 if mtype is not None, sets the sbuf's message type
415 !! processed by numpydoc !!
417 .. py:function:: rmr_call(vctx, ptr_mbuf)
418 :module: ricxappframe.rmr.rmr
421 Refer to the rmr C documentation for rmr_call
422 extern rmr_mbuf_t* rmr_call(void* vctx, rmr_mbuf_t* msg)
440 !! processed by numpydoc !!
442 .. py:function:: rmr_set_meid(ptr_mbuf, byte_str)
443 :module: ricxappframe.rmr.rmr
446 Refer to the rmr C documentation for rmr_bytes2meid
447 extern int rmr_bytes2meid(rmr_mbuf_t* mbuf, unsigned char const* src, int len);
449 Caution: the meid length supported in an RMR message is 32 bytes, but C applications
450 expect this to be a nil terminated string and thus only 31 bytes are actually available.
452 Raises: exceptions.MeidSizeOutOfRang
469 !! processed by numpydoc !!
471 .. py:function:: rmr_get_meid(ptr_mbuf)
472 :module: ricxappframe.rmr.rmr
475 Get the managed equipment ID (meid) from the message header.
480 **ptr_mbuf: ctypes c_void_p**
481 Pointer to an rmr message buffer
501 !! processed by numpydoc !!
503 .. py:function:: rmr_get_src(ptr_mbuf, dest)
504 :module: ricxappframe.rmr.rmr
507 Refer to the rmr C documentation for rmr_get_src
508 extern unsigned char* rmr_get_src(rmr_mbuf_t* mbuf, unsigned char* dest);
526 !! processed by numpydoc !!
528 .. py:function:: get_payload(ptr_mbuf)
529 :module: ricxappframe.rmr.rmr
532 Given a rmr_buf_t*, get it's binary payload as a bytes object
537 **ptr_mbuf: ctypes c_void_p**
538 Pointer to an rmr message buffer
558 !! processed by numpydoc !!
560 .. py:function:: get_xaction(ptr_mbuf)
561 :module: ricxappframe.rmr.rmr
564 given a rmr_buf_t*, get it's transaction id
569 **ptr_mbuf: ctypes c_void_p**
570 Pointer to an rmr message buffer
590 !! processed by numpydoc !!
592 .. py:function:: message_summary(ptr_mbuf)
593 :module: ricxappframe.rmr.rmr
596 Returns a dict that contains the fields of a message
601 **ptr_mbuf: ctypes c_void_p**
602 Pointer to an rmr message buffer
622 !! processed by numpydoc !!
624 .. py:function:: set_payload_and_length(byte_str, ptr_mbuf)
625 :module: ricxappframe.rmr.rmr
628 | Set an rmr payload and content length
629 | In place method, no return
635 the bytes to set the payload to
637 **ptr_mbuf: ctypes c_void_p**
638 Pointer to an rmr message buffer
654 !! processed by numpydoc !!
656 .. py:function:: generate_and_set_transaction_id(ptr_mbuf)
657 :module: ricxappframe.rmr.rmr
660 Generate a UUID and Set an rmr transaction id to it
665 **ptr_mbuf: ctypes c_void_p**
666 Pointer to an rmr message buffer
682 !! processed by numpydoc !!
684 .. py:function:: set_transaction_id(ptr_mbuf, tid_bytes)
685 :module: ricxappframe.rmr.rmr
688 Set an rmr transaction id
689 TODO: on next API break, merge these two functions. Not done now to preserve API.
694 **ptr_mbuf: ctypes c_void_p**
695 Pointer to an rmr message buffer
698 bytes of the desired transaction id
714 !! processed by numpydoc !!
716 .. py:function:: get_src(ptr_mbuf)
717 :module: ricxappframe.rmr.rmr
720 Get the message source (likely host:port)
725 **ptr_mbuf: ctypes c_void_p**
726 Pointer to an rmr message buffer
746 !! processed by numpydoc !!