1/*
2 * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <camkes.h>
8#include <stdio.h>
9#include "payload.h"
10#include <camkes/dataport.h>
11
12int run(void) {
13    int operands[] = { 342, 74, 283, 37, 534 };
14    int sz = sizeof(operands) / sizeof(int);
15    const char *name = get_instance_name();
16
17    printf("%s: what's the answer to ", name);
18    for (int i = 0; i < sz; i++) {
19        printf("%d ", operands[i]);
20        if (i != sz - 1) {
21            printf("+ ");
22        }
23    }
24    printf("?\n");
25
26    struct payload *p = (void*)d + 1024;
27    p->sz = sz;
28    for (int i = 0; i < sz; i++) {
29        p->operands[i] = operands[i];
30    }
31
32    dataport_ptr_t ptr = a_calculate(dataport_wrap_ptr((void*)p));
33    p = dataport_unwrap_ptr(ptr);
34
35    printf("%s: result was %d\n", name, p->result);
36    return 0;
37}
38