This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_usbd_cdc_acm_write new line char issue

Using app_usbd_cdc_acm_write method as blow:

char str[51];
char dev_name[NRF_SDH_BLE_CENTRAL_LINK_COUNT][7];
.
.
.
size_t size = sprintf(str,"{\n\"room\": \"%s\",\n\"uuid\": 0x%X,\n\"value\": %3d\n}\n", dev_name[p_ble_ess_c->conn_handle], BLE_UUID_HUMIDITY_CHARACTERISTIC, p_ble_ess_evt->params.humidity.humidity_value);

app_usbd_cdc_acm_write( &m_app_cdc_acm,
                        str,
                        size);

I see following output in Putty. 

Baudrate is correct (115200) + it decodes first part of the message. 

I have no idea why it crashes at new line.

Using UART module I had no such problems.

Deleting new line characters like that:

size = sprintf(str,"{\"room\": \"%s\",\"uuid\": 0x%X,\"value\": %3d}\n", dev_name[p_ble_ess_c->conn_handle], BLE_UUID_HUMIDITY_CHARACTERISTIC, p_ble_ess_evt->params.humidity.humidity_value);
Didn't change much:

It there a character limit for this method?

Related