Custs1_Val_ntf_req的内存溢出

Learn More常见问题解答教程

18个帖子/ 0新
最后一篇
roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Custs1_Val_ntf_req的内存溢出

嗨对话小组,

如果DEF_SVC1_BUTTON_STATE_CHAR_LEN较大,则DA14585芯片将溢出为24(字节),同时发送间隔每20ms(或更少),

请告知如何每20ms正确发送240个字节。

请参阅示例代码:

//更新按钮特征
struct susts1_val_ntf_ind_req * req = ke_msg_alloc_dyn(custs1_val_ntf_req,
prf_get_task_from_id(TASK_ID_CUSTS1),
task_app,
custs1_val_ntf_ind_req,
def_svc1_button_state_char_len);

req-> conidx = app_env-> conidx;
req-> notification = true;
req->handle = SVC1_IDX_BUTTON_STATE_VAL;
req->length = DEF_SVC1_BUTTON_STATE_CHAR_LEN;
req->value[0] = count++;

KE_MSG_SEND(REQ);

//Android Code
公共空白on特征(Bluetoothgatt Gatt,BluetoothGatt Characteristic特征)
{
super.onCharacteristicChanged(gatt, characteristic);

byte [] messageBytes = charactistististing.getValue();

Log.w(TAG, "onCharacteristicChanged: " + messageBytes.length); //packget show the currect MTU (tested upto 240bytes)
}

Regards,

ro

Device:
PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨罗伊哈,

嗨罗伊哈,

我假设内存溢出位于DA14585侧。如果是的话,可以请说明代码卡在哪里吗?在platform_reset_func()中?

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

是的,platform_reset_func pop with reset_mem_alloc_fail(0xf2f2f2f2)一个clasic内存溢出

Thanks,

ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨罗伊哈,

嗨罗伊哈,

Τ他platform_reset_func platfo()调用rm_reset(), which is implemented in the ROM code. The most possible reason why you get this assertion is due to insufficient memory, because you are allocating messages which are never consumed. For example, if you are allocating notification messages and you have a small connection interval the messages are piled up until a connection event arrives, but with a large connection interval your run out of memory before the connection event arrives. You could increase the connection interval. Probably, in your application there might be some kind of memory leakage pilling up after each connection, as the error code is RESET_MEM_ALLOC_FAIL. To do so, check if there are any pending messages and make sure that you are consuming the messages that you get when the message is handled or if you are allocating data they should be freed. For example, if you sampling the ADC and you are allocating messages in order to send the data over notifications as soon as there is a connection the device eventually will run out of memory, and if the device runs out of memory this will cause the device to reset. In addition try to increase the heap size by defining the DB_HEAP_SZ in the da1458x_config_advanced.h header file.

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
嗨,

嗨,

谢谢您的解释,内存溢出显然是根本原因的副作用。

我的问题是:如何每20ms发送240byte通知?

Thanks,

ro

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

只是要更多clear关于测试代码/设置:

1). Useble_app_all_in_one.在SDK 6.0.10.511中找到

2)。在user_custs1_def.h中编辑/更新定义为:#define def_svc1_adc_val_1_char_len 120

3)。编辑/更新user_app_adcval1_timer_cb_handler间隔到20ms

4)。编译和运行

预期结果:

  • 通知事件应每20ms到达120ms的每20ms到达Android

实际结果:

  • 通知事件arrive to Android every 20ms with 120Byte of data for ~20-30 seconds followed by platform_reset_func (i.e., memory over flow)

请建议每20ms传输120字节数据到Android(优先考虑示例代码)是什么

*注意: 120byte every 20ms = 48Kbps well below the 1M limit

Regards,

ro

Example Code:

//更新user_custs1_def.h中的define:#define def_svc1_adc_val_1_char_len 120 void user_app_adcval1_timer_cb_handler(){static int count = 0;struct musts1_val_ntf_ind_req * req = ke_msg_alloc_dyn(custs1_val_ntf_req,prf_get_task_from_id(task_id_custs1),task_app,custs1_val_ntf_ind_req,def_svc1_adc_val_1_char_len);// adc值是采样的静态uint16_t样本__attribute __((部分(“保留_mem_area0”),zero_init));Sample =(Sample <= 0xFFFF)?(样品+ 1):0;req-> conidx = app_env-> conidx;req-> notification = true;req-> handle = svc1_dx_adc_val_1_val;req-> length = def_svc1_adc_val_1_char_len;// memcpy(req->值,&sample,def_svc1_adc_val_1_char_len); req->value[0] = Count++; ke_msg_send(req); if (ke_state_get(TASK_APP) == APP_CONNECTED) { // Set it once again until Stop command is received in Control Characteristic timer_used = app_easy_timer(2, user_app_adcval1_timer_cb_handler); } }

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨罗伊哈,

嗨罗伊哈,

我工作在SDK6.0.10的清晰BLE_APP_ALL_IN_ONE项目上,我使用了附加的代码片段。但是,我无法复制您的问题。变量“count”每隔20ms发送思想通知。你能在干净的ble_app_all_in_one项目中测试吗?你完成了任何其他修改吗?
谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

要重现问题,只需更改数据大小

从:

#define def_svc1_adc_val_1_char_len 120.

至:

#define def_svc1_adc_val_1_Char_Len 240.

Regards,

ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨roie,

嗨roie,

Just tested with 240 bytes size, but I am still unable to replicate it. Which the heap size that you are using? The default size is 2048 bytes. Can you please increase it?

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

在使用#define db_heap_sz 2048后溢出在〜3,000 - 3,200包后
当使用#define db_heap_sz 2048 * 4 overflow以〜6,800 - 7,200数据包之后

Please note that whenAndroid Phone MTU is in default state(即20)db_heap_sz 2048 * 4是稳定的没有溢出after ~300,000 packets (I manually stoped it)

DA14585.code: user_config.h .max_mtu = 247, Android Code set mtu: mBluetoothGatt.requestMtu(247); //Set the Android App Mtu to 247 @Override public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { super.onCharacteristicChanged(gatt, characteristic); byte[] messageBytes = characteristic.getValue(); Log.w(TAG, "onCharacteristicChanged: " + messageBytes.length + " " + messageBytes[0]); }

请建议您是否在测试台中使用Android手机?

If yes, Please share the Android version and example test code used.

*注意: The setup used here is: Samsung A5, S9 Android version 8, both phones both show the same behivior

Regards,
ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨roie,

嗨roie,

Let me ask you something for an extra clarification. Are you using a custom mobile application?

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

是的,我正在使用自定义android应用程序。

还有很少的应用商店(例如,LightBlue等)的应用程序

任何推荐的测试应用程序,您可以分享的示例?

Regards,

ro

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

Any updates?

Regards,

ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03

嗨roie,

Still I am not able to replicate it. Am working on that and I will let you know if there is any update. I will try to replicate it.

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

请建议是否有任何我可以发送任何我可以发送到图的根本原因(例如:register dump,启用一些调试Printf标志等)

Regartds,

ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨roie,

嗨roie,

您可以使用BLE Sniffer工具来检查通过空中传输的数据包。

谢谢,PM_DIALOG.

roDAHAN
离线
最后一次露面:5个月2周前
加入:2018-11-19 16:32
Hi PM_Dialog,

Hi PM_Dialog,

我没有嗅探器,请建议购买/安装的工具

Regards,

ro

PM_DIALOG.
离线
最后一次露面:10小时11分钟前
员工
加入:2018-02-08 11:03
嗨roie,

嗨roie,

Apologies for the delay. Propably I missed your last comment. Did you solve this issue?If your issue related with the DA14585, as mentioned this is due to inefficient heap size so you should increase it.

谢谢,PM_DIALOG.