Getting Halcompile to work

More
01 Sep 2016 19:56 #79868 by jwsigler
I have linuxcnc running, but I need to develop some custom hal components for the more special functions on my mill. I am running Linuxcnc/Axis 2.7.6-14 and I can control some of the functionality on my mesa 7i77 board. I also am using the 3.18.13 rt10mah realtime kernel. I do notice in Synaptic that I don't have the package linuxcnc-dev available. I only have linuxcnc-uspace-dev, but when I installed the linuxcnc-uspace-dev package I did get halcompile appearing in the usr/bin folder.

I crate a very simple hal component, but could not get it to compile. One of the other forum member tried compiling my basic program and it worked, so obviously I am doing something wrong when I try to compile. The name of the component and the filename are exactly the same, except that the file name ends with ".comp". When I try to compile I get the error messages of:

john@tree325 ~ $ sudo halcompile --install Drawbar2.comp
Traceback (most recent call last):
File "/usr/bin/halcompile", line 1353, in <module>
main()
File "/usr/bin/halcompile", line 1322, in main
process(f, mode, outfile)
File "/usr/bin/halcompile", line 1192, in process
a, b = parse(filename)
File "/usr/bin/halcompile", line 417, in parse
a, b = f.split("\n;;\n", 1)
ValueError: need more than 1 value to unpack

Since several of the error lines deal with outfile and filename, I am wondering if my problem is that I am not putting my comp file in the correct directory prior to compiling. As I said, halcompile is in the usr/bin folder. I have placde my comp file in the top level folder for my user account which is /home/john/, but I am thinking this is probably not correct even if I fully specify the filename in the halcompile command. I know what I want, and what I need to do in the component file itself, I just need to figure out how to compile these component files. It is like being stuck on the "hello world" program for C.

Any assistance would be greatly appreciated. Thanks.

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

More
01 Sep 2016 20:16 #79873 by tommylight
Just as a precaution, do not use spaces in folder names. I know i had some trouble a while ago because of that.

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

More
01 Sep 2016 20:59 #79878 by emcPT
Replied by emcPT on topic Getting Halcompile to work
When I compile your code I had it on "configs/your_config_folder" folder, and yes ending in .comp

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

More
01 Sep 2016 23:46 - 01 Sep 2016 23:50 #79887 by jwsigler
Replied by jwsigler on topic Getting Halcompile to work
All right I finally was able to solve my problem.
If you are trying to compile a hal component using halcompile and you are getting errors like the following:

Traceback (most recent call last):
File "/usr/bin/halcompile", line 1353, in <module>
main()
File "/usr/bin/halcompile", line 1322, in main
process(f, mode, outfile)
File "/usr/bin/halcompile", line 1192, in process
a, b = parse(filename)
File "/usr/bin/halcompile", line 417, in parse
a, b = f.split("\n;;\n", 1)
ValueError: need more than 1 value to unpack

There is a good chance that the problem is because the original Hal component file was created on a windows system. When I initially created my Hal file, I used Microsoft Visual Studio just like I would to create a standard C program. Apparently Windows and Linux use different control characters within their files for things like the carriage return at the end of a line and possibly other things. It appears that HalCompile does not like the windows version of these hidden characters.

To fix my problem, I took my original hal component file and retyped it in on my linux machine using the linux text editor and the file compiled just fine.
Last edit: 01 Sep 2016 23:50 by jwsigler.

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

More
02 Sep 2016 20:23 #79930 by andypugh
Replied by andypugh on topic Getting Halcompile to work

To fix my problem, I took my original hal component file and retyped it in on my linux machine using the linux text editor and the file compiled just fine.


Yikes!

Easier ways include asking Notepad++ (Windows) to fix it for you,
I think edit may also be able to do it. If nit, a copy/replace can be used.

No help to you, but at least the error is less cryptic now:
github.com/LinuxCNC/linuxcnc/commit/f13a...df78d0ef02cd04740000

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

More
04 Sep 2016 06:23 #79998 by jwsigler
Replied by jwsigler on topic Getting Halcompile to work
If people like to use a Windows based system to create their HAL component files, I have found that WordPad can be used to create Hal Component files. The only thing one needs to do is when saving the WordPad file, one needs to select save as an unformatted text file and in the final save as window, select the option to end each line with a single LF, instead of the CR-LF which is the default Windows approach.

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

More
04 Sep 2016 18:55 #80026 by andypugh
Replied by andypugh on topic Getting Halcompile to work

If people like to use a Windows based system to create their HAL component files, I have found that WordPad can be used to create Hal Component files.


Notepad++ is probably a better bet, it does syntax highlighting and other nice things.

Ithe sooner they release the Linux version the better :-)

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

More
04 Sep 2016 19:56 #80028 by jtc
Replied by jtc on topic Getting Halcompile to work

If people like to use a Windows based system to create their HAL component files, I have found that WordPad can be used to create Hal Component files.


Notepad++ is probably a better bet, it does syntax highlighting and other nice things.

Ithe sooner they release the Linux version the better :-)


I use it on Linux, emulated with wine.

For me is one of the first things to do when installs Linux :)

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

More
17 Feb 2024 04:53 #293578 by MFairleaf
I had this same error message but for different reasons. I don't think your problem was line endings. It is possible that when you retyped the file you fixed one or more syntax errors.

In my case I had forgotten to put the double semi-colon at the start of my custom component.

To get halcompile to work, try copying one of the examples into your text editor saving as example.comp and then try to halcompile --preprocess example.comp

That should at least prove that halcompile is working even if it doesn't make your error apparent.

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

More
17 Feb 2024 11:45 #293604 by andypugh
Replied by andypugh on topic Getting Halcompile to work
"need more than one value to unack" is caused by a failure at the pint that the input file is split into two sections at the ";;" marker.
There could probably be a specific test for this step going wrong, wrapping the split in a try/except

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

Time to create page: 0.144 seconds
Powered by Kunena Forum