-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
executable file
·45 lines (33 loc) · 1.3 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import sys
import os
import subprocess
import argparse
import time
from machinekit import launcher
from machinekit import config
os.chdir(os.path.dirname(os.path.realpath(__file__)))
parser = argparse.ArgumentParser(description='Linear axis motion with Machinekit')
parser.add_argument('-d', '--debug', help='Enable debug mode', action='store_true')
args = parser.parse_args()
if args.debug:
launcher.set_debug_level(5)
if 'MACHINEKIT_INI' not in os.environ: # export for package installs
mkconfig = config.Config()
os.environ['MACHINEKIT_INI'] = mkconfig.MACHINEKIT_INI
try:
launcher.check_installation()
launcher.cleanup_session() # kill any running Machinekit instances
launcher.load_bbio_file('paralell_cape2.bbio') # load the BBIO pin overlay
launcher.start_realtime() # start Machinekit realtime environment
launcher.load_hal_file('main.py') # load the main HAL file
launcher.register_exit_handler() # enable on ctrl-C, needs to executed after HAL files
launcher.ensure_mklauncher() # ensure mklauncher is started
launcher.start_process('configserver -n "Linear Axis" .')
while True:
launcher.check_processes()
time.sleep(1)
except subprocess.CalledProcessError:
launcher.end_session()
sys.exit(1)
sys.exit(0)