Towards a1 1.0.0; implement missing GETs
[ric-plt/a1.git] / integration_tests / receiver.py
index cb5f82c..f1c324f 100644 (file)
@@ -35,8 +35,8 @@ while rmr.rmr_ready(mrc) == 0:
     print("not yet ready")
 
 print("listening ON {}".format(PORT))
-sbuf = None
 while True:
+    sbuf = rmr.rmr_alloc_msg(mrc, 4096)
     sbuf = rmr.rmr_torcv_msg(mrc, sbuf, 1000)
     summary = rmr.message_summary(sbuf)
     if summary["message state"] == 12 and summary["message status"] == "RMR_ERR_TIMEOUT":
@@ -59,5 +59,13 @@ while True:
         sbuf.contents.mtype = 21024
         print("Pre reply summary: {}".format(rmr.message_summary(sbuf)))
         time.sleep(DELAY)
-        sbuf = rmr.rmr_rts_msg(mrc, sbuf)
-        print("Post reply summary: {}".format(rmr.message_summary(sbuf)))
+
+        # try up to 5 times to send back the ack
+        for _ in range(5):
+            sbuf = rmr.rmr_rts_msg(mrc, sbuf)
+            post_reply_summary = rmr.message_summary(sbuf)
+            print("Post reply summary: {}".format(post_reply_summary))
+            if post_reply_summary["message state"] == 10 and post_reply_summary["message status"] == "RMR_ERR_RETRY":
+                time.sleep(1)
+            else:
+                break