Coder Social home page Coder Social logo

exciting-io / printer Goto Github PK

View Code? Open in Web Editor NEW
476.0 476.0 94.0 700 KB

Tools for exploring the possibilities of "internet of things" printing.

Home Page: http://exciting.io/printer

License: MIT License

Ruby 57.25% HTML 20.32% JavaScript 6.68% Shell 4.86% C++ 8.32% SCSS 2.51% Procfile 0.06%

printer's People

Contributors

chrisroos avatar chrisroos-and-lazyatom avatar lazyatom avatar martinseener avatar tomafro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

printer's Issues

unexpted tLABEL

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

More accurate previews

There's no reason why we can't generate the monochrome image as part of the preview process.

Allow expiry of unprinted data

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?

Failure, content length: 9185, cache: 0

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

Preview stalls with malformed URLs

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.

ID generation is still not reliable

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

Support different orientations

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.

Heat time doesn't works

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

Send User-Agent information to the server

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.

Server returns wrong Content-Type response header

(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

App Directory

Can we have a sort of App Directory of all the apps created for the printer, (or have you got one)?

Prepare page hangs

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.

Prevent other requests overwriting content

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.

Create a diagnostic sketch

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.

Start server on reboot

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.

Some things should be printed immediately

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).

Store some configuration on the SD Card

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?

Cannot install pi_piper on minibian (Raspberry Pi)

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 updated

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>'

Only print if the response code was 200

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.

Compress whitespace in output

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.

Transparent pixels print as black

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.

Protect print URLs with OAuth2

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.

Auto printer ID generation

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.

Move printing logic into the server

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.

Help content services reject invalid print URLs

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).

Make the test page better

It could be more attractive, have more fun stuff on it, be more legible (at the moment the text is tiny). Better!

USB Printer

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?

Very dark images often result in corrupt prints

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.

User control of printer darkness

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.

"avrdude: stk500_recv(): programmer is not responding" issue

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.

Printer without ethernet shield

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?

Connecting the printer via a Proxy

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

Restarting app shouldn't drop requests

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.