arduino uno ethernet fail

Hi guys,

I got a code from my software vendor.
It needs to get http request when the button is pressed.

Unfortunately, arduino gives a lot of errors to this code.

I do not understand what goes wrong, can you help me?

#include <SPI.h>
#include <Ethernet2.h>

// this must be unique
byte mac[] = {
  0xFE, 0xE7, 0xDE, 0xB0, 0xDC, 0x9B
};

int systemState = 0;

// change to your network settings
IPAddress ip(192, 168, 1, 110);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

// change to your server
IPAddress server(192, 168, 178, 104);

char serverName[] = “192, 168, 178, 104”;
// change to your server’s port

int serverPort = 14999;

EthernetClient client;
int totalCount = 0;
char pageAdd[64];

//buttonPin

const int buttonPin = 2; // the number of the pushbutton pin
void setup() {

  Serial.begin(9600);
  // disable SD SPI


  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);

  //button pin mode

  pinMode(buttonPin, INPUT);

  // Start ethernet

  Serial.println(“Starting ethernet…”);
  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  Serial.println(Ethernet.localIP());

  delay(2000);
  Serial.println(“Ready”);
}
void loop() {

  if (systemState == 0) {
    pushButton();
  }
}

byte getPage(IPAddress ipBuf, int thisPort, char *page)
{
  int inChar;
  char outBuf[128];

  Serial.print(F(“connecting…”));

  if (client.connect(ipBuf, thisPort) == 1)
  {
    Serial.println(F(“connected”));

    sprintf(outBuf, ”GET % s HTTP / 1.1″, page);
    client.println(outBuf);
    sprintf(outBuf, ”Host: % s”, serverName);
    client.println(outBuf);
    client.println(F(“Connection: close\r\n”));
  }
  else
  {
    Serial.println(F(“failed”));
    return 0;
  }

  // connectLoop controls the hardware fail timeout


  int connectLoop = 0;

  while (client.connected())
  {
    while (client.available())
    {
      inChar = client.read();
      Serial.write(inChar);

      // set connectLoop to zero if a packet arrive

      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet


    if (connectLoop > 10000)
    {

      // then close the connection from this end.

      Serial.println();
      Serial.println(F(“Timeout”));
      client.stop();
    }

    // this is a delay for the connectLoop timing


    delay(1);
  }

  Serial.println();

  Serial.println(F(“disconnecting.”));

  // close client end

  client.stop();

  return 1;
}

//Send get request to Houdini if button was pressed


void pushButton() {
  if (digitalRead(buttonPin) == HIGH) {

    // send request to Houdini

    sprintf(pageAdd, ” / Custom_Term”); (!getPage(server, serverPort, pageAdd));
    Serial.println(“Button pressed”);
    systemState == 1;

  }
}

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor you will not have access to this useful tool. I recommend you to use the standard IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we’re trying to read your code.

When you encounter an error you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

(deleted)

edit code.

i can't upload the error, the file is to big.

Thanks for auto formatting the code. That makes it much easier to read. I didn't even want to look at it before. If I paid someone for code and it came to me looking like that I'd be quite skeptical about the quality of their work.

Put the error output in a text file and post that file as an attachment.

I do not understand what goes wrong

But the error message should tell you what does it say?

When I try it it tells me I haven’t installed the Ethernet2 libiary, have you? Where did you get that libiary from, please supply a link.

strange, the error message is smaller now.

Arduino: 1.6.10 (Windows 8.1), Board:"Arduino/Genuino Uno"

testethernet:73: error: missing terminating " character

    sprintf(outBuf, "GET % s HTTP / 1.1″, page);

    ^

C:\Users\spotify10\Documents\Arduino\testethernet\testethernet.ino: In function 'void loop()':

testethernet:58: error: 'pushButton' was not declared in this scope

    pushButton();

               ^

C:\Users\spotify10\Documents\Arduino\testethernet\testethernet.ino: In function 'byte getPage(IPAddress, int, char*)':

testethernet:74: error: expected ')' before ';' token

    client.println(outBuf);

                          ^

exit status 1
missing terminating " character

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
[b][/b]

ethernet2 library:

(deleted)

[quote author=tonygils link=msg=3437615 date=1507239478]
testethernet:73: error: missing terminating " character

    sprintf(outBuf, "GET % s HTTP / 1.1″, page);

Even though it looks like a standard quotation mark at the end of the string on line 73:

   sprintf(outBuf, "GET % s HTTP / 1.1″, page);

If you look closely it's not (″ vs. ").

tonygils:
strange, the error message is smaller now.

The reason it was so much longer before is that the Ethernet2 library causes a bunch of compiler warnings. After the first compilation the Arduino IDE caches the compiled library and uses that compiled file for all future compilations unless the library is modified or you change to a different selection in the Tools > Board menu (in which case the library is re-compiled on the next compilation). The reason for this is to make subsequent compilations faster. Since the library wasn't re-compiled the second time, you don't get any of its warnings in the compilation output.

pert:

The reason it was so much longer before is that the Ethernet2 library causes a bunch of compiler warnings. After the first compilation the Arduino IDE caches the compiled library and uses that compiled file for all future compilations unless the library is modified or you change to a different selection in the Tools > Board menu (in which case the library is re-compiled on the next compilation). The reason for this is to make subsequent compilations faster. Since the library wasn't re-compiled the second time, you don't get any of its warnings in the compilation output.

[/quote]

thanks! now i can compile without errors.