GTKterm从arduino设备打印c ++代码

时间:2016-10-24 00:31:16

标签: linux arduino serial-port embedded

我有一个arduino设备(特别是RedBear实验室BLE nano设备)。我希望能够将日志输出到GTKterm。我正在遵循设置设备的教程:https://github.com/RedBearLab/BLENano/blob/master/Docs/RB_Nano_Doc_6-8-15.pdf。教程说要将波特率设置为38400,选择正确的端口,并将HW流量放在RTS / CTS上。然而,当我这样做时,只有10%的时间我会实际看到一个输出(来自printf())。我注意到的一件事是当我打开GTKterm(使用sudo GTKterm)时出现以下错误:"控制信号读取:输入/输出错误"。我该如何调试呢?

代码示例:

int main(void)
{
    bool erase_bonds;

// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);
buttons_leds_init(&erase_bonds);
uart_init();
printf("Heart rate collector example (this is a custom log)\r\n");
ble_stack_init();
device_manager_init(erase_bonds);
db_discovery_init();
hrs_c_init();
bas_c_init();

// Start scanning for peripherals and initiate connection
// with devices that advertise Heart Rate UUID.
printf("This is where the scan should start\r\n");
scan_start();

for (;; )
{
    power_manage();
}
}




/**@brief Function for initializing the UART.
 */
static void uart_init(void)
{
    uint32_t err_code;
const app_uart_comm_params_t comm_params =
   {
       RX_PIN_NUMBER,
       TX_PIN_NUMBER,
       RTS_PIN_NUMBER,
       CTS_PIN_NUMBER,
       APP_UART_FLOW_CONTROL_ENABLED,
       false,
       UART_BAUDRATE_BAUDRATE_Baud38400
   };

APP_UART_FIFO_INIT(&comm_params,
                      UART_RX_BUF_SIZE,
                      UART_TX_BUF_SIZE,
                      uart_error_handle,
                      APP_IRQ_PRIORITY_LOW,
                      err_code);

APP_ERROR_CHECK(err_code);

app_trace_init();
}



/**@brief Function to start scanning.
 */
static void scan_start(void)
{
    printf("Starting scan\r\n");
    ble_gap_whitelist_t   whitelist;
    ble_gap_addr_t      * p_whitelist_addr[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
    ble_gap_irk_t       * p_whitelist_irk[BLE_GAP_WHITELIST_IRK_MAX_COUNT];
    uint32_t              err_code;
    uint32_t              count;
// Verify if there is any flash access pending, if yes delay starting scanning until 
// it's complete.
err_code = pstorage_access_status_get(&count);
APP_ERROR_CHECK(err_code);

if (count != 0)
{
    m_memory_access_in_progress = true;
    return;
}

// Initialize whitelist parameters.
whitelist.addr_count = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
whitelist.irk_count  = 0;
whitelist.pp_addrs   = p_whitelist_addr;
whitelist.pp_irks    = p_whitelist_irk;

// Request creating of whitelist.
err_code = dm_whitelist_create(&m_dm_app_id,&whitelist);
APP_ERROR_CHECK(err_code);

if (((whitelist.addr_count == 0) && (whitelist.irk_count == 0)) ||
    (m_scan_mode != BLE_WHITELIST_SCAN)                        ||
    (m_whitelist_temporarily_disabled))
{
    // No devices in whitelist, hence non selective performed.
    printf("No devices in whitelist, hence non selective performed.");
    m_scan_param.active       = 0;            // Active scanning set.
    m_scan_param.selective    = 0;            // Selective scanning not set.
    m_scan_param.interval     = SCAN_INTERVAL;// Scan interval.
    m_scan_param.window       = SCAN_WINDOW;  // Scan window.
    m_scan_param.p_whitelist  = NULL;         // No whitelist provided.
    m_scan_param.timeout      = 0x0000;       // No timeout.
}
else
{
    // Selective scanning based on whitelist first.
    printf("Selective scanning based on whitelist first.");
    m_scan_param.active       = 0;            // Active scanning set.
    m_scan_param.selective    = 1;            // Selective scanning not set.
    m_scan_param.interval     = SCAN_INTERVAL;// Scan interval.
    m_scan_param.window       = SCAN_WINDOW;  // Scan window.
    m_scan_param.p_whitelist  = &whitelist;   // Provide whitelist.
    m_scan_param.timeout      = 0x001E;       // 30 seconds timeout.
}

err_code = sd_ble_gap_scan_start(&m_scan_param);
APP_ERROR_CHECK(err_code);

err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
APP_ERROR_CHECK(err_code);
}

0 个答案:

没有答案