Pokeys

More
05 Apr 2020 12:50 #162765 by andypugh
> -I/usr/include/libusb-1.0

Do you have libusb-dev installed?

> -I/usr/realtime-3.4-9-rtai-686-pae/include

You won't have this. Mint will be 4.14.nnn and you may not have the rtai realtime kernel at all.
What does uname -a tell you?

> -I/usr/realtime-3.4-9-rtai-686-pae/include

Again, this needs to match a folder that actually exists.

> -I/usr/include/i386-linux-gnu

You probably have a 64-bit kernel, so i386 is likely to be wrong

You might have more luck using

sudo halcompile --install pokeys.comp

That should sort out some (but not all) of the issues pointed to above (and will eliminate the need for the manual compilation stage)
You can then try adding in includes, compiler arguments and linker arguments in to the .comp file from the list above to try to make it work...

There are (at least) three things that are available in .comp that for some reason are not documented....

include - like a #include after the ;;, but puts the /#include statement at the top of the generated C file.

option extra_compile_args "some arguments";
option extra_link_args "some arguments";

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

More
05 Apr 2020 13:36 - 05 Apr 2020 13:54 #162767 by KRAD-AT

> -I/usr/include/libusb-1.0

Do you have libusb-dev installed?

> -I/usr/realtime-3.4-9-rtai-686-pae/include

You won't have this. Mint will be 4.14.nnn and you may not have the rtai realtime kernel at all.
What does uname -a tell you?

> -I/usr/realtime-3.4-9-rtai-686-pae/include

Again, this needs to match a folder that actually exists.

> -I/usr/include/i386-linux-gnu

You probably have a 64-bit kernel, so i386 is likely to be wrong

You might have more luck using

sudo halcompile --install pokeys.comp

That should sort out some (but not all) of the issues pointed to above (and will eliminate the need for the manual compilation stage)
You can then try adding in includes, compiler arguments and linker arguments in to the .comp file from the list above to try to make it work...

There are (at least) three things that are available in .comp that for some reason are not documented....

include - like a #include after the ;;, but puts the /#include statement at the top of the generated C file.

option extra_compile_args "some arguments";
option extra_link_args "some arguments";


Thank you for your fast response!

I have installed libusb-1.0.

Uname -a says: Linux cnc 4.16.12-rt5-kona-rt #1 SMP PREEMPT RT Fri Jun 8 10:39:47 JST 2018 x86_64 x86_64 x86_64 GNU/Linux

"> -I/usr/realtime-3.4-9-rtai-686-pae/include"
I have this folder, is this the right one? /usr/src/linux-headers-4.16.12-rt5-kona-rt/include

"> -I/usr/include/i386-linux-gnu"
Maybe this is the right one? /usr/include/x86_64-linux-gnu

But what does this whole block of commands anyway? The halcompile command seem to have worked. I got a file called pokeys.c

Thank you for your help!
Last edit: 05 Apr 2020 13:54 by KRAD-AT.

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

More
05 Apr 2020 14:14 #162770 by KRAD-AT
I understand at the moment that the halcompile made a file called pokeys.c which has to be compiled again with the gcc command.
Am I right so far?

And in this compiling procedure some errors occur.
I tried this compiling command:
gcc -Wall  -Os -g -I. -I/usr/include/libusb-1.0 -I/usr/include -L/usr/lib/ -L/usr/lib/arm-linux-gnueabihf/ -lPoKeys -lusb-1.0 -I/usr/src/linux-headers-4.16.12-rt5-kona-rt/include -I. -I/usr/src/linux-headers-4.16.12-rt5-kona-rt/include -I/usr/include/x86_64-linux-gnu -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-math-errno -funsafe-math-optimizations -fno-rounding-math -fno-signaling-nans -fcx-limited-range -mhard-float -DRTAI=3 -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -Wframe-larger-than=2560 -URTAPI -U__MODULE__ -DULAPI -Os  -o pokeys ./pokeys.c -Wl,-rpath,/lib -L/lib -llinuxcnchal
But the errors stayed the same.
Most of them seem to be undefined variables in the code of pokeys.c

Where should they be defined? Is there a problem with the pokeys library?

Isn't there an easier way to get this stuff running?

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

More
05 Apr 2020 14:39 #162776 by andypugh

I understand at the moment that the halcompile made a file called pokeys.c which has to be compiled again with the gcc command.
Am I right so far?


That is one option with halcompile.
linuxcnc.org/docs/2.7/html/hal/comp.html

Typically you use the --install option and halcompile does everything.

But, this is a HAL component that relies on an external library. That generally causes trouble and the original poster worked round that by using halcompile to preprocess and then compiling "by hand"

But, the set of compile options listed are likely to be very specific to the system that the original poster was compiling on.

Most of them seem to be undefined variables in the code of pokeys.c. Where should they be defined? Is there a problem with the pokeys library?


My suspicion is that the compiler isn't finding the pokeys library at all.

This is why I suggested trying to do the whole thing with halcompile (which should automatically get _most_ of the compiler options right) and add in the things that it needs, like the pokeys library.

Can you see the pokeys library in /usr/include? Does it contain definitions of the missing things?

As a first step try adding
include pokeys.h;
in the pokeys.comp file somewhere before the ;; separator. (after changing pokeys.h to the _actual_ name of the header file that you found)
Then try
halcompile --compile pokeys.comp
and see that the error messages are.

Isn't there an easier way to get this stuff running?

Pokeys is not officially supported in LinuxCNC in any way. The strength of Open Source is that you can do almost anything. The weakness is that some of the things you can do are quite difficult.

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

More
05 Apr 2020 15:18 #162779 by KRAD-AT
I found the library in the folder /usr/include.
Then i added "include "PoKeysLib.h"" before the separator.
Then I tried it again:

cnc@cnc:~/projects$ sudo halcompile --compile pokeys.comp
pokeys.comp:15:1: Trying to find one of ";"
> component pokeys "PoKeys IO driver, by Mit Zot";
> ^
while parsing Declaration():
> include "PoKeysLib.h"
> ^
while parsing File():
> include "PoKeysLib.h"
> ^

and got a new file pokeys.c

I don't know what parsing in Linux means. Am I on the right way?

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

More
05 Apr 2020 15:36 #162781 by andypugh
You need a ; at the end of the include line.

(as is documented in the halcompile documentation)

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

More
05 Apr 2020 20:34 #162794 by KRAD-AT
Thank you,

I tried it again.
cnc@cnc:~/projects$ sudo halcompile --compile pokeys.comp
gcc -Os -g -I. -I/build/linuxcnc-2.9.0~pre0.1350.gb0a0416d3/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/usr/include/linuxcnc -Wframe-larger-than=2560 -DSIM -fPIC -URTAPI -U__MODULE__ -DULAPI -Os  -o pokeys /tmp/tmpUe9hf9/pokeys.c -Wl,-rpath,/lib -L/lib -llinuxcnchal 
/tmp/ccOrG51x.o: In Funktion »user_mainloop«:
/tmp/tmpUe9hf9/pokeys.comp:28: Warnung: undefinierter Verweis auf »PK_ConnectToDeviceWSerial«
/tmp/tmpUe9hf9/pokeys.comp:32: Warnung: undefinierter Verweis auf »PK_DigitalIOGet«
/tmp/tmpUe9hf9/pokeys.comp:32: Warnung: undefinierter Verweis auf »PK_AnalogIOGet«
/tmp/tmpUe9hf9/pokeys.comp:38: Warnung: undefinierter Verweis auf »PK_DisconnectDevice«
collect2: error: ld returned 1 exit status
Makefile:2: recipe for target 'pokeys' failed
make: *** [pokeys] Error 1

This is all I get.

As far as I found out there must be a problem with the linking of the library.
But I don't know how to solve this.

Maybe someone has an Idea.

Thank you.

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

More
05 Apr 2020 23:01 #162817 by tommylight
On the second picture you have mv ./pokeys ..............
it can not have a dot in front of /

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

More
06 Apr 2020 18:34 - 06 Apr 2020 18:39 #162951 by andypugh
Replied by andypugh on topic PoKeys HAL Driver
In trying to test this for myself I found that the latest version of LinuxCNC had lost the ability to compile userspace components with halcompile, and it took some time to track down the problem.

Anyway, I think I have a solution to your problem.

Edit the pokeys.comp file to look like this
pin out bit in-# [55];
pin out unsigned ain-# [3];
pin out bit err;
pin in unsigned devSerial;
pin out bit alive;

license "GPL";

option extra_link_args "-lPoKeys";

;;

#include <unistd.h>   /* UNIX standard function definitions */
#include "PoKeysLib.h"

sPoKeysDevice * dev=0;
int i=0;

Note the new "option extra_link_args" line.
(and, to be clear, that's a minus and lower-case L)

Then you should be able to compile and install in one step:
sudo halcompile --install pokeys.comp
Last edit: 06 Apr 2020 18:39 by andypugh.

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

More
06 Apr 2020 18:52 - 06 Apr 2020 18:53 #162953 by andypugh
Replied by andypugh on topic PoKeys HAL Driver
Updated Install Instructions

This driver uses the PoKeys driver from here . It scans at about 15hz, fast enough for UI keys and knobs. I had problems with hidcomp, taking too much resources on my rather slow computer i use for my mill, so I wrote that. With this, i dont get any significant slow down on performance and key presses get detected 100%.
It needs device serial pin to be set in HAL file with proper value.
Set your IO pin function with standard windows software that comes with the board.

1) Install dependencies
sudo apt-get install git build-essential libusb-1.0-0 libusb-1.0-0-dev
2) Download the code to a git repository
git clone https://bitbucket.org/mbosnak/pokeyslib.git
3) Compile and install the driver
cd pokeyslib
sudo make -f Makefile.noqmake install
4) Create the LinuxCNC HAL driver, Download the pokeys.comp file attached to this post then compile and install with halcompile.
sudo halcompile --install pokeys.comp
5) To enable RW permission for USB device, you also need to set "udev" rules in linux:
Create a new file in the
/etc/udev/rules.d
named
90-usb-pokeys.rules
with the following contents:
SUBSYSTEM=="usb", ATTRS{idVendor}=="1dc3", ATTRS{idProduct}=="1001", GROUP="plugdev", MODE="664"
Save the file, then execute
udevadm control --reload-rules

And that is it, now you can include the driver in your hal file with:
loadusr pokeys
and after you set yours board serial with:
setp pokeys.0.devSerial 12345
pokeys.0.err should become False and pokeys.0.alive start blinking with approx 10hz.
Attachments:
Last edit: 06 Apr 2020 18:53 by andypugh.
The following user(s) said Thank You: Maik, LAUSCH

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

Time to create page: 0.105 seconds
Powered by Kunena Forum