Notification on print completion October 10, 2016 09:51AM |
Registered: 7 years ago Posts: 109 |
Re: Notification on print completion October 10, 2016 10:13AM |
Registered: 8 years ago Posts: 301 |
;Set Pin high in end gcode. M42 P67 S1 ; Digial pin 67 on (physical pin 32 on header.) G4 P1000 ; wait 1000 msec (= 1 sec) M42 P67 S0 ; pin off
Re: Notification on print completion October 10, 2016 10:23AM |
Registered: 10 years ago Posts: 14,672 |
Re: Notification on print completion October 11, 2016 05:51AM |
Registered: 7 years ago Posts: 109 |
#!/usr/bin/expect set timeout 20 set ip [lindex $argv 0] set password [lindex $argv 1] spawn telnet $ip expect "password:" sleep .1; send "$password\r"; sleep 1; expect "successful!" sleep 1; send "M27\r" sleep 1; expect { "byte" { ### if M27 reports printing in progress, than ... send "exit\r" sleep .1; spawn cat status ###check last status expect { "0" { exec echo 1 > status ### if last status is 0 , than change to 1 and inform user send_user "Printing started!" } "1" { send_user "Printing in process" ### if last status is 1, it means that we already printing, do nothing } } } "Not" { ### if M27 reports "Not printing" or idle, than ... send "exit\r" spawn cat status ### check last status expect { "1" { exec /home/pi/./finished.sh ### if last status was 1 (printing) than execute finished.sh script send_user "Printing finished!" exec echo 0 > status ### write new status } "0" { ### if last status was 0 , it means that no printing was started or finished actions were already executed. send_user "No Print started yet!" } } } }
Re: Notification on print completion October 11, 2016 06:48AM |
Registered: 8 years ago Posts: 301 |
Re: Notification on print completion October 11, 2016 07:34AM |
Registered: 7 years ago Posts: 109 |
Quote
DADIY
Nice solution, I think you might want to add a lock file so that you don't get multiple notifications, create it the first time the printing starts and remove it once printing finishes and you've sent the alert. Otherwise won't you just keep getting printing finished alerts?
Re: Notification on print completion October 11, 2016 08:32AM |
Registered: 8 years ago Posts: 301 |
#Check Printer is up before attempting to connect. ping -W1 IP -c 1 >/dev/null 2>&1 if [ $? = 0 ] then echo Printer Up /path/to/script/watchprinter.sh IP Password else echo Printer down. fi
Re: Notification on print completion October 11, 2016 09:54AM |
Registered: 7 years ago Posts: 109 |