Difference between revisions of "Cerealbot/Software"

From Makers Local 256
Jump to: navigation, search
m (added api curl lines)
m (Cerealbot Code: migrating to /rpi)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
  
 
[https://github.com/ctag/cerealbox Github files for this project].
 
[https://github.com/ctag/cerealbox Github files for this project].
 
== Cerealbot Code ==
 
 
Underneath the queue is a hodge podge of shell scripts and C programs.
 
 
Current System:
 
 
Shell script hooks bound to Octoprint's "printStart" and "printDone" events. These handle setting the flag which indicates a part is being printed/removed. Once a part is being removed, its corresponding gcode is deleted from the queue.
 
 
A cron job checks the printer status and queue for a match of "free printer + file to print" and then kicks off the print job.
 
 
A C program acts as a buffer to the arduino and allows the shell scripts to control hardware in a easy to use but complicated to setup manner.
 
 
=== API ===
 
 
Curl is great for testing around with both Octoprint and RedQueen's api, but I've switched the shell scripts to use [https://github.com/micha/resty resty] for ease of maintenance.
 
 
<pre>
 
Curl Examples
 
To RedQueen:
 
curl --data "{\"message\":\"${MSG}\", \"channel\":\"##rqtest\", \"isaction\":false, \"key\":\"${APIKEY}\"}" https://crump.space/rq/relay -H "Content-Type:application/json"
 
To Octoprint:
 
curl -H "X-Api-Key:$OCTO_API_KEY" http://bns-daedalus.256.makerslocal.org/api/printer -o /tmp/printr_status.json
 
</pre>
 
 
== Webcam ==
 
 
To list available formats:
 
<pre>
 
v4l2-ctl --list-formats
 
</pre>
 
or
 
<pre>
 
v4l2-ctl -d /dev/video0 --list-formats-ext
 
</pre>
 
 
==== Octoprint ====
 
 
To use an http stream with octoprint, the URL has to be formatted correctly.
 
 
At first glance, I tried: cerealbox.256.makerslocal.org:8081, which didn't work.
 
 
Turns out Octoprint blindly appends a GET variable to the URL, which turns the above into: cerealbox.256.makerslocal.org:8081?2354jk345 which isn't a valid URL anymore.
 
 
So, you have to set up the webcam URL like: http://cerealbox.256.makerslocal.org:8081/
 
 
Here the trailing slash lands the GET variable. It took Hunter Fuller to figure all that out.
 
 
==== mjpg-streamer ====
 
 
[https://github.com/jacksonliam/mjpg-streamer mjpg-streamer] is by far the best solution for webcam streaming from the RPi. A recent update brought immense relief for CPU overhead.
 
 
Base command to run:
 
 
<pre>
 
mjpg_streamer -b -i "./input_uvc.so -d /dev/video0 -n -f 5 -r 1280x720" -o "./output_http.so -p 8080 -w ./www"
 
</pre>
 
 
Previously I've used the -y flag for compatibility, which totally crushed the little CPU, but the most recent build of mjpg-streamer appears to work quite well with my Logitech webcam using the default MJPG codec.
 
  
 
== Slic3r Config ==
 
== Slic3r Config ==
Line 66: Line 7:
  
 
== Octoprint Server - RPi ==
 
== Octoprint Server - RPi ==
 
=== Authbind ===
 
 
tl;dr: haproxy ''bad'', authbind '''good'''.
 
 
In '/etc/default/octoprint' Set port to 80 and uncommand the extra arguments.
 
 
In '/etc/init.d/octoprint' Add 'AUTHBIND=/usr/bin/authbind' to the variable declaration section and then find the invocation of $DAEMON and add $AUTHBIND directly in front of it (with a space). When you restart the service, it should come up on port 80.
 
  
 
=== Raspbian - Debian ===
 
=== Raspbian - Debian ===
Line 98: Line 31:
  
 
Right now I'm streaming the webcam from v4l-mjpg-streamer, total pain, will look for something better.
 
Right now I'm streaming the webcam from v4l-mjpg-streamer, total pain, will look for something better.
 
== Protips ==
 
 
=== BYOBU ===
 
 
* F1 allows you to set "log into byobu" to save some time while logging in.
 
 
* 'C-a a' will send C-a to screen, so that you can use screen within byobu to debug the printer's serial connection.
 

Latest revision as of 03:08, 9 June 2015

Github files for this project.

Slic3r Config

I'm still working on a Slic3r config, its on github.

Octoprint Server - RPi

Raspbian - Debian

Archlinux

To run octoprint from port 80 as user 'octoprint', I adjusted the systemd unit file to launch with authbind.

[Unit]
Description=Octoprint 3d Printing Web Server
After=network.target

[Service]
User=octoprint
Group=octoprint
Type=simple
ExecStart=/usr/bin/authbind --deep /usr/bin/octoprint --port 80
Restart=on-failure

[Install]
WantedBy=multi-user.target

Right now I'm streaming the webcam from v4l-mjpg-streamer, total pain, will look for something better.