lpcware

Shared memory buffer - nxpUSBLib

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by fjarnjak on Tue Jul 03 21:38:17 MST 2012
Shared memory buffer in the nxpUSBLib is limiting my application...

What I want to do is to constantly stream data as fast as possible (no explicit delays, except ones that occur due to snprintf, send, etc) as a virtual COM port to my Windows machine. In case user sends something to the device, stream will be changed, stopped, or whatever else...

However, buffer gets corrupted the moment I send something to the device; streaming one-way works fine. If I send data for example every 1 second, and in the mean time something comes from the PC to the device, buffer is not corrupted because send/receive operations do not overlap. Sometimes though, it naturally happens in case you were unlucky and typed when device was about to send/or sending.

Shared buffer would work in the request & reply scenario - PC sends command; device responds; PC sends another command; device responds, and so on.

Is there a plan to make 2 separate buffers for outgoing and incoming endpoint? Maybe as user-configurable option to save memory for those who do not need separate buffers?


Also, I noticed that when I follow CDC library documentation - meaning calling CDC_Device_USBTask followed by USB_Task() function, after receiving 1 charachter as in the virtual serial demo, it will constantly send charachters back (echo). If I comment out CDC_Device_USBTask it sends one echo. I can see in the example that call to CDC_Device_USBTask was commented out...which seems to confirm my observation. I suggest this issue should get documented or even better it should be resolved so that we can follow API. 


It would be nice to have working CDC_Device_CreateStream to get the stream and use printf type methods directly...



Outcomes