lordmundi / shuttleCP

ShuttleCP: Jog Dial for ChiliPeppr and bCNC
GNU General Public License v3.0
6 stars 5 forks source link

Script on startup? #12

Open HCS-II opened 7 years ago

HCS-II commented 7 years ago

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 commented 7 years ago
  1. Yes, it was just in case someone had a 4th access. Not many folks do. You could certainly remap the buttons to do whatever you would like. In fact, if you do it in a generic way to make it easy to remap stuff, feel free to commit it and send a pull request so that we can make it a feature!

  2. I do have it launched automatically, but I can't recall exactly what I did (unfortunately, can't ssh into it at the moment). Do a search for running scripts on bootup with raspbian. If i recall, I installed it as a service so I could do "service start blah" and "service stop blah". I'm guessing this will depend on whether or not you are running systemd or not. Also, there is always the /etc/rc.local method if that exists in your distribution.

FG

On Wed, Feb 15, 2017 at 10:17 AM, HCS-II notifications@github.com wrote:

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lordmundi/shuttleCP/issues/12, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWKCnvc3ggjQ8p3it5XkIAgcsJrQlcIks5rcyUagaJpZM4MB6zJ .

HCS-II commented 7 years ago

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 commented 7 years ago

Well, unfortunately my Raspbian didn't use systemd. I guess it was an OS release before they switched over.

FG Sent from my Android phone

On Feb 15, 2017 11:35 PM, "HCS-II" notifications@github.com wrote:

Thanks for the reply. I also want to launch as a service in systemd.

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

Regards,

Mike

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lordmundi/shuttleCP/issues/12#issuecomment-280235926, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWKCo7ZHYE0XNgYjze8-hY6HccuvDZ1ks5rc-AZgaJpZM4MB6zJ .

HCS-II commented 7 years ago

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 commented 7 years ago

Frank,

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