I have several applications where my application on the STM32 provides an USB_CDC commandline interface to the user.
So during development I have a terminal program to type commands and see responses.
But then for "internal applications" I might want to automate something through the module I've created and "for now" I don't care about what's coming back.
I then send: "please do this, please do that" to the device, and 1) the characters are echoed back and 2) output is produced.
This tends to "lock up" the device after a while when the USB output buffer fills up: My input-processing (and echo-ing) process ends up in a "write" call that blocks.
Is there an api call that allows me to determine the status of the output buffer? If the output buffer is over say 25% full I want to stop echo-ing characters and output data. (If I do this say in the input processing thread, say after getting a new character, then I hope I don't accidentally activate this with normal interactive work: A command can still output say multiple buffers of data, and the user is unlikely to type a new command before the output buffer has been mostly cleared).
USB_CDC output buffer status.
Moderators: RoccoMarco, barthess
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB_CDC output buffer status.
You could try a non blocking TIME_IMMEDIATE write or a write with a small timeout.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB_CDC output buffer status.
You need to create a "stream" object performing writes with timeout internally, you may use memstream as a template, then pass your object to chprintf for output.
Giovanni
Giovanni
Who is online
Users browsing this forum: No registered users and 8 guests