custom hal component failed to compile, undeclared (first use in this function)

More
3 years 10 months ago #259773 by andypugh
You can't have a hyphen in a variable name in C.

my-pin looks like my (minus) pin to C, and it looks for variables "my" and "pin" and doesn't find them.

However, the convention (not well enforced) is that HAL pins should use - as the word separator, not _.

Halcompile handles this for you, but you need to remember that it is - above the ;; separator and _ below when referring to pin names.

Also confusing is that it is (index) to refer to members of a pin array, despite the fact that is is [index] to reference an array in C. Again this is a workaround in halcompile forced by C base code and macro syntax.

Halcompile does very clever things, but there are some assumptions in the C compilers that is can't work around quite as elegantly as one might wish.
The following user(s) said Thank You: smc.collins

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

More
3 years 10 months ago #259848 by smc.collins
I really think hal, should embrace a basic, like YAB or similar. 

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

  • tommylight
  • Away
  • Moderator
  • Moderator
More
3 years 10 months ago #259850 by tommylight

I really think hal, should embrace a basic, like YAB or similar. 
Nooooooo :)
Hal is the main reason i love LinuxCNC.

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

More
3 years 10 months ago - 3 years 10 months ago #259858 by smc.collins
C is a great language, but hal is already behaving like a Basic type language. it'd make more sense to have a basic type of syntax in hal. Back to my mess, I can get it to compile, but I still can't get it to work. If someone can explain why this doesn't work, I'd love to hear the explanation. latest source and config.
Attachments:
Last edit: 3 years 10 months ago by smc.collins.

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

More
3 years 10 months ago #259910 by andypugh

C is a great language, but hal is already behaving like a Basic type language. it'd make more sense to have a basic type of syntax in hal.

 
HAL files can be Tcl files, if you want actual code in there. 

The custom comps _have_ to be C files as they are compiled into Linux kernel modules and C is the only language allowed in the kernel. 
 

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

More
3 years 10 months ago #259920 by smc.collins
i got some motion today, sniffing out a logic problem but i think i might be on the correct path now. 

any idea why iocontrol doesn't fetch the tool number from the component when homing ???

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

Time to create page: 0.160 seconds
Powered by Kunena Forum