Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script on startup? #12

Open
HCS-II opened this issue Feb 15, 2017 · 5 comments
Open

Script on startup? #12

HCS-II opened this issue Feb 15, 2017 · 5 comments

Comments

@HCS-II
Copy link
Contributor

HCS-II commented Feb 15, 2017

Thanks for the great script!

I'll be using it on my OxCNC running GRBL and bCNC on a RPi3 with 7" official LCD.

Two questions:
1- What is the purpose of the A axis? Just to stay in-line with the Tormach implementation and allow for future expansion? I was thinking of remapping the three middle buttons to X, Y and Z and use the previously-assigned X button to Home. Thoughts?

2- I have tried to run the script on startup via init.d but it doesn't work. Have you launched your script automatically, and if yes, how did you go about it?

Regards,

Mike

@lordmundi
Copy link
Owner

lordmundi commented Feb 15, 2017 via email

@HCS-II
Copy link
Contributor Author

HCS-II commented Feb 16, 2017

Frank,

Thanks for the reply. I also want to launch as a service in systemd but my script failed. Probably because it called the shuttle bash script (with GPIO cleanup) instead of calling shuttlecp directly.

When you get a chance, I would appreciate if you could share the startup script file you used.

In my testings, shuttleCP didn't crash or cause issues if launched before bCNC, though it reported failed postings when the jog button was used. Once bCNC was executed, it worked correctly. So I don't understand why you've put the following warning in the README file: "For bCNC, make sure that bCNC is running and is connected to the GRBL board. All alarms must be clared and the CNC machine state is reported as "Idle"."

Regards,

Mike

@lordmundi
Copy link
Owner

lordmundi commented Feb 16, 2017 via email

@HCS-II
Copy link
Contributor Author

HCS-II commented Feb 16, 2017

O.K., I've got it working and here is the recipe. Sorry, I'm new to Github so I don't know yet how to do a pull request :-)

First, the shuttle script needs to have explicit path for the call to shuttleCP. So the content should be:

#!/bin/bash

trap cleanup SIGINT EXIT
function cleanup() {
    for pin in 8 9 7 0 2 3 15 16 4 5; do
        gpio write $pin 0
    done
}

echo "Starting shuttleCP ..."
sudo /home/pi/shuttleCP/shuttlecp /dev/input/by-id/usb-Contour_Design_ShuttleXpress-event-if00
echo "Program terminated."

In the ShuttleCP package, you need a file called shuttle.service that contains the following text :

[Unit]
Description=ShuttleXpress controller for bCNC
After=multi-user.target

[Service]
Type=idle
ExecStart=/home/pi/shuttleCP/shuttle

[Install]
WantedBy=multi-user.target

With this done, here are the instructions you could add for the user:

Autorun the shuttle script on boot using systemd in Raspbian Jessie:

Reference and more details here.

We first need to add a unit file that tells systemd that we want it to launch the shuttle script on boot once the GPIO service has been activated. To do so, simply copy the file shuttle.service found in the shuttleCP directory by using the following command:
sudo cp /home/pi/shuttleCP/shuttle.service /lib/systemd/system/

Next, the permission on the unit file needs to be set to 644 :
sudo chmod 644 /lib/systemd/system/shuttle.service

Last, we can tell systemd to start the script during the boot sequence and reboot the RPi:

sudo systemctl daemon-reload
sudo systemctl enable shuttle.service
sudo reboot

You can confirm the new service runs by checking it's status:
sudo systemctl status shuttle.service

@HCS-II
Copy link
Contributor Author

HCS-II commented Feb 17, 2017

Frank,

My 15yo son is going to show me how to make a pull request for the above mods. Just standby for later tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants