1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 16:01:18 +01:00

USBUS CDC ACM STDIO: test for the buffering code

fixes #12384
This commit is contained in:
Antonio Galea 2019-10-10 14:56:58 +02:00
parent 6c04cb1a45
commit d1cc563ccf

View File

@ -18,16 +18,46 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include "shell.h"
#include "shell_commands.h"
static int cmd_text(int argc, char **argv)
{
char *usage = "text [length]\n";
if (argc != 2) {
puts(usage);
return -1;
}
int n = atoi(argv[1]);
if (n <= 0) {
puts(usage);
return -1;
}
for (int i=0; i < n; i++) {
if (i && (i % 80 == 0)) {
puts("");
}
putc('0' + (i % 10), stdout);
}
puts("");
return 0;
}
static const shell_command_t shell_commands[] = {
{ "text", "Generates long text for testing stdio buffer", cmd_text },
{ NULL, NULL, NULL }
};
int main(void)
{
(void) puts("RIOT USB CDC ACM shell test");
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}