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");
29 /* Set nodes we want to receive data from */
30 nodes = malloc(sizeof(*nodes));
31 if (!nodes) PERROR_AND_EXIT(errno, "malloc");
32 nodes->mask = contract_nodes[i];
33 ret = fres_contract_add_block(contract[i], FRES_BLOCK_ITEM_NODES,
35 if (ret) PERROR_AND_EXIT(ret, "Cannot add item_nodes block\n");
38 deadline = fosa_msec_to_rel_time(contract_deadline_sec[i]*1000);
39 ret = frsh_contract_set_timing_reqs(&contract[i],
42 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_timing_reqs");
44 /* Negotiate the contract */
45 ret = frsh_contract_negotiate(&contract[i], &vres[i]);
46 if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
48 printf("Contracts negotiated\n");
50 for (i=0; i<10; i++) {
52 printf("Reading data\n");
55 ret = frs_item_receive(vres[j], &data);
56 if (ret == -1) PERROR_AND_EXIT(errno, "frs_item_receive");
58 /* TODO: Do something with the received data */
65 /* for (i=0; i<N; i++) { */
66 /* frsh_cancel_contract(vres[i]); */