Hi everybody,
I have some trouble with the _io_cdc_serial_read function in the CDC usb host example.
/*FUNCTION****************************************************************
*
* Function Name : _io_cdc_serial_read
* Returned Value : _mqx_int number of characters read
* Comments :
* This routine reads characters from the USB serial I/O channel
* device, converting carriage return ('\r') characters to newlines,
* and then echoing the input characters.
*
*END*********************************************************************/
int_32 _io_cdc_serial_read
(
/* [IN] the file handle for the device */
FILE_CDC_PTR fd_ptr,
/* [IN] where the characters are to be stored */
char_ptr data_ptr,
/* [IN] the number of characters to input */
int_32 num
)
It is specified that the function returns the "number of characters read". What happens to me is that everytime i call this function the return value is always 1 even if i have more than 1 byte stored by the function in the "data_ptr" location.
For example: i send 5 bytes with _io_cdc_serial_write to a CDC device that send back to the host the same 5 bytes.
then i call:
num_done = _io_cdc_serial_read(f_usb, usb2uart, sizeof(uart2usb))
what i see is that in the usb2uart buffer i have all the 5 bytes received but num_done = 1.
The opposite function, _io_cdc_serial_write , seems to work properly. I send 5 byte and it returns me the same value as "byte sended".
Any ideas?
Thanks,
Matteo Davanzo
Hi Matteo Davanzo:
which board and MQX version you are using?
Regards
Daniel
Hi Daniel Chen,
I'm using the FDRM-KL26Z. But i've discovered the problem.
There was an issue inside the in_data_callback. Undefining the USB_UART_HW_FLOW it works, now i can talk in both directions without problem.
But now i'm testing the speed of the connection, i transfer 1Mbyte of data from device to host and then from host to device an what i can see is that i can achieve a speed of only 46 KByte/s and this is very worst for my purposes. I'm trying to improve that but at the moment i don't now how to fix this. I try to cancel the delay that is inserted in the stack when e NAK is received but i have not see a noticeable improvement.
My code doens't do anything else of receiving / sending. If you have any ideas about that i would appreciate it so much.
Thank you for your answer,
Regards
Matteo
Hi Daniel,
I'm already using this kind of implementation. I think there is a problem on the host stack that limits the speed.
In another project, that i developed starting from the CDC device example, in a connection with a PC i can reach 250 Kbyte / s in terms of speed.
So i'm pretty sure that the problem is on the host side. I'm watching the new sdk 1.3.0 because i've see in the documentation of the MSD example that it can reach about 500 kByte/s, but there is a lot of difference in the code with the usb 4.1 stack so at the moment i can't test it, i need to understand the new concept of the sdk before.
Regars,
Matteo