-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printer demo needs a little further help #2
Comments
PrintOut is initialized as follows so is not NULL.
The following is a an older version of the program that prints "Hello" instead of reading from terminal. |
"The following" seems to be missing... Maybe there is a race condition? If I use this modification of the loop, printing basically works, but if I leave out the test for PrinterOut being Null, the program just crashes with an illegal memory access exception and restarts, over and over again.
|
This is the older version that just prints hello. |
I note that older version also has a test It seems that, from start up, it takes a time for PrinterOut to become non-Null, and essentially, we must wait for this before trying to print. |
Of course, there must be a check for NULL. The printer may be unplugged on power up. The Arduino sketch runs as a freeRTOS task. The USB host stack is interfaced with another task. If you like, you can create semaphores to sync the tasks. Prerequisite: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/usb_host.html The ESP-IDF has USB host examples using one more task for the client/class driver and semaphores to sync main, usb host lib task, and usb client/class tasks. |
With the printer demo, it seems if you try to print just a fixed string like "hello world" instead of a line read from Serial, the program crashes, because PrinterOut is a null pointer.
I guess some extra logic is needed to check for PrinterOut being null, and it would be most instructive and helpful if you could add this.
Or perhaps a better approach would use some callback to tell when the printer is ready to accept data?
The text was updated successfully, but these errors were encountered: