HalView - view HAL pin values externally in C++
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
If you have had to open a watch window and populate it with the pins you want to watch, every single time
that you change some code and restart LinuxCNC, you may appeciate this.
This is just a brief resume of the use of halview to assist in debugging etc with a LinuxCNC configuration.
It assumes a working knowledge of HAL.
Precompiled binaries of halview, redisclient and test are in the zip package,
compiled against the standard rtai kernel for the Ubuntu 10.4 /LinucCNC 2.4.3 package
so most of you will be able to just use these binaries.
It relies upon QT3, and those libraries must be installed, plus the development files if building yourself.
halview was written to assist debugging a component for LinuxCNC.
It provides a means of monitoring pin values independently of the rtai system, ie the monitoring program
is independent of LinuxCNC and is unaffected by stopping and re-starting LinuxCNC.
It comes in 5 parts
1) redis is a key database daemon launched at startup of the OS which stores values by keys.
This needs to be installed, see redis.io/download
2) hiredis is a C library which provides the calling functions to set and get values from redis
download from github.com/antirez/hiredis compile and install the libraries
3) redisclient is a Userspace component which provides 6 bit value pins (B0 - B5), 6 s32 (long int) value pins (D0 - D5) and 6 floating point value pins (F0 - F5) which can be net(ted) to existing signals and unattached OUT pins that you wish to monitor.
Additional pins can be written in, the code is quite straight forward, the keys are put into arrays and refreshed in a for() loop, so very few amendments would be required.
Example of use in .hal file :-
loadusr -W redisclient
# attaching redisclient - these are all signal names from the hal file in which included
net tool-change => redisclient.B0
net tool-changed => redisclient.B1
net tool-number => redisclient.D0
net tool-oldnumber => redisclient.D1
net xhomed => redisclient.B2
net zhomed => redisclient.B3
net delaystart => redisclient.B4
net delaydone => redisclient.B5
net ontool => => redisclient.D2
redisclient will update the values of all 18 pins once per second, frequency could be changed in the code.
The pin values will be stored in redis, under the keys B0 - B5, D0 - D5, F0 - F5.
4) halview is a QT3 based gui which queries redis for these key values, either once per second,
or in manual mode every time the refresh button is displayed and displays them.
It has text edit boxes alongside each key for an identifying user entry as to which pin /signal it refers to.
Once halview is opened, it can be left running for the entire session and just switched to 'manual' whenever redisclient is not loaded
and therefore no updates are happening.
5) test binary will populate all the pin values to facilitate the initial testing of halview.
As a spin off, the code demonstrates a method of getting values from HAL and making them available to external programs, using the redis database and hiredis C libraries.
If it is of use to anyone - enjoy
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
Please Log in or Create an account to join the conversation.
- mhaberler
- Offline
- Moderator
- Posts: 197
- Thank you received: 11
- Michael
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
Sorry, I have everything in scripts that auto generate, forgot that one
Attached, strip the .txt off after download and rename .pro
regards
PS Be aware that if you use the .ui to generate .cpp and .h files they will not match those provided because I don't like the way
they are set out and use a different method, just cutting and pasting the major graphical layout changes.
Please Log in or Create an account to join the conversation.
- mhaberler
- Offline
- Moderator
- Posts: 197
- Thank you received: 11
groups.google.com/forum/?fromgroups#!topic/redis-db/d4QcWV0p-YM
-m
Please Log in or Create an account to join the conversation.
- mariusl
- Offline
- Platinum Member
I am trying to get this example to work for me as I think it is a great idea. I installed the qt3 package with "sudo apt-get install qt3-dev-tools" but get an error when I want to compile Halview. I seem to not have the right stuff.
This is the error
make: *** No rule to make target `/usr/share/qt3/lib/libqt-mt.prl', needed by `Makefile'. Stop.
This is what I have in that directory.
drwxr-xr-x 2 root root 4096 2013-05-12 14:27 ./
drwxr-xr-x 6 root root 4096 2013-05-12 14:27 ../
lrwxrwxrwx 1 root root 30 2013-05-12 14:27 libqt-mt.so.3 -> ../../../lib/libqt-mt.so.3.3.8
lrwxrwxrwx 1 root root 30 2013-05-12 14:27 libqt-mt.so.3.3 -> ../../../lib/libqt-mt.so.3.3.8
lrwxrwxrwx 1 root root 28 2013-05-12 14:27 libqui.so.1 -> ../../../lib/libqui.so.1.0.0
lrwxrwxrwx 1 root root 28 2013-05-12 14:27 libqui.so.1.0 -> ../../../lib/libqui.so.1.0.0
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
I installed the qt3 package with "sudo apt-get install qt3-dev-tools" but get an error when I want to compile Halview. I seem to not have the right stuff.
I built my Qt3 from sources, so not quite sure about the Ubuntu packages
I should just go into Synaptic, put libqt3 in the search box and then check if below are already installed
libqt3-mt-dev
libqt3-mt
libqt3-headers
That will check you have everything you need
libqt-mt.prl is a qmake file with build environment variables like paths and CFLAGS etc
You will need to download the .pro file then generate your own Makefile using qmake, because my paths will not match yours.
Alternatively, there is a binary in the .zip, does that not work?
regards
Please Log in or Create an account to join the conversation.
- mariusl
- Offline
- Platinum Member
I tried the binary and got this error.
./halview: error while loading shared libraries: libhiredis.so.0.10: cannot open shared object file: No such file or directory
I followed the instructions for the redis server and that works. Then I downloaded the zip containing the hiredis source and compiled with "make" and "make install"
Should I have done something more?
P.S. The synaptic thing is a mess of dependencies that will not be installed.
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
- Posts: 25
- Thank you received: 761
That needs to be in LD_LIBRARY_PATH and you need to run ldconfig.
I have a symlink in /usr/lib to the libraries in /usr/local/lib but I can't remember if I did that myself or it was part of the install, probably the former.
In case you don't have the libs for some reason I have attached them (built against 10.04)
regards
Please Log in or Create an account to join the conversation.
- mariusl
- Offline
- Platinum Member
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.