Go Down

Topic: Printing to a printer (Read 582 times) previous topic - next topic

conradin

Oct 31, 2012, 05:36 am Last Edit: Oct 31, 2012, 05:41 am by conradin Reason: 1
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: [Select]

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

Coding Badly


Put...

\r

...in front of all...

\n

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy