Commit 01bff870 authored by jdelange's avatar jdelange

* packet-store/pinger.c

   packet-store/software.aadl
   - Complete the packet store example with a real producer and consumer


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@3516 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 6f8f1498
#include <stdio.h>
#include <request.h>
#include <deployment.h>
#include <po_hi_storage.h>
__po_hi_request_t pkt;
__po_hi_storage_packet_store_t packet_store;
void user_produce_pkts_init ()
{
printf ("*** INIT PACKET PRODUCER ***\n");
if (__po_hi_storage_packet_store_new (&packet_store) != __PO_HI_SUCCESS)
{
printf ("*** /!\ ERROR WHEN CREATING THE PACKET STORE /!\ ***\n");
}
fflush (stdout);
}
void user_produce_pkts ()
{
static int p = 0;
int ret;
__po_hi_request_t pkt;
pkt.vars.pinger_global_data_source.pinger_global_data_source = p;
pkt.port = pinger_global_data_source;
printf ("*** PRODUCE PKT WITH VALUE *** %d\n", p);
p++;
ret = __po_hi_storage_packet_store_write (&packet_store, &pkt);
if (ret != __PO_HI_SUCCESS)
{
printf ("*** /!\\ ERROR WHEN WRITING A PACKET IN THE STORE (ret=%d) /!\\ ***\n", ret);
}
fflush (stdout);
}
void user_do_ping_spg ()
{
printf ("*** SENDING PKT *** \n");
__po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt));
int ret;
__po_hi_request_t pkt;
ret = __po_hi_storage_packet_store_read (&packet_store, &pkt);
if (ret != __PO_HI_SUCCESS)
{
printf ("*** /!\\ ERROR WHEN READING A PACKET IN THE STORE /!\\ ***\n");
if (ret == __PO_HI_UNAVAILABLE)
{
printf ("*** /!\\ ;_; NO PACKET AVAILABLE AT THIS TIME ;_; /!\\ ***\n");
}
}
else
{
printf ("*** SENDING PKT *** \n");
__po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt));
}
fflush (stdout);
}
......
......@@ -15,9 +15,7 @@ public
data Simple_Type
properties
Type_Source_Name => "custom_int";
Source_Text => ("ping");
Source_Data_Size => 8 Bytes;
Data_Model::Data_Representation => integer;
end Simple_Type;
-----------------
......
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