Beispiel #1
0
static void buf_queue_send_param_test(void)
{
    kstat_t ret;
    ksem_t  sem;

    memset(&sem, 0, sizeof(ksem_t));

    ret = krhino_buf_queue_send(&g_test_bufqueue0, NULL, TEST_BUFQUEUE_MSG_MAX);
    BUFQUEUE_VAL_CHK(ret == RHINO_NULL_PTR);


    ret = krhino_buf_queue_send(NULL, g_test_send_msg0, TEST_BUFQUEUE_MSG_MAX);
    BUFQUEUE_VAL_CHK(ret == RHINO_NULL_PTR);

    ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                TEST_BUFQUEUE_MSG_MAX + 1);
    BUFQUEUE_VAL_CHK(ret == RHINO_BUF_QUEUE_MSG_SIZE_OVERFLOW);


    ret = krhino_sem_create(&sem, "test_sem ", 0);
    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    g_test_bufqueue0.blk_obj.obj_type = RHINO_OBJ_TYPE_NONE;
    ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                TEST_BUFQUEUE_MSG_MAX);
    g_test_bufqueue0.blk_obj.obj_type = RHINO_BUF_QUEUE_OBJ_TYPE;
    BUFQUEUE_VAL_CHK(ret == RHINO_KOBJ_TYPE_ERR);

    ret = krhino_buf_queue_send((kbuf_queue_t *)&sem, g_test_send_msg0, 0);
    BUFQUEUE_VAL_CHK(ret == RHINO_KOBJ_TYPE_ERR);
    krhino_sem_del(&sem);
}
Beispiel #2
0
static void task_buf_queue_trigger_entry(void *arg)
{
    *(uint8_t *)buf_queue_send = 0x5a;

    krhino_buf_queue_send(&test_buf_queue, (void *)buf_queue_send, 1);
    krhino_task_dyn_del(krhino_cur_task_get());
}
Beispiel #3
0
static void task_queue0_entry(void *arg)
{
    kstat_t ret;

    while (1) {
        ret = krhino_buf_queue_create(&g_test_bufqueue0, "test_bufqueue0",
                                      g_test_bufqueue_buf0,
                                      TEST_BUFQUEUE_BUF0_SIZE, TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        /* check krhino_buf_queue_flush param */
        buf_queue_flush_param_test();

        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_BUF_QUEUE_FULL);

        ret = krhino_buf_queue_flush(&g_test_bufqueue0);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        ret = krhino_buf_queue_del(&g_test_bufqueue0);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        if (test_case_check_err == 0) {
            test_case_success++;
            PRINT_RESULT("buf queue flush", PASS);
        } else {
            test_case_check_err = 0;
            test_case_fail++;
            PRINT_RESULT("buf queue flush", FAIL);
        }

        next_test_case_notify();
        krhino_task_dyn_del(task_0_test);
    }
}
Beispiel #4
0
static void task_queue2_entry(void *arg)
{
    kstat_t ret;
    kbuf_queue_info_t info;
    size_t count = 0;

    while (1) {

        memset(g_test_send_msg1, 's', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg1,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);
        count++;

        memset(g_test_send_msg1, 'o', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg1,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);
        count++;


        memset(g_test_send_msg1, 'y', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg1,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);
        count++;


        memset(g_test_send_msg1, 'w', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg1,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_BUF_QUEUE_FULL);

        (void)krhino_buf_queue_info_get(&g_test_bufqueue0, &info);

        BUFQUEUE_VAL_CHK(count == info.cur_num);
        krhino_task_dyn_del(task_2_test);
    }
}
Beispiel #5
0
OSStatus mico_rtos_push_to_queue( mico_queue_t* queue, void* message, uint32_t timeout_ms )
{
    kstat_t ret;
    kbuf_queue_t *q = *((kbuf_queue_t **)queue);

    timeout_ms = timeout_ms;

    ret = krhino_buf_queue_send(q, message, q->max_msg_size);

    if (ret == RHINO_SUCCESS) {
        return kNoErr;
    }

    return kGeneralErr;
}
Beispiel #6
0
static void task_queue1_entry(void *arg)
{
    kstat_t ret;
    kbuf_queue_info_t info;

    while (1) {
        memset(g_test_send_msg0, 'y', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        memset(g_test_send_msg0, 'o', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        memset(g_test_send_msg0, 's', TEST_BUFQUEUE_MSG_MAX);
        ret = krhino_buf_queue_send(&g_test_bufqueue0, g_test_send_msg0,
                                    TEST_BUFQUEUE_MSG_MAX);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        krhino_task_dyn_del(task_1_test);
    }
}
Beispiel #7
0
int aos_queue_send(aos_queue_t *queue, void *msg, unsigned int size)
{
    int ret;

    if ((queue == NULL) || (msg == NULL)) {
        return -EINVAL;
    }

    ret = krhino_buf_queue_send(queue->hdl, msg, size);
    if (ret == RHINO_SUCCESS) {
        return 0;
    }

    ERRNO_MAPPING(ret);
}
Beispiel #8
0
static void task_queue0_entry(void *arg)
{
    kstat_t ret;
    size_t  size;
    int     count = 0;
    size_t  msg;

    /* err param test */
    ret = krhino_buf_queue_create(&g_test_bufqueue0, "test_bufqueue0",
                                  (void *)g_test_bufqueue_buf0,
                                  TEST_BUFQUEUE_BUF0_SIZE, 0);

    BUFQUEUE_VAL_CHK(ret == RHINO_INV_PARAM);

    ret = krhino_buf_queue_create(&g_test_bufqueue0, "test_bufqueue0",
                                  (void *)g_test_bufqueue_buf0,
                                  TEST_BUFQUEUE_BUF0_SIZE, TEST_BUFQUEUE_MSG_MAX);

    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    ret = krhino_fix_buf_queue_create(&g_test_bufqueue1, "test_bufqueue1",
                                      (void *)g_test_bufqueue_buf1, sizeof(size_t), 2);

    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    msg = 0x11;
    ret = krhino_buf_queue_send(&g_test_bufqueue1, &msg, sizeof(size_t));
    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    ret = krhino_buf_queue_send(&g_test_bufqueue1, &msg, sizeof(size_t));
    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    ret = krhino_buf_queue_send(&g_test_bufqueue1, &msg, sizeof(size_t));
    BUFQUEUE_VAL_CHK(ret == RHINO_BUF_QUEUE_FULL);

    (void)krhino_buf_queue_recv(&g_test_bufqueue1, RHINO_NO_WAIT, &msg, &size);
    (void)krhino_buf_queue_recv(&g_test_bufqueue1, RHINO_NO_WAIT, &msg, &size);

    ret = krhino_buf_queue_recv(&g_test_bufqueue1, 1, &msg, &size);
    BUFQUEUE_VAL_CHK(ret == RHINO_BLK_TIMEOUT);

    /* check krhino_buf_queue_recv */
    buf_queue_recv_param_test();

    buf_queue_send_param_test();

    /* check RHINO_NO_WAIT */
    ret = krhino_buf_queue_recv(&g_test_bufqueue0, RHINO_NO_WAIT, &g_test_recv_msg0,
                                &size);
    BUFQUEUE_VAL_CHK(ret == RHINO_NO_PEND_WAIT);

    /* check sched disalbe */
    ret = krhino_sched_disable();
    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);
    ret = krhino_buf_queue_recv(&g_test_bufqueue0, RHINO_WAIT_FOREVER,
                                &g_test_recv_msg0, &size);
    BUFQUEUE_VAL_CHK(ret == RHINO_SCHED_DISABLE);
    ret = krhino_sched_enable();
    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    ret = krhino_task_dyn_create(&task_1_test, "task_bufqueue1_test", 0,
                                 TEST_BUFQUEUE_SND_TASK_LOW_RPI,
                                 0, TASK_TEST_STACK_SIZE, task_queue1_entry, 1);

    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    do {
        ret = krhino_buf_queue_recv(&g_test_bufqueue0, RHINO_WAIT_FOREVER,
                                    g_test_recv_msg0, &size);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        memset(g_test_send_msg0, send_char[count], TEST_BUFQUEUE_MSG_MAX);
        ret = memcmp(g_test_send_msg0, g_test_recv_msg0, size);
        count ++;
    } while (count <  TEST_BUFQUEUE_MSG_NUM);


    ret = krhino_task_dyn_create(&task_2_test, "task_bufqueue2_test", 0,
                                 TEST_BUFQUEUE_SND_TASK_HIGH_RPI,
                                 0, TASK_TEST_STACK_SIZE, task_queue2_entry, 1);

    BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

    krhino_task_sleep(RHINO_CONFIG_TICKS_PER_SECOND / 10);

    count = 0;

    do {
        ret = krhino_buf_queue_recv(&g_test_bufqueue0, RHINO_WAIT_FOREVER,
                                    g_test_recv_msg0, &size);
        BUFQUEUE_VAL_CHK(ret == RHINO_SUCCESS);

        memset(g_test_send_msg1, send_char[count], TEST_BUFQUEUE_MSG_MAX);
        ret = memcmp(g_test_send_msg1, g_test_recv_msg0, size);
        count ++;
    } while (count <  TEST_BUFQUEUE_MSG_NUM);


    if (test_case_check_err == 0) {
        test_case_success++;
        PRINT_RESULT("buf queue recv", PASS);
    } else {
        test_case_check_err = 0;
        test_case_fail++;
        PRINT_RESULT("buf queue recv", FAIL);
    }

    next_test_case_notify();
    krhino_task_dyn_del(task_0_test);
}
Beispiel #9
0
/**
 * \brief Process byte reception
 *
 * \param[in] device The pointer to device structure
 * \param[in] data Data read
 */
static void usart_fill_rx_buffer(struct _usart_async_device *device, uint8_t data)
{
	struct usart_os_descriptor *descr = CONTAINER_OF(device, struct usart_os_descriptor, device);

	krhino_buf_queue_send(&descr->kbuf, &data, 1);
}