exciting-io / printer Goto Github PK
View Code? Open in Web Editor NEWTools for exploring the possibilities of "internet of things" printing.
Home Page: http://exciting.io/printer
License: MIT License
Tools for exploring the possibilities of "internet of things" printing.
Home Page: http://exciting.io/printer
License: MIT License
If my printer is offline for a week, I don't want to get a week of weather forecasts printed out when it comes back online again.
Perhaps another header sent with the content/url post could indicate a time-to-live?
Content services should require oauth authentication to send content to print URLs. At the moment, anyone who knows your print ID and URL can send content to be printed.
This implies some kind of account on the backend server.
It would be good to keep it simple to post via cURL and AJAX in spite of this.
I've seen several people enter print urls for services that are either invalid or garbage (i.e. test.com/1
or 1.2.3.4
). It might be nice for content services to be able to 'validate' a print URL by sending some kind of ping request so that can reject an invalid URL early in the process of accepting a registration.
(Of course, this might be rendered moot if the content service and the print server start negotiating directly about the print URLs).
Its a 560 +-5% resistor (gr,bl,br,go) but its 0.1W, 0.25W or 5W?
Thanks.
(bug, however does not affect the funcionality)
HTTP server returns wrong Content-Type response header for data availability check at http://printer.gofreerange.com/printer/{id} URL. In fact it respects request Accept header ("application/vnd.freerange.printer.") and provides correct data. However, server sends wrong response's Content-Type, which is always set to "text/html;charset=utf-8" (should be "application/vnd.freerange.printer." etc.).
> GET /printer/*** HTTP/1.0
> Host: printer.gofreerange.com
> Accept: application/vnd.freerange.printer.A2-bitmap
> X-Printer-Version: 1.0.5
< HTTP/1.0 200 OK
< Date: Thu, 21 Feb 2013 12:39:48 GMT
< Status: 200 OK
< X-Frame-Options: sameorigin
< X-XSS-Protection: 1; mode=block
< Content-Type: text/html;charset=utf-8
< Content-Length: 9172
< Via: 1.0 printer.gofreerange.com
< Vary: Accept-Encoding
< Connection: close
If the printer could communicate whether or not to supply rotated images for printing, then the server could provide more suitable print data.
This could possibly be done with another request header, along the lines of X-Printer-Orientation: Up
or something.
The error is when phantomjs is trying to find the file, I tried the printer mail app and the test page. :ENOENT: No such file or directory
Technically there's no reason why the data sent to the printer can't be the sequence of bytes representing all the commands the printer needs to operative, rather than an image which the remote printer must then process into 256-row chunks. The file could also contain all of the initialisation communication too.
One possible advantage of doing this is that text-based printing could be supported without changing the software that runs on the remote printer; it would just represent a different byte stream.
It's also possible that the printer could be connected using the native serial interface, saving more space on the arduino for more sophisticated networking/interface code.
It's not clear to me whether or not this is something that recap should control in it's foreman upstart export, but it looks like by default foreman doesn't set any of the services to start at a particular run-level.
Would it be possible to use a WiFi shield instead of an ethernet one?
http://www.amazon.com/Arduino-WiFi-Shield/dp/B009M8BU50
Thoughts?
It could be useful to know whether or not it's an Arduino or a Teensy or a Raspberry Pi that's connecting to the server, along with versions of the software they are using. We could use this information to tailor the response according to the capabilities of the agent.
At the moment, we get a stack trace.
Rather than hard coding the ID into the sketch, it would be good to generate a unique one. This could happen on first run, and be stored in EEPROM.
This raises the question of how to determine your printer URL if you have no visibility of the ID. To get around this, we could store the IP that a printer is polling against, and then match it against the IP of incoming requests to the web interface. This would allow us to pair a users web browser with the printer.
I have an issue with the heat time... if i set it to 10 it doesn't print almost anything, if I set to 240 I'm getting the same results like I set 100...
I'm using this tiny printer from adafruit (https://www.adafruit.com/products/2751) so I don't know if I need to set different parameters...the model used for other raspberryPi project is Zijiang ZJ-58...hope you can help me solving this!
Thank you
Can I use the code for the different prints without having the ethernet shield? I'm new to Arduino and coding so I'm having a bit of trouble. I plan on keeping the printer connected to my computer with the USB but I want to print the things available here using the code for the shield. How hard would it be to modify it for that purpose?
I wonder if it'd be possible to store some of the configuration, e.g. printer server, MAC address and printerType on the SD Card? This would avoid the need for each person to compile their own sketch but at the expense of a little more complexity in the code, and potentially more complexity in general. What do you think @lazyatom?
It looks like images with a lot of darkness in them cause the prints to corrupt; sometimes skipping parts of the image, sometimes resulting in garbage character output. See here for examples:
Tweaking the darkness setting for the printer right down seems to resolve this:
The first print (at the bottom) used a darkness of 150, and still demonstrated the error. The second print (at the top) used a darkness of 50, and printed successfully.
My current best guess is that the slow-down caused by the darkness results in some kind of buffer overrun within the printer. Introducing a delay(1)
after every 500 bytes sent to the printer resolves the problem, at the cost of a significant print speed reduction.
The A2 printers with "version 4" firmware print with a different intensity from those with "version 2.2". I slightly suspect that each printer is a little bit different, depending on the voltage and current available to it. It would be great to allow users to tweak the darkness of the printer from the web interface.
Hi,
First of all thanks a lot for making all this work open-source ! I'm planning on making a small box, receiving messages and printing them in a drawer, like a insta-mailbox on your desk, and your project is very helpful.
I've got an issue connecting the printer to the internet.
I'm hacking from a University and the connection here is protected by a proxy. After some extensive research, I found tips on how to bypass the proxy:
http://goo.gl/dnWhNl
So I tried to modify your code following the tips:
debug2("Attempting to connect to ", host);
if (client.connect("proxy.noc.titech.ac.jp", 3128)) { // the proxy URL and its port
digitalWrite(downloadLED, HIGH);
client.print("GET printer.gofreerange.com"); client.print("/printer/"); client.print(printerId); client.println(" HTTP/1.0");
client.print("Host: "); client.print(host); client.print(":"); client.println(port);
client.flush();
client.print("Accept: printer.gofreerange.com/application/vnd.freerange.printer."); client.println(printerType);
client.print("X-Printer-Version: "); client.println(sketchVersion);
client.println();
boolean parsingHeader = true;
The output is:
the yellow led turns on for 5 seconds, then turns off and the red led flashes 5 times. Then all the leds are off for 10 seconds.
The printer is not detected on: http://printer.gofreerange.com/my-printer
My question is, do you guys know if there are other parts of the code that should be modified?
Thank you !
Pierre
Getting this error when I try to start up the client. Any ideas?
./pi-printer.rb:15: syntax error, unexpected tLABEL, expecting ')'
def initialize(serial_port: "/dev/ttyAMA0")
^
./pi-printer.rb:15: syntax error, unexpected ')', expecting keyword_end
./pi-printer.rb:137: syntax error, unexpected keyword_end, expecting $end
I'm trying to do a fresh install using the minibian distro.
It won't let me install pi_piper saying that it requires RubyGems version >- 2.0.0
I have apt-get update
d
It suggests gem update --system
but I get an error saying this is disabled in Debian as it can break Debian.
Any advice on how to proceed?
(I then over-rode this to force a gem update and now get the following error when I run the printer script pi-printer.rb)
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- serialport (LoadError)
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ./pi-printer.rb:5:in `<main>'
Try printing any content with the font-family set to 'serif'. Weird.
At the moment, I have to ssh on and run sudo start printer
.
There's no reason why we can't generate the monochrome image as part of the preview process.
Like - if the printer URL was wrong (i.e. the ID was wrong)?
If you were using a printer to send a message, you might want it to appear without intervention by the recipient.
I think we might be able to do this elegantly using HTTP headers (e.g. X-Print: now
).
Some of the problems we've seen have been to do with the printer sketch size. @lazyatom mentioned that some of these are to do with older arduino bootloaders. I'm wondering whether it'd be possible to create a simple sketch to determine the bootloader version, and potentially other useful stats about a user's arduino, that would better help us diagnose problems.
Was playing with this at the weekend and never got it to work reliably, the cache file written as cache.write(client.read());
is always 0 bytes long.
I started wondering if this was my SD or ethernet board behaving weirdly so adapted a small test script that seems to run fine (see below).
Do you have any other suggestions as to what might be causing the problem? We tried removing the debouncing to reduce the flash memory usage below 30,000 but that didn't seem to help either
This is on an Arduino Uni with the Ethernet Shield and a 1gb/2gb/16gb microsd card (see the same issue with all three cards), have also tried formatting to Fat16 and Fat32 using various rools.
Test program which checks the card is working:
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
const int chipSelect = 4;
int loops = 0;
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x85, 0x7F };
void setup()
{
Serial.begin(9600);
while (!Serial) {
;
}
Serial.print("Initializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
Serial.print("Setting up network");
if(Ethernet.begin(mac)) {
Serial.println("Got ethernet");
} else {
Serial.println("Ethernet failed");
}
delay(1000);
Serial.print("IP: ");
Serial.println(Ethernet.localIP());
}
void loop()
{
String dataString = "";
for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";
}
}
File dataFile = SD.open("MYLOG.TXT", FILE_WRITE);
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
Serial.println(dataString);
}
else {
Serial.println("Failed to write to SD card: MYLOG.TXT");
while(true); // stop trying
}
loops++;
if(loops > 3) {
while(true); // stop trying
}
}
Output from test program:
Initializing SD card...card initialized.
Setting up networkGot ethernet
IP: 192.168.2.2
505,399,337
404,393,365
414,419,398
404,411,404
Output from printer program in debug mode:
0: Doing setup - I've added this
0: ID: 7p2x6b2w7n7w3q1e
20: SD card loaded - I've added this
5520: IP: 192.168.2.2
... snip ...
15759: Attempting to connect to printer.exciting.io
15845: Waiting for data
15845: Waiting for data
15846: Waiting for data
15855: Waiting for data
15881: Waiting for data
15907: Waiting for data
15933: Waiting for data
15988: Content length: 9185
17996: Waiting for data
17997: Server disconnected
18016: Failure, content length: 9185
length: 9185
18038: cache: 0
At the moment, the page image is stored in a file with the same name each time, so it's possible that a secondary prepare_page
process could overwrite the image before the rasterisation process reads the previous image in. I think this has already happened a few times.
I think the logic for determining if a pixel is "printed" or not doesn't handle transparent pixels well. To replicate this, print an image that is smaller than 384px - the areas without any background at all will be black unless the image is embedded in an HTML page with a white background.
When I try to print this page the printer jams and will not print. It will print the test page, the print-painter, the mail page sometimes jams as well.
http://definedcode.com/weather/
that's the page I am trying to print, it just jams. do you know why?
It's pretty annoying to run the tests, then start the server and have resque workers start.
With the raw print mechanism, if the server returns any content, it will be printed. For example, a 503 error if the server was waiting to restart will result in the HTML being printed.
Hello! I get this tiny printer from adafruit (https://www.adafruit.com/products/2751) that have USB connection too but I'm unable to make it works with your project... I edited the /boot/cmdline.txt line changing kgdboc=ttyAMA0,19200 to kgdboc=ttyUSB0,19200 but it didn't works!
Any help?
At the moment, I suspect that it does.
It should be possible for other people to reference a small CSS file served from http://printer.gofreerange.com which does some of the initial work to make an HTML page suitable for previewing and printing.
This CSS exists already to some extent in the 'wee-dtp' application.
Can we have a sort of App Directory of all the apps created for the printer, (or have you got one)?
The backend server has a bash injection vulnerability. The URL to print is not correctly escaped.
See:
https://github.com/exciting-io/printer/blob/master/lib/printer/jobs/prepare_page.rb#L39
If there are many rows of completely white space, it may be possible to send serial commands to feed that number of pixel rows, rather than sending the print commands for row after row of empty pixels.
I'm still seeing some malformed IDs in the server logs:
74.109.8.133 - - [15/Apr/2012 20:55:29] "GET /printer/i%FF%FF%FF%FF HTTP/1.1" 200 - 0.0024
It could be more attractive, have more fun stuff on it, be more legible (at the moment the text is tiny). Better!
At the very least, the job should fail; looks like at the moment PhantomJS doesn't even exit.
Most of the malformed URLs were simply missing the 'http://' at the start.
It would be useful to see everything that's been submitted (and printed) via the web.
It looks like if you send a URL that can't be reached (like http://localhost), the prepare page job just sits trying to access it. It would be better if it had a timeout to prevent the worker stalling.
I think unicorn can do application restarts without losing a single request, but I suspect that foreman is shutting it down completely and restarting it. This might be a quick fix for the issue where printers print out 503 errors after a deployment.
Whenever I try to upload the sketch to my board (Arduino Uno, R2), I get the error "avrdude: stk500_recv(): programmer is not responding". If I hold shift down and then press upload, I get: "avrdude: usbdev_open(): did not find any USB device "usb".
So far, this error only appears when I attempt to upload your printer.ino sketch, all other sketches upload properly, including this thermal printer example: http://bildr.org/2011/08/thermal-printer-arduino
I am attempting to upload it to the Arduino from my Mac with the latest Arduino software.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.