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

In WSL2 - Enter does not work, need Ctrl-Enter #3

Closed
Eloque opened this issue Jan 10, 2024 · 6 comments
Closed

In WSL2 - Enter does not work, need Ctrl-Enter #3

Eloque opened this issue Jan 10, 2024 · 6 comments

Comments

@Eloque
Copy link

Eloque commented Jan 10, 2024

When using grblhud in interactive mode, hitting "Enter" on either numpad or regular does not send the command.
For example, typing "help" and "enter" does not execute a command, but instead issues a space.

Using "ctrl-enter" does work, both the regular and numpad enter.

Using WSL2, Ubuntu 22.04.3 LTS on Windows 10 Pro and Python 3.12.1

@johannesnoordanus
Copy link
Owner

Hi, I just saw your comment.

It could be due to a keyboard mapping problem. Or even the specific keyboard type (hardware) you use.
I read that it is best to configure from the 'windows' side of things.

But, it might be good old 'CRLF' (\r\n) of windows versus 'LF' ('\n') of Unix and Mac.
Both are used to encode the <enter> key.
I tested this on Unix and Mac, but that is the '\n' situation. I would expect '\r' '\n' to be two bytes after each other, so the '\n' would always trigger <enter> but apparently this is not the case (in your case).

You could adapt line 190 of "install dir of"/grblhud/lineinput.py to:

if c == '\n' or c == '\r':

To find out the "install dir of" you can enter:

pip show grblhud

Let me know if that worked, because then I can update the program (I don't use windows systems, so I cannot test this).

Another possibility is to use another virtual machine to run Unix on. This might not have the issue. It might also be possible to configure the keyboard mapping of the virtual system (WSL2 or other).

Regards,
Johannes

@Eloque
Copy link
Author

Eloque commented Jan 16, 2024

I tried it, but it did not work alas.

This is an Ubuntu install on WSL2, so it might not be that windows thing with the CRLF.

@johannesnoordanus
Copy link
Owner

johannesnoordanus commented Jan 18, 2024

Ok, I am a bit surprised. Keyboard remap isn’t an option?
I can give you a patch so you can see what character number it is when you press <enter>?

If you add the following line to "install dir of"/grblhud/unblockedgetch.py" (line 73, just before the return statement),
print(f"bytes: '\\x{c.hex().upper()}'", end = "")
(edit: updated this line!)
you get the hex code(s) of each key you enter. (You can find the install dir as mentioned in my first reply.)

I am very curious what you get when you run grblhud and push <enter>

Regards,
Johannes

P.S. you can also run a direct test on this module by entering:
python "install dir of"/grblhud/unblockedgetch.py
(type anykey - including <enter> - to get the hex code(s) for that key, end with 'z')

P.S.2 I did a test using python 3.12 on linux/arm (Manjaro) and it didn't work fine. See my comment below ...

@johannesnoordanus
Copy link
Owner

I'll make a fix for this problem. Point is that python 3.12.1 has a bug, it returns a 0x0D (CR) code instead a 0x0A (LF) code.
I'll also make a bug report for the python community (foundation).
The fix will handle CR and LF equally and is almost the same as the first patch I supplied:

You can add a class variable at line 33 and change line 191 of "install dir of"/grblhud/lineinput.py to:

LF                  = '\x0A'        # or '\n'


if c == Input.LF or c == Input.CR:
    print(Input.LF, end = '', flush=True) 

This will do the trick.

@johannesnoordanus
Copy link
Owner

johannesnoordanus commented Jan 19, 2024

Created a python bug report for this issue: python/cpython#114328

pip install -U grblhud

This installs version 1.7.8 of grblhud and fixes the <enter> issue.

@johannesnoordanus
Copy link
Owner

Issue is fixed. Python bug will be fixed in a next release: python/cpython#114328

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

No branches or pull requests

2 participants