-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
emulation on host: Add full UART driver emulation. #5785
Conversation
This PR replaces the high level Serial mock with a more complete UART driver. This way the HardwareSerial works without any modifications. Additionally the driver supports UART0 and UART1 at the same time (UART0 is directed to stdout and UART1 writes to stderr). RX is implemented by switching the terminal into raw non-blocking mode and injecting each key-press directly into the FIFO of UART0. A new command line switch -c was added to ignore CTRL-C and send it via serial as well. The decumentation was updated accordingly. Reading and setting of GPIOs does only write to stderr, when compiled with D=1. But this is subject to be replaced with a proper GPIO emu anyway. Reading from GPIO0 now returns 1 instead of 0 because this is most likely a low active input.
@everslick Can you properly restore the terminal state after the double ^C, Also is there a way to tell |
The restore is actually in, but I see it not working here as well. I'll have a look... The \r -> \r\n translation should be easy to add. I will commit something... thanks for the feedback! :-) |
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.
This is running well, tested with WiFiTelnetToSerial
, thanks !
I however have an issue. My terminal gets broken somewhere and can't be restored:
if (!isatty(STDIN))
{
perror("isatty(STDIN)");
//system("stty sane"); <- same error message "Inappropriate ioctl for device"
return 0;
}
My terminal gets broken after I initialize ESP8266WebServer
so I will track this bug myself, not the fault of this PR.
Can you check and perror-report on all tcget/setattr / isatty
's like above ?
(funny system programming on an arduino core :)
This PR replaces the high level Serial mock with a more complete UART driver. This way the HardwareSerial works without any modifications. Additionally the driver supports UART0 and UART1 at the same time (UART0 is directed to stdout and UART1 writes to stderr). RX is implemented by switching the terminal into raw non-blocking mode and injecting each key-press directly into the FIFO of UART0. A new command line switch -c was added to ignore CTRL-C and send it via serial as well. The decumentation was updated accordingly.
Reading and setting of GPIOs does only write to stderr, when compiled with D=1. But this is subject to be replaced with a proper GPIO emulation anyway. Reading from GPIO0 now returns 1 instead of 0 because this is most likely a low active input.