Start-up script

More
17 Mar 2020 18:12 #160580 by Earlton2
Start-up script was created by Earlton2
After a linuxCNC 2.7.15 update my start-up script is on the blink! The intention is to disable the Network and Sound Then start linuxCNC. After closing LinuxCNC I enable the Network and Sound, and log the start, stop and elapse times. What's quit is the ability to turn the Network OFF and ON. This is not really a linuxCNC question but the solution might be of interest to our subscribers.

There are (LOG, ...) commands in the ngc file to capture the odd parameter e.g. spindle speed. The mawk command captures the latest ngc file from .axis_preferences. It then builds the *.log filename to append the time info.

#!/bin/bash
# log file for date stamps and elapse time
# gnc file may append commentary and data using (LOG, ...)
echo "run linuxcnc after disabling audio and ethernet"

#sudo /etc/init.d/network-manager stop
sudo service network-manager stop
amixer set Master mute
start=$(date)

linuxcnc /home/cnc/linuxcnc/configs/EAI07TPCPWM/EAI07TPCPWM.ini
sleep 1s

stop=$(date)
#sudo /etc/init.d/network-manager start
sudo service network-manager start
amixer set Master unmute
# read ngc file from axis log, 2nd entry using \' as break
ngcf=$(mawk -F\' '/recent/ {print $2}' /home/cnc/.axis_preferences)
logf=$(echo $ngcf | cut -d. -f 1)
ext=".log"
logf=$logf$ext
echo "Start Time:" $start >> $logf
echo "End Time: " $stop >> $logf
#33 pulled this gem off the web from Bill Gale
duration=$(date -ud@$(($(date -ud"$stop" +%s)-$(date -ud"$start" +%s))) +%T)
echo "Duration: " $duration >> $logf

David Whiteley
The following user(s) said Thank You: tommylight, bbsr_5a

Please Log in or Create an account to join the conversation.

More
18 Mar 2020 07:33 #160626 by bbsr_5a
Replied by bbsr_5a on topic Start-up script
you are better off to get the mashine its own system
no matter it workes the way you did it
the CAD CAM system shoudt not run on a realtime kernel

Please Log in or Create an account to join the conversation.

More
18 Mar 2020 10:08 #160637 by BeagleBrainz
Replied by BeagleBrainz on topic Start-up script

the CAD CAM system shoudt not run on a realtime kernel


Why ? What is the issue ?

Please Log in or Create an account to join the conversation.

More
18 Mar 2020 11:13 #160642 by tommylight
Replied by tommylight on topic Start-up script

the CAD CAM system shoudt not run on a realtime kernel


Why ? What is the issue ?

I run everything on a real time kernel, even my HP tablet!
You can run everything on realtime kernel, the only caveat is for laptops, it will drain the battery faster.

Please Log in or Create an account to join the conversation.

More
18 Mar 2020 11:36 #160643 by BeagleBrainz
Replied by BeagleBrainz on topic Start-up script
I just started playing with my ML150-G5 Twin Quad Core Xeons @ 3.0GHz and on a non RT kernel I was getting "NMI watchdog: BUG: soft lockup - CPU#X stuck for XXs!"
Went to a RT_PREEMPT and those issues disappeared......anyway nothing to do with linuxcnc but kinda interesting.
The 8 cores are great for building kernel packages, 26 minutes from start to having debs built, not bad for a box that owes me AUD $50 (that includes getting a pair of E5450 CPUs & cooler, 16GB RAM and 128MB Nvidia PCI card (yes PCI))....those times are with an old mechanical drive that's not the fastest. Runs quiet for what it is, but sounds like a jet taking off until it's done it's start up thing. Shame it wont work with 16x PCIe cards...the Gen 6s will.

But yeah when I boot into Mint 19.2 it's always a real time kernel.

Please Log in or Create an account to join the conversation.

More
19 Mar 2020 23:08 #160794 by Earlton2
Replied by Earlton2 on topic Start-up script
Some progress in that I can now run 'sudo ./runcnc.sh' from a Terminal, it will ask for my Password, turn OFF Network & Sound, run linuxCNC, and when I Quit linuxCNC it enables Network & Sound.
I used 'sudo chown root:root runcnc.sh' and chmod u+s runcnc.sh'. I have even tried the former on the Desktop link to runcnc.sh but this does not disable the Network nor does it ask for a password.
I've appended a typical log to the end of the script. i.e. some run parameters using (LOG, .....) and the three time stamps.
cat runcnc.sh
#!/bin/bash
# sudo chown root:root runcnc.sh
# sudo chmod u+s runcnc.sh
# normal command use 'sudo -n cnc ...'
# log file for date stamps and elapse time
# gnc file may append commentary and data using (LOG, ...)
sudo -u cnc echo "run linuxcnc after disabling audio and ethernet"
service network-manager stop
sudo -u cnc amixer set Master mute
sudo -u cnc start=$(date)
sudo -u cnc linuxcnc /home/cnc/linuxcnc/configs/EAI07TPCPWM/EAI07TPCPWM.ini
sudo -u cnc sleep 1s
sudo -u cnc stop=$(date)
service network-manager restart
sudo -u cnc amixer set Master unmute
# read ngc file from axis log, 2nd entry using \' as break
sudo -u cnc ngcf=$(mawk -F\' '/recent/ {print $2}' /home/cnc/.axis_preferences) 
sudo -u cnc logf=$(echo $ngcf | cut -d. -f 1)
sudo -u cnc ext=".log"
sudo -u cnc logf=$logf$ext
sudo -u cnc echo "Start Time:" $start >> $logf
sudo -u cnc echo "End Time:  " $stop  >> $logf
# pulled this gem off the web from Bill Gale:
sudo -u cnc duration=$(date -ud@$(($(date -ud"$stop" +%s)-$(date -ud"$start" +%s))) +%T)
sudo -u cnc echo "Duration:  " $duration >> $logf

cat scallop.log
0.375000 tool dia, 1.500000 shell rad, 0.450000 shell height, 96.000000 shell angle
7.384615 ridges, 0.123252 edge mod, 0.045000 height mod, 0.562500 nose rad
0.400000 border, 0.370000 ring, 0.180000 lip, 2.450000 outer rad
Run Date:   Mon Mar 16 09:15:37 EDT 2020
Start Time: 16:40:36
End Time:   17:05:05
Duration:   00:24:29

Please Log in or Create an account to join the conversation.

Time to create page: 0.189 seconds
Powered by Kunena Forum