Skip to content
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

Support for Micropython Keyboard Interrupts #73

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

Kswin01
Copy link
Contributor

@Kswin01 Kswin01 commented Jun 13, 2024

This PR adapts the micropython port to support keyboard interrupts. We buffer the input characters from the sDDF serial subsystem in internal micropython buffers, so that we can process interrupt chars as they come in. We then read characters from our internal buffers when reads are requested. The transmit path remains unchanged.

components/micropython/mphalport.c Outdated Show resolved Hide resolved
components/micropython/mphalport.c Outdated Show resolved Hide resolved
components/micropython/mphalport.c Outdated Show resolved Hide resolved
components/micropython/mphalport.c Outdated Show resolved Hide resolved
components/micropython/mphalport.c Outdated Show resolved Hide resolved
components/micropython/micropython.h Outdated Show resolved Hide resolved
components/micropython/micropython.c Outdated Show resolved Hide resolved
components/micropython/micropython.c Outdated Show resolved Hide resolved
components/micropython/micropython.c Outdated Show resolved Hide resolved
components/micropython/mphalport.c Outdated Show resolved Hide resolved
@JE-Archer
Copy link
Contributor

One issue is that while inputting ^C will kill executions that wait for IO, it won't do anything for executions that don't. Example:

Inputting ^C will kill

async def f():
    await asyncio.sleep(10)
asyncio.run(f())

but won't kill

for i in range(100000):
    print(i)

@Kswin01
Copy link
Contributor Author

Kswin01 commented Jun 17, 2024

One issue is that while inputting ^C will kill executions that wait for IO, it won't do anything for executions that don't. Example:

Inputting ^C will kill

async def f():
    await asyncio.sleep(10)
asyncio.run(f())

but won't kill

for i in range(100000):
    print(i)

That's correct, if we never switch to the t_event co-routine, we will never process input and therefore not receive the keyboard interrupts. We couldn't think of a great way to deliver these characters within the current design.

JE-Archer
JE-Archer previously approved these changes Jun 17, 2024
Kswin01 added 5 commits June 17, 2024 13:12
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Signed-off-by: Krishnan Winter <krishnanwinter1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants