- LinuxCNC
- General LinuxCNC Questions
- How to read "Machine configuration directory" in HAL userspace component
How to read "Machine configuration directory" in HAL userspace component
- freisei
- 
				 Topic Author Topic Author
- Offline
- Junior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 20
- Thank you received: 1
			
	
						24 Dec 2020 13:20				#193107
		by freisei
	
	
		
			
	
			
			 		
													
	
				How to read "Machine configuration directory" in HAL userspace component was created by freisei			
			
				Hi!
i am writing a timeinterval-component, and i want to save same data in configuration-directory.
I have often seen the os.environ 'CONFIG_DIR' in python - i think this is what i need.
If i try to get this in c i get an empty variable:
my componet was loaded after linuxcnc was startet with
Is there a header-file to include to get more of linuxcnc-environment?
Greets from Bavaria
Freisei
					i am writing a timeinterval-component, and i want to save same data in configuration-directory.
I have often seen the os.environ 'CONFIG_DIR' in python - i think this is what i need.
If i try to get this in c i get an empty variable:
const char* s = getenv("CONFIG_DIR");
    printf("CONFIG_DIR :%s\n",(s!=NULL)? s : "getenv returned NULL");
    printf("end test\n");my componet was loaded after linuxcnc was startet with
halcmd loadusr -W timeinterval filename=lubrication_timeinterval.savIs there a header-file to include to get more of linuxcnc-environment?
Greets from Bavaria
Freisei
Please Log in or Create an account to join the conversation.
- freisei
- 
				 Topic Author Topic Author
- Offline
- Junior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 20
- Thank you received: 1
			
	
						25 Dec 2020 10:16				#193169
		by freisei
	
	
		
			
	
			
			 		
													
	
				Replied by freisei on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Hi,
i´ve found that the current working directory is the config-dir, when the component is loaded from linuxcnc himself/halfile.
But for develement it would be great if someone know how to access the "config_dir" Varaible.
Greets from Bavaria
Freisei
					i´ve found that the current working directory is the config-dir, when the component is loaded from linuxcnc himself/halfile.
But for develement it would be great if someone know how to access the "config_dir" Varaible.
Greets from Bavaria
Freisei
Please Log in or Create an account to join the conversation.
- udoS
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 216
- Thank you received: 25
			
	
						31 Oct 2022 06:06				#255544
		by udoS
	
	
		
			
	
			
			 		
													
	
				Replied by udoS on topic How to read "Machine configuration directory" in HAL userspace component			
			
				@
	freisei
Hallo freisei
did you find a solution getting the "config_dir" programmatically;
Best Regards
					Hallo freisei
did you find a solution getting the "config_dir" programmatically;
Best Regards
Please Log in or Create an account to join the conversation.
- freisei
- 
				 Topic Author Topic Author
- Offline
- Junior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 20
- Thank you received: 1
			
	
						05 Nov 2022 14:55				#256014
		by freisei
	
	
		
			
	
			
			 		
													
	
				Replied by freisei on topic How to read "Machine configuration directory" in HAL userspace component			
			
				no sorry.			
					Please Log in or Create an account to join the conversation.
- udoS
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 216
- Thank you received: 25
			
	
						21 Nov 2022 19:18				#257248
		by udoS
	
	
		
			
	
	
			
			 		
													
	
				Replied by udoS on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Hi  @freisei
I found a way to get the ini Directory; if thats what you where looking for;
Best Regards
					I found a way to get the ini Directory; if thats what you where looking for;
Best Regards
Please Log in or Create an account to join the conversation.
- freisei
- 
				 Topic Author Topic Author
- Offline
- Junior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 20
- Thank you received: 1
			
	
						22 Nov 2022 08:01				#257307
		by freisei
	
	
		
			
	
			
			 		
													
	
				Replied by freisei on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Hi udoS,
fine!
Would be great if you share your answer, so others can benefit from it, too.
Thanks!
					fine!
Would be great if you share your answer, so others can benefit from it, too.
Thanks!
Please Log in or Create an account to join the conversation.
- udoS
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 216
- Thank you received: 25
			
	
						22 Nov 2022 11:14				#257319
		by udoS
	
	
		
			
	
	
			
			 		
													
	
				Replied by udoS on topic How to read "Machine configuration directory" in HAL userspace component			
			
				@freisei
some pree condition:
Linuxcnc must be running;
If you start Linuxcnc then you can querry:
$ ps aux | grep "linuxcnc"
LinuxCNC starts with "/bin/bash /usr/bin/linuxcnc"
Now if you start LinuxCNC, LinuxCNC starts/calls for "halui -ini" and "io -ini"
If you querry now for
$ ps aux | grep "halui -ini" or
$ ps aux | grep "io -ini"
then you get as return the process info along with the path;
io -ini /home/udos/linuxcnc/configs/sim.axis.gantry/gantry_mm.ini
Here the code I have used in Qt 5.15.2:
 			
					some pree condition:
Linuxcnc must be running;
If you start Linuxcnc then you can querry:
$ ps aux | grep "linuxcnc"
LinuxCNC starts with "/bin/bash /usr/bin/linuxcnc"
Now if you start LinuxCNC, LinuxCNC starts/calls for "halui -ini" and "io -ini"
If you querry now for
$ ps aux | grep "halui -ini" or
$ ps aux | grep "io -ini"
then you get as return the process info along with the path;
io -ini /home/udos/linuxcnc/configs/sim.axis.gantry/gantry_mm.ini
Here the code I have used in Qt 5.15.2:
Please Log in or Create an account to join the conversation.
- andypugh
- 
				  
- Offline
- Moderator
- 
				  
		Less
		More
		
			
	
		- Posts: 19677
- Thank you received: 4553
			
	
						22 Nov 2022 23:45				#257405
		by andypugh
	
	
		
			
	
			
			 		
													
	
				Replied by andypugh on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Maybe you can run the linuxcnc_info script?			
					Please Log in or Create an account to join the conversation.
- dgarrett
- Offline
- Platinum Member
- 
				  
		Less
		More
		
			
	
		- Posts: 492
- Thank you received: 297
			
	
						23 Nov 2022 01:07		 -  23 Nov 2022 01:09		#257412
		by dgarrett
	
	
		
			
	
	
			 		
													
	
				Replied by dgarrett on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Processes started by linuxcnc (like [DISPLAY]DISPLAY)
inherit the environmental variables 'INI_FILE_NAME'
Python example within a [DISPLAY]DISPLAY program:
import os
print(os.environ.get("INI_FILE_NAME"))
The ini setting is also available in stat() and
may be obtained from programs not started by linuxcnc
(if Run-In-PLace, source rip_environment first):
$ python -c "import linuxcnc;s=linuxcnc.stat();s.poll();print(s.ini_filename)"
Note the item namings are different (INI_FILE_NAME and ini_filename)
					inherit the environmental variables 'INI_FILE_NAME'
Python example within a [DISPLAY]DISPLAY program:
import os
print(os.environ.get("INI_FILE_NAME"))
The ini setting is also available in stat() and
may be obtained from programs not started by linuxcnc
(if Run-In-PLace, source rip_environment first):
$ python -c "import linuxcnc;s=linuxcnc.stat();s.poll();print(s.ini_filename)"
Note the item namings are different (INI_FILE_NAME and ini_filename)
		Last edit: 23 Nov 2022 01:09  by dgarrett.			
			Please Log in or Create an account to join the conversation.
- udoS
- Offline
- Elite Member
- 
				  
		Less
		More
		
			
	
		- Posts: 216
- Thank you received: 25
			
	
						23 Nov 2022 06:27				#257429
		by udoS
	
	
		
			
	
			
			 		
													
	
				Replied by udoS on topic How to read "Machine configuration directory" in HAL userspace component			
			
				Thanks for the info;
@andypugh
How does that get me the path to a running linuxcnc ?
@dgarrett
I'm all in Qt and/or c++; No No No Python; what so ever;
with "The ini setting is also available in stat()" .. are you referring to NML ?
then what is the call for it ? could be used in the Lcnc_QtCpp_HMI;
What I have here is an interface into LinuxCNC/HAL in an attempt to build a Linuxcnc-IDE;
Qt 5.15.2, with Creator 8.0.1, c++17; any help Wellcome !
Best Regards
 			
					@andypugh
How does that get me the path to a running linuxcnc ?
@dgarrett
I'm all in Qt and/or c++; No No No Python; what so ever;
with "The ini setting is also available in stat()" .. are you referring to NML ?
then what is the call for it ? could be used in the Lcnc_QtCpp_HMI;
What I have here is an interface into LinuxCNC/HAL in an attempt to build a Linuxcnc-IDE;
Qt 5.15.2, with Creator 8.0.1, c++17; any help Wellcome !
Best Regards
Please Log in or Create an account to join the conversation.
- LinuxCNC
- General LinuxCNC Questions
- How to read "Machine configuration directory" in HAL userspace component
		Time to create page: 0.142 seconds	
 
													