Hallo zusammen,
ich habe einen kleinen alix-Server, auf den ich per ssh zugreife. Auf diesem möchte ich bestimmte Funktionen ausführen, sobald am USB-Nummernblock (angeschlossen am usb-Port des Servers) eine bestimmte Taste gedrückt wird. Mein zugehöriges Python Script funktioniert auf meinem PC, auf dem Server reagiert es jedoch nicht auf die Eingaben am Nummernblock.
Woran mag das liegen?
Der USB-Nummernblock wird auf dem Server ordnungsgemäß erkannt: lsusb
1 | CodeBus 002 Device 002: ID 0a81:0101 Chesen Electronics Corp. Keyboard |
cat /proc/bus/input/devices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | CodeI: Bus=0003 Vendor=0a81 Product=0101 Version=0110 N: Name="CHESEN USB Keyboard" P: Phys=usb-0000:00:0f.4-3/input0 S: Sysfs=/devices/pci0000:00/0000:00:0f.4/usb2/2-3/2-3:1.0/input/input5 U: Uniq= H: Handlers=kbd event5 B: EV=120013 B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=1f I: Bus=0003 Vendor=0a81 Product=0101 Version=0110 N: Name="CHESEN USB Keyboard" P: Phys=usb-0000:00:0f.4-3/input1 S: Sysfs=/devices/pci0000:00/0000:00:0f.4/usb2/2-3/2-3:1.1/input/input6 U: Uniq= H: Handlers=kbd event6 B: EV=13 B: KEY=2020000 3878 d801d001 1e0000 0 0 0 B: MSC=10 |
Hier mein Python-Programm:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/usr/bin/env python # -*- coding: utf-8 -*- import sys, select, termios, tty,datetime class mylocontrol(object): def __init__(self): self.checkkeys() def showcontent(self,content): if content == "1": print ("Menue") elif content == "2": print ("Termine") elif content == "3": print ("Wetter") def getkey(self): old_settings = termios.tcgetattr(sys.stdin) tty.setraw(sys.stdin.fileno()) select.select([sys.stdin], [], [], 0) answer = sys.stdin.read(1) termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings) return answer def checkkeys(self): while True: answer=self.getkey() if "9" in answer: break else: ret = self.showcontent(answer) mylo = mylocontrol() |