Pages: [1]   Go Down
Author Topic: Printing to a printer  (Read 475 times)
0 Members and 1 Guest are viewing this topic.
Maine
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
You blocked me on facebook and now youre going to die!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all, I am trying to print to my printer, but I dont know what the character encoding should be like.
I have code that sends data to the printer, but the formating stinks.  How can I print clear messages to the printer using the arduino?
are there libraries to help format the printer output?
this line:
#!/bin/bash \n for i in `seq 0 255` \n do \n nslookup 130.111.192.$i | grep flex \n done
prints out like:
#!/bin/bash
                            for i in `seq 0 255`
                                                             do
                                                                   nslookup 130.111.192.$i | grep flex
                                                                                                                          done

Code:
#include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE };
byte ip[] = { 192, 168, 1, 17 };
char data[] = {"#!/bin/bash \n for i in `seq 0 255` \n do \n nslookup 130.111.192.$i | grep flex \n done"};
byte server[] = { 192, 168, 1, 24 };  // the printer
EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  client.connect(server, 9100);
  delay(1000);

  Serial.println("connecting...");
  //we told it to connect, lets check it with the "connected" function

  if (client.connected()) {
    Serial.println("connected to printer");
    client.write(data);
   }
}

void loop()
{
// IDK I only want to print once.
}
Does anyone have more information about using the network functions for printing via the Arduino, and formatting printing?

I have all official hardware Arduino Uno, and Ethernet shield, and I run Linux if any of that matters.
« Last Edit: October 30, 2012, 11:41:14 pm by conradin » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Put...

\r

...in front of all...

\n
Logged

Pages: [1]   Go Up
Jump to: