component compile problem

More
14 Apr 2018 11:13 #108993 by Skidloaders1
Good day all

trying to write my first component but have failed to compile so far
Reduced file to smallest possible.but no matter what i write ,I keep getting the same error message ( even when using component from others )

see below


FUNCTION _;
{
If (toolchange == true )
turn-turret = true;
}


wil@wil:~/Desktop/Weiler-DDR$ sudo halcompile --compile turr.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


Wrote program on linux with gedit ( no Windows any where near it )

regards
Wilfried

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

More
14 Apr 2018 15:14 #108999 by gaston48
Replied by gaston48 on topic component compile problem
Hello,
Simple Component Example:

component ddt "Compute the derivative of the input function";
pin in float in;
pin out float out;
variable double old;
function _;
license "GPL"; // indicates GPL v2 or later
;;
float tmp = in;
out = (tmp - old) / fperiod;
old = tmp;


;; is important and justified left

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

More
14 Apr 2018 20:43 #109011 by Grotius
Replied by Grotius on topic component compile problem
Hi,

Maybe you can try : sudo halcompile ....
I have made variant's of thcud component. But next time i will try to make a mini tutorial how to compile a component.

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

More
15 Apr 2018 09:47 #109060 by Skidloaders1
Good day linuxcnc

Quote => " But next time i will try to make a mini tutorial how to compile a component."
Grotius I'm sure this will be welcomed by a lot of CNC enthousiast and the like.

I don't understand the programming requirements for a component very well.
I found a very nice online C editor and compiler.
www.onlinegdb.com/online_c_compiler
but when typing in a component program it does not react very well at all :-(
However, I did learn from it that turn-turret does not compile , but turn_turret does.
1)Is it possible to troubleshoot ( debug ) one's program in a non linuxcnc terminal environment?
2)What is the difference between a component for linuxcnc and a C program ?

p.s. my lathe is at work (15 min) from home where I have 380Volt.

Thanks
Wilfried

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

More
15 Apr 2018 12:28 #109064 by rodw
Replied by rodw on topic component compile problem
You really need to read the docs (master branch shown)
linuxcnc.org/docs/devel/html/hal/comp.html

C is a programming language. Hal components are written C like but there are some rules about the construction as you found out about underscores and hyphens.

components are usually compiled using halcompile which is a program that takes the .comp file as input, converts it to a C module, compiles and installs it so it is seen by Linuxcnc.

Normally you compile and install a component like this.
halcompile --install rtexample.comp

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

More
16 Apr 2018 16:14 #109130 by Skidloaders1
Good day All

Have tried any and every program and its variant but keep getting the same error.

nl.
wil@wil:~/Desktop/Weiler-DDR$ sudo halcompile --install constant.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


I have to conclude that the problem is not with the component.
But what else could it be ?
Had a look at Jeff Eplers Halcompiler program where line 1353 =>
main ()
whitch is the last line of the program.
do i have corrupt or missing file or files ??
It leaves me completely clueless.

any guidance would me most welcome
regards
Wilfried

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

More
17 Apr 2018 16:21 - 19 Apr 2018 15:42 #109206 by Skidloaders1
Hi all

Have now compiled ddt.comp on other linuxcnc machine and it worked just fine. :-)

Also reinstalled linuxcnc-dev , but with no change to the result.

Is it possible to compile on other unit and transfer the files to the machine I need them in ??
reinstall linuxcnc ?????
currently running linuxcnc 2.7.12 .

regards
Wilfried
Last edit: 19 Apr 2018 15:42 by Skidloaders1.

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

More
19 Apr 2018 20:15 - 20 Apr 2018 01:17 #109307 by JR1050
Replied by JR1050 on topic component compile problem
i think you have several syntax errors

FUNCTION _;
{
If (toolchange == true )
turn-turret = true;
}


C is case sensitive " If" is not the same as" if"
you will need to declare what your variables/ hal pins are
names should be in sequential parenthesis
you have to name the component
Spend some time in the hal manual and look up the toolchange comp for the first guy that retrofitted an HNC, it is very simple and makes sense. His first name was Kurt.
Most important, you have to know what you really want your component to do, you might try "hello world" with the gcc. Halcompile is for hal components.

so , more like this


component tool change;

pin in bit tool_change;
pin out bit turn_turret ;

function( _);
;;
;;
{
if((tool_change)==1){
turn_turret =1;
}
}

Im a big fan of components for plc functions, but it is a large learning curve.Ladder might be easier.
Last edit: 20 Apr 2018 01:17 by JR1050.

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

More
20 Apr 2018 15:22 #109338 by Skidloaders1
Thank you JR1050 for your kind help.

I realise that learning to write components is not going to be a overnight success.

I tried your code , once again with no different result.
Not looking forward to reinstall linuxcnc - ( or the full Debian .)
But looks like I have no choice.

best Wilfried

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

More
20 Apr 2018 15:26 #109339 by Skidloaders1
hope to write component for my Weiler lathe

see

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

Time to create page: 0.203 seconds
Powered by Kunena Forum