Question about keyboard for cnc build

More
5 years 7 months ago #202067 by robertspark
I have a spare idc port on the 7i92h which is just setup as I/o at present..... (1x7i76 card bit file uploaded) however is it possible to connect to both a 7i76e and 7i92 at the same time?

they both have their own IP addresses and are both on their own ethernet ports as the pc has 2x ethernet ports and 6x rs232 UART ports (all disabled in the bios but I can liven one up as they made no difference to latency), which was plan B....... plan a was to use a usb to rs232 db25M converter as plan A

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #202174 by andypugh

robertspark wrote:

andypugh wrote: You could connect the serial port to a Mesa UART. That would keep the data in the realtime layer.


that sounds interesting, how would I go about doing that?

I ask because I am using 1x7i76e


I think that there is probably a firmware that sets up the 7i76E smart-serial port as a UART.

You would then need your Arduino, or similar, to scan the matrix and output scan-codes (key-up and key-down) which would be read by the UART, twiddled by a simple driver .comp and output on a HAL pin for use by sendkeys or matrix_kb.

You are right, by the way, the 7i73 handles a max matrix size of 8 x 8. You could (possibly) handle an 8x14 with _two_ 7i73s, but that gets expensive.
It is getting a bit much for an Arduino, even. You would need to use a Mega to have enough pins.
The following user(s) said Thank You: robertspark

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #202196 by robertspark
there is also the keywarrior

www.codemercs.com/en/io/28-keywarrior

which provides software to programs each of the inputs

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago - 5 years 7 months ago #202273 by robertspark
python script to read the keyboard codes and convert to integers {probably better for switch case later}

save as foo.py

and run in terminal as
Code:
python foo.py
Code:
import serial ser = serial.Serial( port='/dev/ttyS2',\ baudrate=9600,\ parity=serial.PARITY_NONE,\ stopbits=serial.STOPBITS_ONE,\ bytesize=serial.EIGHTBITS,\ timeout=0) while True: for line in ser.read(): print(ord(line) ) ser.close()

(I know little about python.... but am learning slowly)

keyboard codes start bottom LHS as 0x00 (keypress) and 0x80 (release) and
end top RHS as 0x6F (keypress) and 0xEF (release)

.... ie... go from 00 >> 111 for key press (as DEC / INT) and
from128 >>> 239 for release


note: you would need to change your port to whatever you have it plugged in as (I am using good old serial ports, but it is possible to use a USB adapter too)
Code:
sudo dmesg | grep tty
Last edit: 5 years 7 months ago by robertspark.

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago #202536 by andypugh
matrix_kb and sendkeys expect 0x80 + code for Key Up and 0x40 + code for key down. So the key-up is a match, but key-down won't fit.

The 7i73 also sends 0x00 as an "all up" and 0x40 as "nothing".

You could manipulate the codes inside your Python to suit, but you might as well just make the Python send keys and set HAL pins.

See here for how to set up HAL pins in Python code:
linuxcnc.org/docs/2.8/html/hal/halmodule.html

Note that setting HAL pins with set_p etc is documented there, but the component really should create its own pins and manipulate them using the h = value method.

Please Log in or Create an account to join the conversation.

More
5 years 7 months ago - 5 years 7 months ago #202541 by robertspark
thanks Andy, I can create the pins (all 112) no problem and change their status from true to false.

I can link them to other hal pins.

however, what I am struggling to figure out is how to create a component that simulates a keypress

I've been looking at many options but all I am looking for is simple means to input keypresses into the MDI..... no mouse movement.... just be able to type a G/M/etc.... or maybe G00/G01 etc

I know that there are methods / functions / libraries / programmes such as
xdotool
pynput.py
keyboard.py
I am ok to load / install them and use them but I was wondering if there is a built in bash tool or python library that is installed as a default setup as part of the linuxcnc.iso.....

I don't like to add files that are not necessary if there is something inbuilt
Last edit: 5 years 7 months ago by robertspark.

Please Log in or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum