Sending strings using USB_Class_CDC_Send_Data

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sending strings using USB_Class_CDC_Send_Data

701 Views
kevinlfw
Contributor III

I'm using the USB CDC VCOM code found in KSDK 1.3.0 and I'm attempting to write a string to my terminal.  The call is simple:

 

USB_Class_CDC_Send_Data(applicationHandle, DIC_BULK_IN_ENDPOINT, "Hello, World!", 13);

 

I've also tried casting (uint8_t*)"Hello, World!".  Both methods print some non ASCII characters:

156413_156413.PNGCapture.PNG

 

So I played around with it and did this:

    uint8_t *buffer;

    buffer = malloc(size);

    memcpy(buffer, "Hello, World!", 13);

     USB_Class_CDC_Send_Data(applicationHandle, DIC_BULK_IN_ENDPOINT, buffer, 13);

and it prints:

156414_156414.PNGCapture.PNG

 

I don't believe I should have to copy the buffer in order to print the message, so what am I doing wrong; or what is the SDK doing that's preventing me from simply printing out a specified byte sequence.

Labels (1)
0 Kudos
1 Reply

437 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Kevin,

I apologize for the late response.

This behaviour is expected and is correct.

If you refer to structure of the function, there is expected pointer on buffer.

uint8_t* app_buff,

usb_status USB_Class_CDC_Send_Data

(

cdc_handle_t cdc_handle,

uint8_t ep_num,

uint8_t* app_buff,

uint32_t size

)

Because - if you hand over text parameter (instead of pointer on buffer), there will be displayed content which is on this address in hexa.

I hope this explains your question.

Best Regards,

Iva

0 Kudos