Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: Recieve Serial and send out TCP IP on: October 22, 2011, 10:10:28 am
I played with a little more and I one major flaw is that the print queue does no wait for it. I am able to send print jobs one after the other and they write over each other. Does arduino need to tell the windows it is busy and when it is ready? Does anyone have experience with this.

I believe if I was able to do this then there would be no need to buffer the print job.
2  Using Arduino / Project Guidance / Re: Recieve Serial and send out TCP IP on: October 21, 2011, 10:20:24 pm
First your note about putting in a timeout is a good idea. Thank You. 

I guess the only thing that I am really worried about is that if I receive a Print job while not connected. Will I just loose part of it?
3  Using Arduino / Project Guidance / Recieve Serial and send out TCP IP on: October 21, 2011, 09:00:33 am
I have a Sparkfun Pro Ethernet. I have a computer that prints reports for a manufacturing process, each report is about 2000 bytes of text. I have set up Ethernet pro usb as a generic text printer in windows, and the pc prints the report and arduino catches it and sends it over TCP/IP to a Server.  Below is the code i am using.

I was thinking that it would be better to buffer the whole text and try to send it several TCP packets instead of a byte at a time like it is now. And this way I could hold on to it connect to server send and then disconnect. But will i need to get an arduino Mega to be able to do this.  I was just trying to get someone elses thoughts on this.


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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,177 };
byte server[] = { 192,168,1,3 };

unsigned long lastconnected;
unsigned long lastdisconnected;
unsigned long currenttime;

int count = 0;

Client client(server, 7000);

void setup()
{
   Ethernet.begin(mac, ip);
   Serial.begin(9600);

   delay(1000);

   if (client.connect()) {
      lastconnected = millis();
   }
}

void loop()
{
   if (Serial.available() > 0) {            //Resend printed data from Serial out TCP
     if(client.connected()){         
      char incomingByte = Serial.read();
      if(incomingByte!= 0x0C){
        client.print(incomingByte);
        count++;
      }
      if (incomingByte == 0x0C){  // Sees Form Feed Stops and disconnects
          client.println(incomingByte);
          client.println("End of Ticket");  // Marks end of print job
          client.println(count);
          client.stop();
          lastdisconnected = millis();
          count=0;
         }       
    }
   }
 
   if (millis() - lastconnected > 540000 && client.connected()){    // Disconnects after connected for nine minutes
     client.stop();
     lastdisconnected = millis();
     delay(100);
           
   }
   
   if (!client.connected() && (millis() - lastdisconnected > 100)){  //If disconnected,  reconnect
     client.connect();
     lastconnected = millis();
     delay(1000);
   }
}
4  Using Arduino / Networking, Protocols, and Devices / Re: Arduino capture text and resend out Ethernet on: September 24, 2011, 02:02:49 pm
the second delay.
Code:
delay(3);    //wait for whole message

It was skipping characters.
5  Using Arduino / Networking, Protocols, and Devices / Re: Arduino capture text and resend out Ethernet on: September 23, 2011, 01:02:37 pm
Thank You so much. I had thought that it was resetting but had no idea why. I put the resistor in and took the delay out and it works great.

Thanks
6  Using Arduino / Networking, Protocols, and Devices / Arduino capture text and resend out Ethernet on: September 23, 2011, 11:08:15 am
I have a need to print to an arduino usb port and have it resend the text to a TCP server. I have a program and want to send process info to the "main office". My thought is to have it print to the arduino. I installed the arduino on a win xp machine told the pc it was a genric text only printer. Then i set the arduino to resend to "TCP Server". As a test I used Hercules SETUP Utility by HW-group.com to catch it. The problem is that when i send a test print page it only captures about 2 sentences in the middle of the page. I am using a Sparkfun Arduino Pro Ethernet with a FTDI Basic.

Below is my sketch. What am I missing. The text that i want to send  is about a paragraph worth the text at a time every couple minutes. Because of the software on the PC for the Process I think this is the easiest way to get info out of it with out modifying the program.

Any help or ideas wold be great!!

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,177 };
byte server[] = { 192,168,1,3 };

Client client(server, 7000);

void setup()
{
   Ethernet.begin(mac, ip);
   Serial.begin(9600);

   delay(1000);

   if (client.connect()) {
      client.println("Connected");
      client.println();
   }
}

void loop()
{
   if (client.available()) {
      char c = client.read();
      Serial.print(c);
   }
   
   if (Serial.available() > 0) {
     char incomingByte = Serial.read();
    client.print(incomingByte);
     delay(3);    //wait for whole message
   }
   

   if (!client.connected()) {
      client.stop();
      for(;;)
         ;
   }
}

Pages: [1]