我使用蓝牙聊天示例作为起点,实现从手机到嵌入式设备的 BT 连接。我能够成功连接到设备,但一旦建立连接,logcat 就会被大量日志记录淹没。当我第一次使用 BT 聊天应用程序电话对电话时,我没有看到这种类型的日志记录。
这是一遍又一遍重复的内容。它基本上使 logcat 无法使用。到目前为止,我还没有找到配置日志记录的方法或者为什么它记录这么多。任何见解将不胜感激。
03-08 14:29:04.941: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.957: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.957: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.971: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.976: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.989: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.991: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.016: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.016: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.034: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.036: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.050: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.051: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.066: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.066: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.081: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.081: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.086: DEBUG/(2419): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_READ_EVT
03-08 14:29:05.086: DEBUG/(2419): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
03-08 14:29:05.086: DEBUG/(2419): bts_log_tstamps_us: [update stats] ts 1263504, bta hdl 2, diff 01263504, tx_q 1 (1), rx_q 0 (0)
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_poll: transp poll : (fd 41) returned r_ev [POLLIN ] (0x1)
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_poll: return 1
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_read: read 122 bytes out of 1024 on fd 41
03-08 14:29:05.101: DEBUG/BluetoothSocket(11422): read
03-08 14:29:05.101: DEBUG/BluetoothSocket.cpp(11422): readNative
03-08 14:29:05.101: DEBUG/ASOCKWRP(11422): asocket_read
03-08 14:29:05.106: INFO/BLZ20_WRAPPER(11422): blz20_wrp_poll: nfds 2, timeout -1 ms
03-08 14:29:05.117: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.121: DEBUG/BluetoothSocket.cpp(11422): availableNative
I used the Bluetooth Chat example as a starting point to implement a BT connection from my phone to an embedded device. I am able to successfully connect to the device but once the connection is made the logcat is getting overrun by a massive amount of logging. I did not see this type of logging when first doing the BT chat app phone to phone.
Here is what is repeated over and over. It basically makes the logcat unusable. So far I haven't found a way to configure the logging or why it's logging so much. Any insights would be appreciated.
03-08 14:29:04.941: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.957: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.957: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.971: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.976: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:04.989: DEBUG/BluetoothSocket(11422): available
03-08 14:29:04.991: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.016: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.016: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.034: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.036: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.050: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.051: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.066: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.066: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.081: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.081: DEBUG/BluetoothSocket.cpp(11422): availableNative
03-08 14:29:05.086: DEBUG/(2419): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_READ_EVT
03-08 14:29:05.086: DEBUG/(2419): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
03-08 14:29:05.086: DEBUG/(2419): bts_log_tstamps_us: [update stats] ts 1263504, bta hdl 2, diff 01263504, tx_q 1 (1), rx_q 0 (0)
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_poll: transp poll : (fd 41) returned r_ev [POLLIN ] (0x1)
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_poll: return 1
03-08 14:29:05.086: DEBUG/BLZ20_WRAPPER(11422): blz20_wrp_read: read 122 bytes out of 1024 on fd 41
03-08 14:29:05.101: DEBUG/BluetoothSocket(11422): read
03-08 14:29:05.101: DEBUG/BluetoothSocket.cpp(11422): readNative
03-08 14:29:05.101: DEBUG/ASOCKWRP(11422): asocket_read
03-08 14:29:05.106: INFO/BLZ20_WRAPPER(11422): blz20_wrp_poll: nfds 2, timeout -1 ms
03-08 14:29:05.117: DEBUG/BluetoothSocket(11422): available
03-08 14:29:05.121: DEBUG/BluetoothSocket.cpp(11422): availableNative
发布评论
评论(5)
在使用我的 Arduino 板 + 蓝牙适配器后,我尝试实现 马特·贝尔的博客。问题是以下代码:
调用以下函数会导致 logCat 中产生巨大的垃圾邮件
LogCat:
PS:时间戳实际上是固定版本的。不使用该修复将导致每5ms发送垃圾邮件,从而有效地阻止我的整个日志
我当前的修复是在while循环末尾添加以下代码,从而减少垃圾邮件。
我希望这能帮助一些有类似问题的人。
编辑:目前我不得不将睡眠计时器减少到 10 毫秒 bam .. SPAM
After playing with my Arduino Board + Bluetooth-Adapter I tryed to implement the Bluetooth-Code from MATT BELL'S BLOG. The Problem is the following Code:
Calling the following function results in huge Spam in logCat
LogCat:
PS: The timestamps are in fact of the fixed version. Not using the fix will will result in a spam every 5ms effectivly blocking my whole Log
My current fix is adding the following code at the end of the while loop resulting in reduction of the spam.
I hope this will help some people with similar issues.
Edit: Currently I had to reduce the sleep-timer to 10ms bam .. SPAM
这一定是一个错误,而且是一个严重的错误:
要么 Logcat 有时只显示此调试打印 - 尽管我的代码总是遇到它
或者蓝牙芯片有时会松动...(更有可能)。
只是将日志级别从详细设置为调试不会改变这样一个事实:有大量数据传输到 Logcat,从而阻止了所有正常日志...
This must be an error, and a serious one:
either Logcat only shows this debug print sometimes - although my code always comes across it
or the Bluetooth chip runs loose sometimes...(more likely).
Just turning the log level to debug from verbose won't change the fact there is an enormous amount of data transferred to Logcat, blocking all normal logs...
我只是偶然发现这一点:三年后,这种日志堵塞仍然存在 - 至少在我的三星 GT-I8190 (4.1.2) 上。
罪魁祸首是
mmInputStream.available()
解决这个问题的一种方法是不使用它的
available()
方法。而不是:您可以使用类似下面的代码来避免日志堵塞...
下面的代码也适用于具有此讨厌错误的手机。不过,它可能应该进行修改,因为它只是一个快速的解决方案。脏修复:
I just stumbled upon this: after 3 years this log clogging is still present - at least on my Samsung GT-I8190 (4.1.2).
The culprit is
mmInputStream.available()
One way around this is not to use it
available()
method. Instead of:You could use something like the code below to awoid log clogging...
This code below also works on phones with this nasty bug. It should probably be revise though since it is just a quick & dirty fix:
“avaliableNative”具有详细优先级。要删除该消息(以及所有详细消息),请使用“*:D”参数作为最后一个 logcat 参数。通过使用软盘图标旁边的组合框中的“调试”优先级,可以在 Eclipse 中实现类似的效果。
"avaliableNative" has a Verbose priority. To get rid of the message (and all verbose messages as well) use a "*:D" parameter as the last logcat parameter. Similar thing can be achieved in Eclipse by using the "debug" priority in the combo box next to the floppy disk icon.
在 DDMS 中,您可以使用调试、信息、错误、警告按钮来过滤掉内容,您还可以创建一个特殊的过滤器来仅显示您感兴趣的内容。不要认为有任何蓝牙设置可以关闭该日志记录你可以使用。
In DDMS you can filter things out by using the debug, info, error, warning buttons and you can also create a special filter to only show things that you are interested in. Don't think there is any bluetooth setting to turn off logging that you could use.