Страница 21 из 47

Re: MyGUI

Добавлено: 13 ноя 2012, 14:24
nkp
Nick писал(а):нет.
тогда остается общение через порт
то есть МК пишет в порт - мы скриптом читаем и активируем в скрипте те или иные пины , затем коннектим их в хал
как то выглядит по надежности не совсем "железобетонно"
-------------
а что надо сделать (и можно ли это в принципе?)чтоб было как с джойстиком ??
я же не ставил никаких драйверов - а все в хал "появилось"

Re: MyGUI

Добавлено: 13 ноя 2012, 14:38
nkp
руководствуясь определением:

Код: Выделить всё

hal_input − control HAL pins with any Linux input device, including USB HID devices
то есть совсем "любого"
хочу "увидеть " в хал кнопки мышки юсб :

Код: Выделить всё

loadusr -W hal_input -K  A4Tech USB Mouse
и не работает....
сейчас попробую клавиатуру...

Re: MyGUI

Добавлено: 13 ноя 2012, 15:25
nkp
да и клавиатура что то не завелась
вот описание hal_input:
(для просмотра содержимого нажмите на ссылку)
HAL_INPUT

hal_input − control HAL pins with any Linux input device, including USB HID devices
SYNOPSIS

loadusr hal_input [-KRAL] inputspec ...
DESCRIPTION

hal_input is an interface between HAL and any Linux input device, including USB HID devices. For each device named, hal_input creates pins corresponding to its keys, absolute axes, and LEDs. At a fixed rate of approximately 10ms, it synchronizes the device and the HAL pins.
INPUT SPECIFICATION

The inputspec may be in one of several forms:
A string S

A substring or shell-style pattern match will be tested against the "name" of the device, the "phys" (which gives information about how it is connected), and the "id", which is a string of the form "Bus=... Vendor=... Product=... Version=...". You can view the name, phys, and id of attached devices by executing less /proc/bus/input/devices. Examples:

SpaceBall
"Vendor=001f Product=0001"
serio*/input0

A number N

This opens /dev/input/eventN. Except for devices that are always attached to the system, this number may change over reboots or when the device is removed. For this reason, using an integer is not recommended.

When several devices are identified by the same string, add ":N" where N is the index of the desired device. For example, if Mouse matches input3 and input10, then Mouse and Mouse:0 select input3. Specifying mouse:1 selects input10.

For devices that appear as multiple entries in /dev/input, these indices are likely to stay the same every time. For multiple identical devices, these indices are likely to depend on the insertion order, but stay the same across reboots as long as the devices are not moved to different ports or unplugged while the machine is booted.

If the first character of the inputspec is a "+", then hal_input requests exclusive access to the device. The first device matching an inputspec is used. Any number of inputspecs may be used.

A subset option may preceed each inputspec. The subset option begins with a dash. Each letter in the subset option specifies a device feature to include. Features that are not specified are excluded. For instance, to export keyboard LEDs to HAL without exporting keys, use

hal_input -L keyboard ...
DEVICE FEATURES SUPPORTED

EV_KEY (buttons and keys). Subset -K


EV_ABS (absolute analog inputs). Subset -A


EV_REL (relative analog inputs). Subset -R


EV_LED (LED outputs). Subset -L

HAL PINS AND PARAMETERS

For buttons
input.N.btn-name bit out
input.N.btn-name-not bit out

Created for each button on the device.

For keys
input.N.key-name
input.N.key-name-not

Created for each key on the device.

For absolute axes
input.N.abs-name-counts s32 out
input.N.abs-name-position float out
input.N.abs-name-scale parameter float rw
input.N.abs-name-offset parameter float rw
input.N.abs-name-fuzz parameter s32 rw
input.N.abs-name-flat parameter s32 rw
input.N.abs-name-min parameter s32 r
input.N.abs-name-max parameter s32 r

Created for each absolute axis on the device. Device positions closer than flat to offset are reported as offset in counts, and counts does not change until the device position changes by at least fuzz. The position is computed as position = (counts - offset) / scale. The default value of scale and offset map the range of the axis reported by the operating system to [-1,1]. The default values of fuzz and flat are those reported by the operating system. The values of min and max are those reported by the operating system.

For relative axes
input.N.rel-name-counts s32 out
input.N.rel-name-position float out
input.N.rel-name-reset bit in
input.N.rel-name-scale parameter float rw
input.N.rel-name-absolute parameter s32 rw
input.N.rel-name-precision parameter s32 rw
input.N.rel-name-last parameter s32 rw

Created for each relative axis on the device. As long as reset is true, counts is reset to zero regardless of any past or current axis movement. Otherwise, counts increases or decreases according to the motion of the axis. counts is divided by position-scale to give position. The default value of position is 1. There are some devices, notably scroll wheels, which return signed values with less resolution than 32 bits. The default value of precision is 32. precision can be set to 8 for a device that returns signed 8 bit values, or any other value from 1 to 32. absolute, when set true, ignores duplicate events with the same value. This allows for devices that repeat events without any user action to work correctly. last shows the most recent count value returned by the device, and is used in the implementation of absolute.

For LEDs
input.N.led-name bit out
input.N.led-name-invert parameter bit rw

Created for each LED on the device.
PERMISSIONS AND UDEV

By default, the input devices may not be accessible to regular users--hal_input requires read-write access, even if the device has no outputs. To change the default permission of a device, add a new file to /etc/udev/rules.d to set the device’s GROUP to "plugdev". You can do this for all input devices with this rule:

SUBSYSTEM=="input", MODE="0660", GROUP="plugdev"

You can also make more specific rules for particular devices. For instance, a SpaceBall input device uses the ’spaceball’ kernel module, so a udev entry for it would read:

DRIVER=="spaceball", MODE="0660", GROUP="plugdev"

the next time the device is attached to the system, it will be accessible to the "plugdev" group.

For USB devices, the udev line would refer to the device’s Vendor and Product values, such as

SYSFS{idProduct}=="c00e", SYSFS{idVendor}=="046d", MODE="0660", GROUP="plugdev"

for a particular logictech-brand mouse.

For more information on writing udev rules, see udev(8).
BUGS

The initial state of keys, buttons, and absolute axes are erroneously reported as FALSE or 0 until an event is received for that key, button, or axis.
SEE ALSO

udev(8)
а вот моя клавиатура:
(для просмотра содержимого нажмите на ссылку)

Код: Выделить всё

I: Bus=0003 Vendor=1267 Product=0103 Version=0110
N: Name="HID 1267:0103"
P: Phys=usb-0000:00:1d.1-1/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.1/usb3/3-1/3-1:1.0/input/input12
U: Uniq=
H: Handlers=kbd event4 
B: EV=120013
B: KEY=10000 7 ff800000 7ff febeffdf f3cfffff ffffffff fffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=1267 Product=0103 Version=0110
N: Name="HID 1267:0103"
P: Phys=usb-0000:00:1d.1-1/input1
S: Sysfs=/devices/pci0000:00/0000:00:1d.1/usb3/3-1/3-1:1.1/input/input13
U: Uniq=
H: Handlers=kbd event5 
B: EV=1f
B: KEY=837fff 2c3027 bf004444 0 0 1 c04 a27c000 267bfa d941dfed 9e0000 0 0 0
B: REL=40
B: ABS=1 0
B: MSC=10
может кто подскажет - как правильно прописать это в хал???
так пробовал:

Код: Выделить всё

loadusr -W hal_input -K  HID 1267:0103
ошибка:

Код: Выделить всё

Debug file information:
No input device matching 'HID' was found (1 devices checked)
standard_pinout.hal:80: hal_input exited without becoming ready
6739
  PID TTY      STAT   TIME COMMAND
Stopping realtime threads
Unloading hal components

Re: MyGUI

Добавлено: 13 ноя 2012, 15:30
Nick
а что lsusb пишет?

Re: MyGUI

Добавлено: 13 ноя 2012, 15:35
nkp
Nick писал(а):что lsusb пишет?

Код: Выделить всё

nkp@nkp-desktop:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 005: ID 0458:1004 KYE Systems Corp. (Mouse Systems) Flight2000 F-23 Joystick
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 004: ID 1267:0103 Logic3 / SpectraVideo plc G-720 Keyboard
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 09da:000a A4 Tech Co., Ltd Port Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Re: MyGUI

Добавлено: 13 ноя 2012, 15:44
Serg
Просто мышку с клавиатурой первым зохавало X Window System, а linuxcnc ничего не досталось.
Именно поэтому контроллер клавиатуры со своими кнопками не прокатит - будет просто дубль клавиатуры/мыши.

Re: MyGUI

Добавлено: 13 ноя 2012, 15:48
nkp
можно проверить - емс запустить без иксов
хотя я и так верю :)
а классно бы было с клавой!!!

Re: MyGUI

Добавлено: 13 ноя 2012, 15:56
Nick
О, лучше даже вот это, что говорит:
/proc/bus/input/devices
(или )
less /proc/bus/input/devices и найди там свою мышь.

Re: MyGUI

Добавлено: 13 ноя 2012, 15:58
Serg
В консоли тоже есть кому захватывать. :)
Я упрощённо описал, на самом деле там некий слоёный пирог, но общий смысл в том, что на все устройства, прикидывающиеся клавиатурой система автоматически подключает через драйвер клавиатуры и они рассматриваются как дубли.

Re: MyGUI

Добавлено: 13 ноя 2012, 16:00
Serg
Nick писал(а):О, лучше даже вот это, что говорит:
/proc/bus/input/devices
(или )
less /proc/bus/input/devices и найди там свою мышь.
Да, за эти реально можно зацепиться, но проблема дублей останется.

Re: MyGUI

Добавлено: 13 ноя 2012, 16:10
Nick
А если у нас две мыши включено, то они будут одни и те же ивенты генерить?

Re: MyGUI

Добавлено: 13 ноя 2012, 16:15
nkp
Nick писал(а):less /proc/bus/input/devices и найди там свою мышь.

Код: Выделить всё

I: Bus=0003 Vendor=09da Product=000a Version=0110
N: Name="A4Tech USB Mouse"
P: Phys=usb-0000:00:1d.0-2/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/input/input9
U: Uniq=
H: Handlers=mouse1 event3 
B: EV=17
B: KEY=ff0000 0 0 0 0 0 0 0 0
B: REL=343
B: MSC=10

Re: MyGUI

Добавлено: 13 ноя 2012, 16:22
Nick
попробуй так:
loadusr -W hal_input -K usb-0000:00:1d.0-2/input0
или так:
loadusr -W hal_input -K "usb-0000:00:1d.0-2/input0"

Re: MyGUI

Добавлено: 13 ноя 2012, 16:24
nkp
UAVpilot писал(а):прикидывающиеся клавиатурой система автоматически подключает через драйвер клавиатуры и они рассматриваются как дубли.
а по какому признаку система распознает,что это клавиатура
нельзя ли это обойти ???

Re: MyGUI

Добавлено: 13 ноя 2012, 16:25
nkp
Nick писал(а):loadusr -W hal_input -K usb-0000:00:1d.0-2/input0

Код: Выделить всё

Debug file information:
Traceback (most recent call last):
  File "/usr/bin/hal_input", line 198, in <module>
    d.append(HalInputDevice(w, i, f, parts))
  File "/usr/bin/hal_input", line 54, in __init__
    self.device = linux_event.InputDevice(name)
  File "/usr/lib/pymodules/python2.6/linux_event.py", line 853, in __init__
    self.f = find(pattern)
  File "/usr/lib/pymodules/python2.6/linux_event.py", line 776, in find
    idx = int(idx)
ValueError: invalid literal for int() with base 10: '1d.0-2/input0'
standard_pinout.hal:80: hal_input exited without becoming ready
7376
  PID TTY      STAT   TIME COMMAND
Stopping realtime threads
Unloading hal components
Nick писал(а):loadusr -W hal_input -K "usb-0000:00:1d.0-2/input0"

Код: Выделить всё

Debug file information:
Traceback (most recent call last):
  File "/usr/bin/hal_input", line 198, in <module>
    d.append(HalInputDevice(w, i, f, parts))
  File "/usr/bin/hal_input", line 54, in __init__
    self.device = linux_event.InputDevice(name)
  File "/usr/lib/pymodules/python2.6/linux_event.py", line 853, in __init__
    self.f = find(pattern)
  File "/usr/lib/pymodules/python2.6/linux_event.py", line 776, in find
    idx = int(idx)
ValueError: invalid literal for int() with base 10: '1d.0-2/input0"'
standard_pinout.hal:80: hal_input exited without becoming ready
7587
  PID TTY      STAT   TIME COMMAND
Stopping realtime threads
Unloading hal components

Re: MyGUI

Добавлено: 13 ноя 2012, 17:36
Serg
Nick писал(а):А если у нас две мыши включено, то они будут одни и те же ивенты генерить?
Можно получить эвенты от конкретной клавиатуры в linuxcnc, но проблема в том, что эти же эвенты также получат X'ы и стандартно на них прореагируют.
nkp писал(а):а по какому признаку система распознает,что это клавиатура
нельзя ли это обойти ???
можно конечно, достаточно в клавиатурном чипе перепрошить идентификатор класса и т.п. и написать свой драйвер клавиатуры. :)

Самый простой вариант - это МК и связь через Serial over RS-232/USB/Ethernet/etc.

Re: MyGUI

Добавлено: 13 ноя 2012, 19:30
nkp
С клавиатурой вопрос закрыт!
-----------------------------------------------------------------------------------------------
Тогда последний вопрос из этой обоймы.
в чем различие для hal_input между тем же джойстиком (который мы видим в хал)
и arduino связанного через юсб ??
или поставим вопрос по другому:
что нужно устройству на МК чтоб его входы-выходы можно было увидеть в хал через hal_input (или Hidcomp) ??

Re: MyGUI

Добавлено: 13 ноя 2012, 19:36
Lexxa
Постепенно надо делать. Сначала подвесить мк на компорт, потом привязать мк на юсб просто с эмуляцией компорта типа ftdi232, только без железки а программно

Re: MyGUI

Добавлено: 13 ноя 2012, 19:41
nkp
Lexxa писал(а):Постепенно надо делать. Сначала подвесить мк на компорт, потом привязать мк на юсб просто с эмуляцией компорта типа ftdi232, только без железки а программно
так это я так понял все уже работает http://cnc-club.ru/forum/viewtopic.php? ... 171#p44171

Re: MyGUI

Добавлено: 13 ноя 2012, 19:42
Lexxa