-
Notifications
You must be signed in to change notification settings - Fork 18
refactor: Replace Arduino Serial with esp native #317
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
Open
hhvrc
wants to merge
15
commits into
develop
Choose a base branch
from
feature/ditch-arduino-serial
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7745c8e
Initial commit
hhvrc 5379918
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc e001e00
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc 48f17b4
Some fixes and add jtag support
hhvrc 138c09f
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc ecb29b8
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc b78f410
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc bfff974
Replace all printf and println
hhvrc 6480cad
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc 42715c0
Fix log formatting
hhvrc 00614cf
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc 3dff1fa
Replace more Serial.print calls
hhvrc 166537a
Merge branch 'develop' into feature/ditch-arduino-serial
hhvrc a936399
use fwrite instead of write
hhvrc 3a58c8d
AI Slop fix
hhvrc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #pragma once | ||
|
|
||
| #include <driver/uart.h> | ||
|
|
||
| // Use the same UART that your console / printf uses | ||
| // On most boards this is UART_NUM_0 | ||
| #define OPENSHOCK_UART = UART_NUM_0; | ||
|
|
||
| namespace OpenShock { | ||
| // Call this once during startup (instead of Serial.begin) | ||
| inline void SerialInit() | ||
| { | ||
| // If you already use esp_console, you might already have | ||
| // the driver installed. Then you can skip the install part. | ||
| uart_config_t uart_config = { | ||
| .baud_rate = 115200, | ||
| .data_bits = UART_DATA_8_BITS, | ||
| .parity = UART_PARITY_DISABLE, | ||
| .stop_bits = UART_STOP_BITS_1, | ||
| .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, | ||
| .source_clk = UART_SCLK_DEFAULT, | ||
| }; | ||
| ESP_ERROR_CHECK(uart_param_config(OPENSHOCK_UART, &uart_config)); | ||
|
|
||
| // RX buffer only; TX is handled by vfs/printf | ||
| ESP_ERROR_CHECK(uart_driver_install(OPENSHOCK_UART, 2048, 0, 0, nullptr, 0)); | ||
|
|
||
| // Route stdin/stdout to this UART so printf/scanf work | ||
| esp_vfs_dev_uart_use_driver(OPENSHOCK_UART); | ||
| } | ||
|
|
||
| // Arduino-like helpers | ||
| inline int SerialAvailable() | ||
| { | ||
| size_t len = 0; | ||
| uart_get_buffered_data_len(OPENSHOCK_UART, &len); | ||
| return static_cast<int>(len); | ||
| } | ||
|
|
||
| inline int SerialRead() | ||
| { | ||
| std::uint8_t c; | ||
| // timeout = 0 ticks → non-blocking | ||
| int n = uart_read_bytes(OPENSHOCK_UART, &c, 1, 0); | ||
| if (n == 1) { | ||
| return static_cast<int>(c); | ||
| } | ||
| return -1; // no data | ||
| } | ||
| } // namespace OpenShock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching
common.hto include<cstdio>drops the only Arduino header that pulled in theHardwareSerial Serialdeclaration used throughoutSerialInputHandler.cpp(e.g.,_skipSerialWhitespacesstill calls::Serial.available()/read()). With no remaining include providingSerial, the file now fails to compile with‘Serial’ was not declared in this scope.Useful? React with 👍 / 👎.