chiark / gitweb /
quacks-ingredients: gcode manipulation wip
[reprap-play.git] / quacks-ingredients-make-copy-gcodes
1 #!/bin/sh
2 #
3 # usage:
4 #    ./quacks-ingredients-make-copy-gcodes Tests_L
5 # Uses
6 #    quacks-ingredients-L$l,Tests_L.auto.stl
7 # to make
8 #    quacks-ingredients-L$l,Tests_L.auto.gcode
9 # and then edits them and copies them to the SD card as
10 #    PREPARED/Q$l.G
11
12 set -e
13
14 f=$1
15 shift
16
17 umount /media/sd >/dev/null 2>&1 ||:
18 mount /media/sd
19
20 lhs=quacks-ingredients-L
21
22 gh () {
23         g=$lhs$l.auto.gcode
24         h=/media/sd/PREPARED/Q$l.G
25 }
26
27 for l in 1 2 3 4 5; do
28         gh
29         cura -s $lhs$l,$f.auto.stl -o $g
30         case $l in
31         1|2|3|4)
32                 perl -i~ -pe 's/^/;/ if m/^M140 S0\b.*\n/' $g
33                 ;;
34         5)      ;;
35         *)      echo >&2 "??? $l"; exit 1 ;;
36         esac
37
38         perl -i~ -ne '
39                 $l =~ s/^/;/ if m/^M400/;
40                 print $l or die $!;
41                 $l = $_;
42                 END { print $l or die $!; }
43         ' $g
44
45         cp $g $h
46 done
47
48 umount /media/sd
49 mount /media/sd
50
51 for l in 1 2 3 4 5; do
52         gh
53         cmp $g $h
54         ls -l $h
55 done
56
57 umount /media/sd