1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

test/usbus_cdc_acm_stdio: USB CDC ACM STDIO test

This commit is contained in:
Koen Zandberg 2019-06-14 23:08:34 +02:00
parent 59743aed13
commit c6447b73dc
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
3 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,27 @@
BOARD ?= samr21-xpro
include ../Makefile.tests_common
USEMODULE += auto_init_usbus
USEMODULE += stdio_cdc_acm
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
# USB device vendor and product ID
DEFAULT_VID = 1209
DEFAULT_PID = 0001
USB_VID ?= $(DEFAULT_VID)
USB_PID ?= $(DEFAULT_PID)
CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID)
include $(RIOTBASE)/Makefile.include
.PHONY: usb_id_check
usb_id_check:
@if [ $(USB_VID) = $(DEFAULT_VID) ] || [ $(USB_PID) = $(DEFAULT_PID) ] ; then \
$(COLOR_ECHO) "$(COLOR_RED)Private testing pid.codes USB VID/PID used!, do not use it outside of test environments!$(COLOR_RESET)" 1>&2 ; \
$(COLOR_ECHO) "$(COLOR_RED)MUST NOT be used on any device redistributed, sold or manufactured, VID/PID is not unique!$(COLOR_RESET)" 1>&2 ; \
fi
all: | usb_id_check

View File

@ -0,0 +1,23 @@
Expected result
===============
A second USB serial console (ttyACMx) appears when plugging the USB peripheral
into a host computer. When opening the serial device it should show the RIOT
shell. Basic command interaction must work.
The test should work on Linux, MacOS and Windows. Putty is known to work on
Windows.
Changing the baud rate, bit mode and parity mode is accepted by the device and
reflected back. However, changing these should not affect shell operation.
Note that when testing with this firmware, the regular USB serial console from
the attached debugger is not functional.
Background
==========
This test application can be used to verify the USBUS CDC ACM implementation.
Assuming drivers available, the board under test should show up on the host
computer as an USB CDC Abstract Control Management device (ttyACMx on Linux).
Drivers are available for Linux, macOS and Windows.

View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2019 Koen Zandberg <koen@bergzand.net>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @file
* @brief Basic test for USB CDC ACM functionality. When plugged into a
* USB port, the peripheral should show up as a serial modem USB
* peripheral (/dev/ttyACMx on Linux) and should present the RIOT
* shell over this serial device.
*
* @author Koen Zandberg <koen@bergzand.net>
*
*/
#include <stdio.h>
#include "shell.h"
#include "shell_commands.h"
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);
return 0;
}