查看: 4116|回复: 15

[求助] _lwmsgq_receive()函数使用 求指导

[复制链接]
  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
    发表于 2015-8-18 16:43:58 | 显示全部楼层 |阅读模式
    result = _lwmsgq_receive((pointer)server_queue_a, msg_client_a, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY,0,0);
    来接收server_queue_a中的数据到msg_client_a中,如果server_queue_a中没有数据时,进程就会block在此处,如果想如果在1000ms内没有接到数据,程序不block在这里,应该怎么写
    我知道答案 目前已有15人回答

    评分

    参与人数 1NXP金币 +3 收起 理由
    小七 + 3

    查看全部评分

    该会员没有填写今日想说内容.
    回复

    使用道具 举报

  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
     楼主| 发表于 2015-8-18 16:46:27 | 显示全部楼层
    还请大神帮忙指点一下
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
     楼主| 发表于 2015-8-18 17:08:26 | 显示全部楼层
    急急急~~~
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

    该用户从未签到

    0

    主题

    45

    帖子

    0

    注册会员

    Rank: 2

    积分
    146
    最后登录
    1970-1-1
    发表于 2015-8-19 08:50:09 | 显示全部楼层
    查手册可知,最后两个参数是和超时有关的设置

    2.1.101 _lwmsgq_receive
    Get a message from a lightweight message queue.
    Synopsis
    source\kernel\lwmsgq.c
    #include <lwmsgq.h>
    #include <lwmsgq_prv.h>
    _mqx_uint _lwmsgq_receive(
      void                *handle,
      _mqx_max_type_ptr   message,
      _mqx_uint           flags,
      _mqx_uint           ticks,
      MQX_TICK_STRUCT_PTR tick_ptr)
    Parameters
    handle [IN] — Pointer to the message queue created by _lwmsgq_init
    message [OUT] — Received message
    flags [IN] — LWMSGQ_RECEIVE_BLOCK_ON_EMPTY(block the reading task if msgq is
    empty), LWMSGQ_TIMEOUT_UNTIL (perform a timeout using the tick structure as the absolute
    time), LWMSGQ_TIMEOUT_FOR (perform a timeout using the tick structure as the relative
    time)
    ticks [IN] — The maximum number of ticks to wait. If set to zero waiting time is controlled by the
    tick_ptr input parameter value. When just LWMSGQ_RECEIVE_BLOCK_ON_EMPTY flags is
    set and ticks input parameters is set to zero the receive function waits for an unlimited amount of
    time.
    tick_ptr [IN] — Pointer to the tick structure to use when ticks input parameter is set to zero.
    Returns
    • MQX_OK
    • See error codes
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
     楼主| 发表于 2015-8-19 09:14:31 | 显示全部楼层
    FSL_FAE_YDW 发表于 2015-8-19 08:50
    查手册可知,最后两个参数是和超时有关的设置

    2.1.101 _lwmsgq_receive

            MQX_TICK_STRUCT ticks;
            _time_init_ticks(&ticks, 100000);

    result = _lwmsgq_receive((pointer)server_queue_a, msg_client_a, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY,0,&ticks);

    没有收到但是没有等10s立马就回复了
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    0

    主题

    45

    帖子

    0

    注册会员

    Rank: 2

    积分
    146
    最后登录
    1970-1-1
    发表于 2015-8-19 09:32:01 | 显示全部楼层
    2.1.303 _time_get_ticks_per_sec,  _time_set_ticks_per_sec
    Prototype
    source\kernel\time.c
    _mqx_uint _time_get_ticks_per_sec(void)
    void  _time_set_ticks_per_sec(
      _mqx_uint ticks_per_sec)
    Parameters
    ticks_per_ sec [IN] — New timer frequency in ticks per second
    Returns
    • _time_get_ticks_per_sec():
    Period of clock interrupt in ticks per second
    你需要查一下目前这个系统里面每个tick多少时间,
    可以通过下面的函数先获取每秒的tick数目

    • _time_set_ticks_per_sec():
    None
    _time_get_ticks_per_sec() Gets the timer frequency (in ticks per second) that
    MQX RTOS uses.
    _time_set_ticks_per_sec() Sets the timer frequency (in ticks per second) that
    MQX RTOS uses.
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
     楼主| 发表于 2015-8-19 10:27:21 | 显示全部楼层
    FSL_FAE_YDW 发表于 2015-8-19 09:32
    2.1.303 _time_get_ticks_per_sec,  _time_set_ticks_per_sec
    Prototype
    source\kernel\time.c

    Hi,
    _time_get_ticks_per_sec()返回的是200
    需要用_time_set_ticks_per_sec()重新设置还是怎么滴呀
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    0

    主题

    45

    帖子

    0

    注册会员

    Rank: 2

    积分
    146
    最后登录
    1970-1-1
    发表于 2015-8-19 11:19:46 | 显示全部楼层
    根据200来设置,200ticks是一秒
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    难过
    2019-9-19 08:55
  • 签到天数: 269 天

    连续签到: 1 天

    [LV.8]以坛为家I

    28

    主题

    2424

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    2784
    最后登录
    2019-11-29
     楼主| 发表于 2015-8-19 11:42:38 | 显示全部楼层
    FSL_FAE_YDW 发表于 2015-8-19 11:19
    根据200来设置,200ticks是一秒

    想设置超时1s的话是不是要这样
    _lwmsgq_receive((pointer)server_queue_a, msg_client_a, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY | LWMSGQ_TIMEOUT_UNTIL, 200, 0)
    我试了下这样调用
    _lwmsgq_receive((pointer)server_queue_a, msg_client_a, LWMSGQ_TIMEOUT_UNTIL, 200, 0)
    这样调用不行
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    0

    主题

    45

    帖子

    0

    注册会员

    Rank: 2

    积分
    146
    最后登录
    1970-1-1
    发表于 2015-8-19 13:09:18 | 显示全部楼层
    是指无法返回吗?还是收不到消息?
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-28 07:56 , Processed in 0.109571 second(s), 30 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表