Posts

Showing posts from June, 2020

First steps with a Duet 2 Wifi

Image
I have been testing a Duet 2 Wifi board lately. It is the first 3D printer / CNC controller board that I use that has a decent wireless upload speed. It is a well-thought-out board designed by David Crocker and Tony Lock, that features both an ARM ATSAM4E8E and ESP8266 module. The former handles the RepRapFirmware and the latter provides wireless connectivity to the mix.  The board features five silent stepper motor drivers and heaters and fan controllers to be used on 3D printers or CNC machines. The built-in socket for an SD card allows its usage not only to hold the firmware and website files but also user folders containing g-code files that can be uploaded and managed remotely through the built-in web server.  The only main problem for the newbie is SD card and board initialization, which should have been taken care of by the seller unless they are lousy. But the board I got did have an empty SD and no manual so I had to go Duet3.com site to get some answers in their Documentatio

Remote shutdown your Python program

Image
One piece of code for a project is written in Python and it does what it was intended to do but, out of the blue, I am asked about the possibility of shutting it down remotely from another computer (code is running on a server where I do not want other users to be messing around). It was a perfect opportunity for using the threading library. So I went ahead and I wrote a small piece of code, encapsulated in a function, that will be run on a different thread. The main program is still doing its thing, but the new thread now creates a network socket and binds it to the proper IP address and port so it can accept connections from other computers over the network. When a new connection is made, the code will check if a special token is received, and if that is confirmed, it will shut down the whole program. Otherwise, the thread will loop forever in case new connections are made in the future. So the question is how to shut down the program. Usually, I use exit(0) to make my program