4 #include <fres_contract.h>
8 int contract_deadline_sec[N] = { 8, 8, 4 };
9 int contract_nodes[N] = { 0x01, 0x03, 0x02 };
11 int main(int argc, char *argv[])
14 frsh_contract_t contract[N];
15 frsh_vres_id_t vres[N];
19 if (ret) PERROR_AND_EXIT(ret, "frsh_init");
21 /* Negotiate N contracts */
23 frsh_rel_time_t deadline;
24 frsh_signal_info_t si;
25 fres_block_item_nodes *nodes;
26 ret = frsh_contract_init(&contract[i]);
27 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
30 ret = frsh_contract_set_resource_and_label(
31 &contract[i], FRSH_RT_NETWORK, FRSH_NETPF_ITEM, NULL);
32 if (ret) PERROR_AND_EXIT(ret, "Cannot set resource\n");
34 /* Set nodes we want to receive data from */
35 nodes = malloc(sizeof(*nodes));
36 if (!nodes) PERROR_AND_EXIT(errno, "malloc");
37 nodes->mask = contract_nodes[i];
38 ret = fres_contract_add_block(contract[i], FRES_BLOCK_ITEM_NODES,
40 if (ret) PERROR_AND_EXIT(ret, "Cannot add item_nodes block\n");
43 deadline = fosa_msec_to_rel_time(contract_deadline_sec[i]*1000);
44 ret = frsh_contract_set_timing_reqs(&contract[i],
47 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_timing_reqs");
49 /* Negotiate the contract */
50 ret = frsh_contract_negotiate(&contract[i], &vres[i]);
51 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
53 printf("Contracts negotiated\n");
55 for (i=0; i<10; i++) {
57 printf("Reading data\n");
60 ret = fra_item_receive(vres[j], &data);
61 if (ret == -1) PERROR_AND_EXIT(errno, "frs_item_receive");
63 /* TODO: Do something with the received data */
70 /* for (i=0; i<N; i++) { */
71 /* frsh_cancel_contract(vres[i]); */