【问题标题】:Dbus - Did not receive a replyDbus - 没有收到回复
【发布时间】:2017-09-24 20:22:18
【问题描述】:

我对 Dbus 有一个奇怪的问题...
我使用 Dbus-1。
问题是,它只发生在不同的地方。 有时用于 IDAMsg_GetFontName,有时用于 IDAMsg_GetForeColor(例如)。 也许程序运行十次正常,然后一次出错。或者四次正常,然后两次出错。

但它总是来自我的 std::cout 和 Dbus 的相同错误消息:

Too few arguments

Did not receive a reply

但有时我的论点太少怎么办?
以及如何向 Dbus 发送这条错误消息,就像它看起来的那样,回复已发送并得到?

非常感谢您的帮助。
TIA
早吃

Dbus 消息是:

Did not receive a reply. Possible causes include: the remote 
application did not send a reply, the message bus security policy 
blocked the reply, the reply timeout expired, or the network 
connection was broken.

方法的发送:

if(vMethod == IDAMsg_Init || vMethod == IDAMsg_GetFontName
|| vMethod == IDAMsg_AppQuit
|| vMethod == IDAMsg_GetBackColor || vMethod == IDAMsg_GetForeColor
|| vMethod == IDAMsg_GetBorderColor){
    dbus_message_iter_init_append(msg, &args);
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &vMsg.Str_Send[0])) {
         cout << "DBUS -- SEND -- OUT OF MEMORY 1" << endl; return 0;
    }
    if(vMethod == IDAMsg_GetBorderColor || vMethod == IDAMsg_AppQuit){
        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &vMsg.Str_Send[1])) {
             cout << "DBUS -- SEND -- OUT of Memory 2" << endl; return 0;
        }
    }
}

回复是:

if(vMethod == IDAMsg_Init || vMethod == IDAMsg_AppQuit
|| vMethod == IDAMsg_GetFontName
|| vMethod == IDAMsg_GetBackColor || vMethod == IDAMsg_GetForeColor
|| vMethod == IDAMsg_GetBorderColor){
    if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)){
         cout << "DBUS -- REPLY -- ARG is not String 1 " << endl;
    } else {
         dbus_message_iter_get_basic(&args, &nStr_In[0]);
    }
    if(vMethod == IDAMsg_GetBorderColor || vMethod == IDAMsg_AppQuit){
        if (!dbus_message_iter_next(&args)){
             cout << "DBUS -- REPLY -- Message has too few arguments 1" << endl;
        } else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)){
             cout << "DBUS -- REPLY -- Argument is not STRING 2" << endl;
        } else {
             dbus_message_iter_get_basic(&args, &nStr_In[1]);
        }
    }
    reply = dbus_message_new_method_return(msg);
    dbus_message_iter_init_append(reply, &args);
}
if(vMethod == IDAMsg_Init){
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BOOLEAN, &stat)) {
         cout << "DBUS -- REPLY -- OUT of Memory 1" << endl; return;
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &level)) {
         cout << "DBUS -- REPLY -- OUT of Memory 2" << endl; return;
    }
}

std::cout 的输出通常是:

DBUS -- EBIDA_IDA_Server -- Method Reply for : GetForeColor
DBUS -- IDABrowse -- Got Reply  245_245_245 21614
IDA -- IDABrowse -- INCOMING CALLBACK : GetBorderColor
DBUS -- IDABrowse -- Request send with : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABrowse -- Got Reply  102_143_165 21614
IDA -- IDABrowse -- INCOMING CALLBACK : GetBorderColor
DBUS -- IDABrowse -- Request send with : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABrowse -- Got Reply  126_177_204 21614
IDA -- IDABrowse -- INCOMING CALLBACK : GetBorderColor
DBUS -- IDABrowse -- Request send with : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABrowse -- Got Reply  148_207_239 21614

但如果出现问题,它看起来像这样:

DBUS -- EBIDA_IDA_Server -- Method Reply for : GetForeColor
DBUS -- IDABase -- Got Reply  245_245_245 21614
IDA -- IDABase -- INCOMING CALLBACK : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABase -- Request send with : GetBorderColor
DBUS --  SEND -- Message has too few arguments 1
DBUS -- IDABase -- Got Reply  Did not receive a reply. Possible 
causes include: the remote application did not send a reply, the 
message bus security policy blocked the reply, the reply timeout 
expired, or the network connection was broken. 32723

编辑:

我认为问题是这样显示的:

这是正常的输出顺序:

IDA -- IDABrowse -- INCOMING CALLBACK : GetBorderColor
DBUS -- IDABrowse -- Request sending with : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABrowse -- Got Reply  126_177_204 21614

发生错误时这样:

IDA -- IDABrowse -- INCOMING CALLBACK : GetBorderColor
DBUS -- EBIDA_IDA_Server -- Method Reply for : GetBorderColor
DBUS -- IDABrowse -- Request sending with : GetBorderColor
DBUS -- IDABrowse -- Got Reply  126_177_204 21614

如果出错,则第 2 行和第 3 行已更改。
比,回复存在之前请求发送...

【问题讨论】:

    标签: c++ linux dbus


    【解决方案1】:

    调试方法是使用dbus-monitorBustle 查看总线上的流量(请求、回复、错误)。这应该可以查明错误并向您显示导致错误的消息。

    【讨论】:

    • 好的,谢谢。不知道...也许在底部的 OP 上有一个新外观。
    • 是什么触发了请求和回复的发送?我假设回复将作为接收请求的结果发送,但您的跟踪输出表明并非如此。这两段代码是否在同一个进程中运行?
    • 两位代码?我觉得不行。这是我让运行的例程。而且,是的,就像您在我的 OP [编辑部分] 末尾看到的那样。现在奇怪的是,在发送回复之前,我替换了 std::cout 作为回复之后, 这个错误再也没有出现过。 (编码之神与我同在 。)也许原因也可能是,我将 Dbus 循环(我自己的循环编码)中的 usleep 从 20 扩展到 1000,这对 CPU 来说更好用法。或者可能两者都在一起......
    猜你喜欢
    • 2016-04-20
    • 2018-05-06
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 2018-12-06
    • 2012-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多