HalView - view HAL pin values externally in C++

More
17 Feb 2012 15:06 - 18 Aug 2014 23:50 #17760 by ArcEye
Hi

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
Attachments:
Last edit: 18 Aug 2014 23:50 by ArcEye.
The following user(s) said Thank You: bkt

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

More
17 Feb 2012 15:12 #17761 by ArcEye
And here is the zip, forgot that the upload process corrupts .tar.gz packages

File Attachment:

File Name: halview_0.zip
File Size:37 KB
Attachments:

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

More
18 Feb 2012 13:47 #17794 by mhaberler
trying to rebuild.. halview.pro missing?

- Michael

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

More
18 Feb 2012 14:02 - 18 Feb 2012 14:25 #17795 by ArcEye
Hi Michael

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.

File Attachment:

File Name: halview.txt
File Size:0 KB
Attachments:
Last edit: 18 Feb 2012 14:25 by ArcEye.

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

More
18 Feb 2012 16:02 #17798 by mhaberler
btw, I think redis is a good choice - excellent fellow users ;)

groups.google.com/forum/?fromgroups#!topic/redis-db/d4QcWV0p-YM

-m

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

More
12 May 2013 19:35 - 12 May 2013 21:49 #33945 by mariusl
(Edit): Not John - ArcEye - dont know why I called you John. Too many things at one time I guess.

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

Last edit: 12 May 2013 21:49 by mariusl. Reason: Wrong guy

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

More
12 May 2013 21:07 #33948 by ArcEye
Hi

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.

More
12 May 2013 21:35 - 12 May 2013 21:36 #33949 by mariusl
Hi ArcEye
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

Last edit: 12 May 2013 21:36 by mariusl.

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

More
12 May 2013 22:24 #33953 by ArcEye
It installs into /usr/local/lib

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


File Attachment:

File Name: libhiredis.zip
File Size:204 KB
Attachments:

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

More
12 May 2013 23:14 #33958 by mariusl
I just ran ldconfig and that fixed it. I get a box with 6 each bit, s32 and float variables to look at.

Regards
Marius


www.bluearccnc.com

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

Time to create page: 0.117 seconds
Powered by Kunena Forum