4 posts / 0 new
Last post
liuluan002
Offline
Last seen:6 months 1 week ago
Joined:2015-11-27 14:24
sending through UART

Hi DIalog,

I am making an application for the keeping on scanning, also I need to pulling the scanned packages into the UART. I am afraid that I will make the scanning to be blocked for the moment while I am sending through the UART. Is there any method I can do to polling out the package I got through the UART and not blocked the scanning process?

Here I have put some of my code here:

void app_scan2(void)
{
struct gapm_start_scan_cmd *cmd = KE_MSG_ALLOC(GAPM_START_SCAN_CMD,
TASK_GAPM, TASK_APP,
gapm_start_scan_cmd);

cmd->op.code = GAPM_SCAN_PASSIVE;
cmd->interval = 12288; //6000ms
cmd->window = 12288; //6000ms
cmd->mode = GAP_GEN_DISCOVERY;
cmd->filt_policy = SCAN_ALLOW_ADV_ALL;
cmd->filter_duplic = SCAN_FILT_DUPLIC_DIS;

ke_msg_send(cmd);

}

int gapm_adv_report_ind_handler(ke_msg_id_t msgid,
struct gapm_adv_report_ind *param,
ke_task_id_t dest_id,
ke_task_id_t src_id)
{

volatile struct adv_report adv = param->report;

(无符号字符i = 0;我< 6;我+ +)
{
white_addr1[i]=adv.adv_addr.addr[i];
}

uart2_init(UART_BAUDRATE_115K2, 3);

for (unsigned char i = 0; i < 6; i++)
{
printf_byte(adv.adv_addr.addr[5-i]);
uart2_init(UART_BAUDRATE_115K2, 3);
}

uart2_init(UART_BAUDRATE_115K2, 3);

for ( int j = 0; j < sizeof(adv.data); j++)
{
printf_byte(adv.data[j]);
uart2_init(UART_BAUDRATE_115K2, 3);
}

printf_string(" ");
uart2_init(UART_BAUDRATE_115K2, 3);

return (KE_MSG_CONSUMED);
}
}

Device:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

You can use the arch_printf() function instead of directly using the printf functions that essentially use the UART directly.

You can enable the arch_printf() function in the latest SDK by defining the CFG_PRINTF definition, check that the UART ports are the ones that you have connected, and include the arch_console.h file where you would like to use the arch_printf() functions.

Thanks MT_dialog

liuluan002
Offline
Last seen:6 months 1 week ago
Joined:2015-11-27 14:24
Hi Dialog,

Hi Dialog,
I am trying to use your suggestion to polling out an array from the UART.
However, I got the system restart each time I am calling the function arch_printf("%c",package_send[j]); . Do you have some suggestion how to fix this problem?
My code:
unsigned char package_send[133];
for(unsigned char j=0;j

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

I assume that you mean that you would like to print out the data of that array. If your device ends up in a wrap_platform_reset that means that you are running out memory, you are printing to much data and you are allocating an additional message for each character that you are printing without consuming it (printing it, since the actual print happens when the arch_printf_process gets invoked). Try to print the elements of the array in smaller chunks in order for the arch_printf_process() function that is invoked in the schedule_while_ble_on() to be called and print your data before entering additional data.

Thanks MT_dialog