Beispiel #1
0
rt_err_t rtgui_send_urgent(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size)
{
    rt_err_t result;

    RT_ASSERT(app != RT_NULL);
    RT_ASSERT(event != RT_NULL);
    RT_ASSERT(event_size != 0);

    rtgui_event_dump(app, event);

    result = rt_mq_urgent(app->mq, event, event_size);
    if (result != RT_EOK)
        rt_kprintf("send ergent event to %s failed\n", app->name);

    return result;
}
Beispiel #2
0
rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
{
	rt_err_t result;
	struct rtgui_thread* thread;

	rtgui_event_dump(tid, event);

	/* find rtgui_thread */
	thread = (struct rtgui_thread*) (tid->user_data);
	if (thread == RT_NULL) return -RT_ERROR;

	result = rt_mq_urgent(thread->mq, event, event_size);
	if (result != RT_EOK)
		rt_kprintf("send ergent event failed\n");

	return result;
}
Beispiel #3
0
rt_err_t rtgui_send(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size)
{
    rt_err_t result;

    RT_ASSERT(app != RT_NULL);
    RT_ASSERT(event != RT_NULL);
    RT_ASSERT(event_size != 0);

    rtgui_event_dump(app, event);

    result = rt_mq_send(app->mq, event, event_size);
    if (result != RT_EOK)
    {
        if (event->type != RTGUI_EVENT_TIMER)
            rt_kprintf("send event to %s failed\n", app->name);
    }

    return result;
}
Beispiel #4
0
rt_err_t rtgui_send_sync(struct rtgui_app* app, rtgui_event_t *event, rt_size_t event_size)
{
    rt_err_t r;
    rt_int32_t ack_buffer, ack_status;
    struct rt_mailbox ack_mb;

    RT_ASSERT(app != RT_NULL);
    RT_ASSERT(event != RT_NULL);
    RT_ASSERT(event_size != 0);

    rtgui_event_dump(app, event);

    /* init ack mailbox */
    r = rt_mb_init(&ack_mb, "ack", &ack_buffer, 1, 0);
    if (r != RT_EOK)
        goto __return;

    event->ack = &ack_mb;
    r = rt_mq_send(app->mq, event, event_size);
    if (r != RT_EOK)
    {
        rt_kprintf("send sync event failed\n");
        goto __return;
    }

    r = rt_mb_recv(&ack_mb, (rt_uint32_t *)&ack_status, RT_WAITING_FOREVER);
    if (r != RT_EOK)
        goto __return;

    if (ack_status != RTGUI_STATUS_OK)
        r = -RT_ERROR;
    else
        r = RT_EOK;

__return:
    /* fini ack mailbox */
    rt_mb_detach(&ack_mb);
    return r;
}
Beispiel #5
0
rt_err_t rtgui_thread_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
{
	rt_err_t result;
	struct rtgui_thread* thread;

	rtgui_event_dump(tid, event);
	/* if (event->type != RTGUI_EVENT_TIMER)
		rt_kprintf("event size: %d\n", event_size); */

	/* find rtgui_thread */
	thread = (struct rtgui_thread*) (tid->user_data);
	if (thread == RT_NULL) return -RT_ERROR;

	result = rt_mq_send(thread->mq, event, event_size);
	if (result != RT_EOK)
	{
		if (event->type != RTGUI_EVENT_TIMER)
			rt_kprintf("send event to %s failed\n", thread->tid->name);
	}

	return result;
}
Beispiel #6
0
rt_err_t rtgui_thread_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
{
	rt_err_t r;
	struct rtgui_thread* thread;
	rt_int32_t ack_buffer, ack_status;
	struct rt_mailbox ack_mb;

	rtgui_event_dump(tid, event);

	/* init ack mailbox */
	r = rt_mb_init(&ack_mb, "ack", &ack_buffer, 1, 0);
	if ( r!= RT_EOK) goto __return;

	/* find rtgui_thread */
	thread = (struct rtgui_thread*) (tid->user_data);
	if (thread == RT_NULL){ r = RT_ERROR; goto __return; }

	event->ack = &ack_mb;
	r = rt_mq_send(thread->mq, event, event_size);
	if (r != RT_EOK) 
	{
		rt_kprintf("send sync event failed\n");
		goto __return;
	}

	r = rt_mb_recv(&ack_mb, (rt_uint32_t*)&ack_status, RT_WAITING_FOREVER);
	if ( r!= RT_EOK) goto __return;

	if (ack_status != RTGUI_STATUS_OK) r = -RT_ERROR;
	else r = RT_EOK;

	/* fini ack mailbox */
	rt_mb_detach(&ack_mb);

__return:
	return r;
}