예제 #1
0
static gnrc_nettest_res_t _pkt_test(uint16_t cmd_type, kernel_pid_t pid,
                                    gnrc_pktsnip_t *in, unsigned int exp_pkts,
                                    const kernel_pid_t *exp_senders,
                                    const gnrc_pktsnip_t **exp_out)
{
    msg_t msg;
    gnrc_nettest_res_t res = GNRC_NETTEST_SUCCESS;

    msg.type = cmd_type;
    msg.content.ptr = in;

    msg_send(&msg, pid);

    if (exp_pkts == 0) {
        thread_yield();
    }

    for (unsigned int i = 0; i < exp_pkts; i++) {
        gnrc_pktsnip_t *out;
        const gnrc_pktsnip_t *exp = exp_out[i];

        if (xtimer_msg_receive_timeout(&msg, GNRC_NETTEST_TIMEOUT) < 0) {
            return GNRC_NETTEST_TIMED_OUT;
        }

        if (msg.type != cmd_type) {
            return GNRC_NETTEST_WRONG_MSG;
        }

        if (msg.sender_pid != exp_senders[i]) {
            return GNRC_NETTEST_WRONG_SENDER;
        }

        out = msg.content.ptr;

        if (out == NULL) {
            return GNRC_NETTEST_FAIL;
        }

        while (out && exp) {
            if ((out->users != exp->users) ||
                (out->size != exp->size) ||
                (out->type != exp->type) ||
                (memcmp(out->data, exp->data, out->size) != 0)) {
                return GNRC_NETTEST_FAIL;
            }

            out = out->next;
            exp = exp->next;
        }

        gnrc_pktbuf_release(msg.content.ptr);
    }

    return res;
}
예제 #2
0
void
sol_mainloop_impl_iter(void)
{
    msg_t msg;
    uint32_t sleeptime;

    sol_mainloop_common_timeout_process();
    sol_mainloop_common_idler_process();
    sol_mainloop_common_timeout_process();

    if (!sol_mainloop_common_loop_check())
        return;

    sleeptime = sleeptime_until_next_timeout();
    if (xtimer_msg_receive_timeout(&msg, sleeptime) > 0)
        sol_interrupt_scheduler_process(&msg);
}
예제 #3
0
파일: main.c 프로젝트: JMR-b/RIOT
int main(void)
{
    msg_t m, tmsg;
    xtimer_t t;
    int64_t offset = -1000;
    tmsg.type = 44;

    for (int i = 0; i < 10; i++) {
        xtimer_set_msg(&t, SEC_IN_USEC + offset, &tmsg, sched_active_pid);
        if (xtimer_msg_receive_timeout(&m, SEC_IN_USEC) < 0) {
            puts("Timeout!");
        }
        else {
            printf("Message received: %" PRIu16 "\n", m.type);
        }
        offset = (offset < 0) ? 1000 : -1000;
    }
    return 0;
}