Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
Hi all,
I wonder how to manage an USB keyboard (or similar like a barcode scanner) with the DNS323...
What i want to do is to launch a script with what i type on the keyboard as parameter for example.
(for example if i type test[enter] i want to launch the command ./myscript test)
Do you see a way to do this ?
Thanks in advance.
Offline
Nobody have ANY idea to do that ?
Thanks.
Offline
Well - for starters, you're going to need to compile the appropriate HID (human interface device) driver for the processor and load it, and seeing as there's no display ...
Understand this - the possibilities are limited only by your capabilities - however, there is a point of what is known as "diminishing returns", when it would just be simpler to start with standard PC and do what you need.
Offline
Actually, I could see some value in this since it would provide an easy way to add additional buttons to the NAS.
It would have some serious potential if combined with say a USB display device (say a usb picture frame) or a Mimo usb monitor.
I could also see it being useful in things like reloaded fun plug scripts, say have the script terminate if the user is holding down a key on the keyboard (would be handy for a hanging reloaded script)
Offline
Personally I see little value in it (actually, none). You can telnet/ssh into the unit and perform any action and even see what you are typing and the responses. I purchased these units since I specifically wanted a headless device, low power consumption, small space etc. The last thing I want is another keyboard (larger than the unit itself). Everything I need to script is done and I rarely telnet in any more. I have 2xDNS-323 units and 3 full Linux servers. None have mice, keyboards or monitors. I can telnet in from a PC, my smartphone or a number of other devices locally wired, wireless or remote.
Last edited by FunFiler (2011-03-07 23:27:24)
Offline
Actually I have connected a keyboard to my NAS. (Only the PCB, btw). I use it as a cheap IO device. The leds are exchanged by optocouplers, and so I can 3 external devices by toggling the keyboard leds. I suppose it's also possible to use it as IO input, by shorting one or more of the keyboard matrix lines, but I never tried.
Offline
fordem wrote:
you're going to need to compile the appropriate HID (human interface device) driver for the processor and load it
Thanks for the advice, any good links to start with this ?
FunFiler wrote:
Personally I see little value in it (actually, none).
Think about a barcode scanner for example : you just scan something and the NAS will do what you want (to manage your books for example) You don't need any display or thing like that (you can maybe let the front leds blink to inform the user that the action was successful)
Mijzelf wrote:
Actually I have connected a keyboard to my NAS. (Only the PCB, btw).
Nice job ! How exactly did you do that ?
Thanks for your responses ![]()
Offline
psyko57 wrote:
How exactly did you do that ?
First, I didn't do it on a DNS-323, but on a ZyXEL NSA-220. Same SoC, other box. As fordem said, you need to compile the appropriate HID driver, usbhid.ko in this case, and maybe some dependencies. Load it, plugin the keyboard, and the keyboard is found as /dev/tty0.
I use setleds to toggle the leds:
setleds -L +num </dev/tty0 sleep 2 setleds -L -num </dev/tty0
Although I didn't try I suppose you can read the keystrokes with
cat /dev/tty0
But a problem could be that this stream won't end, so you can't do
CMD=` cat /dev/tty0 `
in your script. You'll need a readln functionality. Don't know if there is a standard script tool for it.
Offline
Mijzelf wrote:
you need to compile the appropriate HID driver, usbhid.ko in this case, and maybe some dependencies.
Thanks, but can you give me more hint on how to do this ?
Thanks a lot.
Offline
I have no experience in compiling kernel modules for a 323. I *think* you need to build a cross compiling environment first. Or at least you need the same compiler as mentioned in
cat /proc/version
and the kernelsources.
But maybe you can just use the module here.
Offline
I'm using the reloaded method to run debian squeeze with the debian kernel and kernel modules (I don't want to overwrite the dlink firmware since I don't have a serial console)
The debian kernel module package does have most of the normal kernel modules (88 total) including the usbhid module. I imagine it's about the same amount of work to get a reloaded debian environment working as it is to get the toolchain and build the modules for the dlink kernel (assuming the modules don't require a kernel setting that dlink didn't enable).
Offline
I've tried to load the plugin, but i can't "cat /dev/tty0"...
I'm searching other solutions...
If you have any ideas...
Offline
psyko57 wrote:
I've tried to load the plugin, but i can't "cat /dev/tty0"...
Did it load? What did dmesg say when you plugged in the keyboard?
Offline
dmesg wrote:
usb 1-1: new low speed USB device using ehci_platform and address 4
input: USB HID v1.10 Keyboard [USB-TMU-V1] on usb-ehci_platform.20865-1
I seems to be ok for me...
Offline
Hm. Mine says:
usb 2-1: new low speed USB device using ehci_platform and address 7 usb 2-1: configuration #1 chosen from 1 choice input: USB Keyboard as /class/input/input0 input: USB HID v1.10 Keyboard [ USB Keyboard] on usb-ehci_platform.16781-1 input: USB Keyboard as /class/input/input1 input: USB HID v1.10 Device [ USB Keyboard] on usb-ehci_platform.16781-1
So it's recognized as a keyboard *and* as a device. Don't know what that means, though.
About cat /dev/tty0; do you have that node? On my system it's
crw-rw---- 1 root root 4, 0 2011-02-20 14:14 /dev/tty0
Further it's not world readable (unless you change that), so it can only be 'cat'ed by root.
When you 'cat' it, you only see the output when you press enter,
Offline
Yes i have tty0, with the same rights than yours...
I've tried to cat with root user but nothing appears...
Offline
Try to load usbkbd.ko
Offline
If i just load usbkbd i have this :
dmesg wrote:
usb 1-1: new low speed USB device using ehci_platform and address 6
input: USB-TMU-V1 on usb-ehci_platform.20865-1
If i load both (usbkbd & usbhid) I have have the same message than the first time (post #14)
(In both cases, cat /dev/tty0 don't display anything...)
I've tried to do 'echo plop > /dev/tty0' but even with this, 'cat /dev/tty0' don't display anything... Is it normal ? Maybe we just can't 'cat' a tty ?
Thnaks a lot for your help ![]()
Offline
psyko57 wrote:
I've tried to do 'echo plop > /dev/tty0' but even with this, 'cat /dev/tty0' don't display anything...
(Plop?) That is normal, A 'tty' is sort of a terminal. So 'echo plop >/dev/tty0' displays plop on the monitor assigned to that tty, while reading gives the input of the keyboard, and maybe even of the mouse.
Maybe we just can't 'cat' a tty ?
I can. But it's a different box and a different kernel, and I don't know which differences are important.
Some googling on 'keyboard embedded linux' led me to SamyGO, some TV hacking project, and it gave me this script:
MouseAndKeyboard.sh:
#!/bin/sh
cd $1
# Load keyboard and mouse support
insmod ./modules/usbhid.ko
insmod ./modules/evdev.ko
# Generate input device nodes at /dtv
i=0
while [ $i -le 31 ]
do
mknod /dtv/event$i c 13 $(($i + 64))
i=$(( i + 1 ))
doneI think /dtv can be translated to /dev in our case. But I must admit that there are no /dev/eventx on my box.
I un- and reconnected the keyboard, and udev made this modifications. In /dev:
crw-rw---- 1 root root 442, 2057 2011-03-13 19:34 usbdev2.10_ep00
crw-rw---- 1 root root 442, 2057 2011-03-13 19:34 usbdev2.10_ep81
crw-rw---- 1 root root 442, 2057 2011-03-13 19:34 usbdev2.10_ep82
drwxr-xr-x 2 root root 2800 2011-03-13 19:34 char
crw-rw-rw- 1 root root 5, 2 2011-03-13 19:35 ptmx
in /dev/char:
lrwxrwxrwx 1 root root 18 2011-03-13 19:34 442:2057 -> ../usbdev2.10_ep82
lrwxrwxrwx 1 root root 18 2011-03-13 19:34 189:137 -> ../bus/usb/002/010
And this 189:137 points to:
crw-rw-r-- 1 root root 189, 137 2011-03-13 19:34 010
It's not clear to me what this all means.
Offline