Late solving here, just posting in case it helps someone someday :)

I created a small python code to test if the joystick file exists and 
called it with loadusr -w joystickLoader
In my case, i got these three files:

joystickLoader:
#!/usr/bin/python
import hal
import os

# load the HAL file 'joystickOptions.hal'
res = os.spawnvp(os.P_WAIT, "halcmd", ['halcmd' , '-k', '-Q', '-f', 
'joystickOptions.hal'])
joyFileExists = os.path.isfile('/dev/js0')
if joyFileExists == True:
  print 'Joystick found! Initilizing...'
  # load the HAL file 'joystickOptions.hal'
  res = os.spawnvp(os.P_WAIT, "halcmd", ['halcmd' , '-k', '-Q', '-f', 
'joystickOptions.hal'])
  if not res:
    res = os.spawnvp(os.P_WAIT, "halcmd", ['halcmd' ,"-f", 
"joystickSuccess.hal"])
    if res:
      print '**** TRY LOADER ERROR: try_sucess.hal file Error'
      raise SystemExit, res
else:
  print 'No joystick found'
exit()

joystickOptions.hal:
loadusr hal_input -KRAL 1

joystickSuccess.hal:
loadrt or2 count=2
loadrt mux4 count=2
addf or2.0 servo-thread
addf or2.1 servo-thread
addf mux4.0 servo-thread
# set the jog speed for the joypad again use numbers that make sense for 
your machine
setp mux4.0.in0 0 # this one must be 0 to prevent motion unless a button is 
pressed
setp mux4.0.in1 50
setp mux4.0.in2 300
setp mux4.0.in3 1800
# the following does the magic of setting the jog speeds
net remote-speed-slow or2.0.in0 input.0.btn-thumb2
net remote-speed-medium or2.1.in0 input.0.btn-thumb
net remote-speed-fast or2.0.in1 or2.1.in1 input.0.btn-joystick
net joy-speed-1 mux4.0.sel0 <= or2.0.out
net joy-speed-2 mux4.0.sel1 <= or2.1.out
net joy-speed-final halui.jog-speed <= mux4.0.out
net joy-x-jog halui.jog.0.analog <= input.0.abs-x-position
setp input.0.abs-y-scale -127.5
net joy-y-jog halui.jog.1.analog <= input.0.abs-y-position
addf mux4.1 servo-thread
setp mux4.1.in0 0
setp mux4.1.in1 -1
setp mux4.1.in2 1
setp mux4.1.in3 0
net joy-z-up mux4.1.sel0 <= input.0.btn-base
net joy-z-down mux4.1.sel1 <= input.0.btn-base2
net joy-z-jog halui.jog.2.analog <= mux4.1.out


Best Regards.
Paulo Sherring.

Em segunda-feira, 1 de outubro de 2018 13:05:50 UTC-3, Paulo Sherring 
escreveu:
>
> Hey there! I am new to machinekit / linuxcnc and I have a question I 
> couldn't find an answer. I have a joystick pluged in a BeagleBone Green and 
> I use it to control a CNC router. The fact is that sometimes, I may have to 
> use the machine without the controller - maybe its mal functioning or 
> something of this sort.
> Currently, I am loading a hal file that specifically sets up the relations 
> between the buttons and the jog signals on my INI file, something like:
> HALFILE = joystick.hal
> What I need is to run some kind of check on my ini file to load it or not, 
> something like 
> if [ -f /dev/input/js0]
> then
> HALFILE = joystick.hal
> fi
>
> Obviously, this could also be inside the hal file itself, but, I also 
> don't know how to do it :(
> Thanks in advance!
> Paulo Sherring.
>

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/machinekit/e8a231e3-5616-41ed-b7bb-06ce426896a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to