Hello everyone, I am attempting to create an embedded device for a school project where I need to send some text data over USB on power-up. It is a constant stream of serial data.
For this, I am setting my own application as the entry point instead of NSH, which requires me to instantiate the USB output myself. I have copied the USB console setup from NSH into my application, and I can see the USB device showing up with `dmesg` so I know it is successfully started. However, none of my `write()` calls to the file descriptor or `fprintf` calls are working correctly. The code for the USB setup is: ```c void board_late_initialize(void) { /* Initialize the USB serial driver */ struct boardioc_usbdev_ctrl_s ctrl; FAR void *handle; int ret; #if defined(CONFIG_CDCACM) ctrl.usbdev = BOARDIOC_USBDEV_CDCACM; ctrl.action = BOARDIOC_USBDEV_CONNECT; ctrl.instance = 0; ctrl.handle = &handle; ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); UNUSED(ret); /* Eliminate warning if not used */ DEBUGASSERT(ret == OK); #endif } ``` Then I am writing to the USB device like so: ```c #define USB_CONSOLE "/dev/ttyACM0" do { console = open(USB_CONSOLE, O_RDWR); /* ENOTCONN means that the USB device is not yet connected, so sleep. * Anything else is bad. */ DEBUGASSERT(errno == ENOTCONN); sleep(1); } while (console < 0); /* Make USB stdout, stderr, stdin */ dup2(console, 0); dup2(console, 1); dup2(console, 2); printf("A=%lf,B=%lf,G=%lf\n", pos.x, pos.y, pos.z); ``` I have tried using `fprintf` on the file descriptor returned by `open`, and also using `write` directly to no avail. The console just stays blank on my host computer. Any ideas what else I could try? Thanks, Matteo
signature.asc
Description: PGP signature