Emulating scroll lock for kvm switch on the NSLU2
I wish to share a USB device between two NSLU2's. They're at a remote
site and the idea is that if the NSLU2 connected to the USB device
crashes/dies, the other will take over the device and continue
operations. That would save me from a 300 km drive if the main NSLU2
crashes hard.
So I got a KVM switch which does what I wish. It can be connected to
two computers and it's possible to grab control of the USB device by
hitting scroll lock twice. So I wrote a program to hit scroll lock
twice for me, which I can run from command line:
#include <fcntl.h>
#include <stdio.h>
#include <linux/input.h>
int main(int argc, char** argv) {
int i, fd;
struct input_event event;
fd = open("/dev/input/by-id/usb-Tangtop_USB2.0_DATA_SWITCH_9008151-event-kbd", O_RDWR);
if (!fd)
return 2;
event.type = EV_KEY;
event.code = KEY_SCROLLLOCK;
for (i = 3; i >= 0; i--) {
event.value = i & 1;
write(fd, &event, sizeof(event));
usleep(100000);
}
return 0;
}
This works on my x86 PC, but not on my NSLU2 running lenny. The
switch is recognised and /dev/input is populated correctly, it seems.
Does anyone know why it still doesn't work? Is what I'm trying at all
possible?
--
Steinar ; NIL DIFFICILE VOLENTI ; http://latinitas.org ; http://voksenlia.net
Reply to: