test.sh
1 #!/bin/bash 2 3 rm -f gcode-output 4 5 linuxcnc -r linuxcncrsh-test.ini & 6 7 8 # let linuxcnc come up 9 TOGO=80 10 while [ $TOGO -gt 0 ]; do 11 echo trying to connect to linuxcncrsh TOGO=$TOGO 12 if nc -z localhost 5007; then 13 break 14 fi 15 sleep 0.25 16 TOGO=$(($TOGO - 1)) 17 done 18 if [ $TOGO -eq 0 ]; then 19 echo connection to linuxcncrsh timed out 20 exit 1 21 fi 22 23 24 ( 25 echo hello EMC mt 1.0 26 echo set enable EMCTOO 27 28 # ask linuxcncrsh to not read the next command until it's done running 29 # the current one 30 echo set set_wait done 31 32 echo set mode manual 33 echo set estop off 34 echo set machine on 35 36 echo set mode mdi 37 echo set mdi m100 p-1 q-2 38 sleep 1 39 40 # here comes a big blob 41 dd bs=4096 if=lots-of-gcode 42 43 echo set mdi m100 p-3 q-4 44 45 echo shutdown 46 ) | nc localhost 5007 47 48 49 # wait for linuxcnc to finish 50 wait 51 52 exit 0 53