Move code from intel galileo to Uno + Ethernet Shield

Hello all this is my fist post on here and i have very little experience in programming but here goes…

I have inherited the code attached from a university project to interface with a Pepperl+Fuchs R2000 laser scanner using a Galileo and am required to move it onto an arduino (preferably Uno)

So far i have changed the MAC address to the one on the Ethernet shield, and changed some of the output pins so as that they are not the ones used by the shield. But the code gets stuck at the initialising section within the setup routine.

The code compiles and uploads successfully but doesnt seem to connect to the scanner.

Im not sure what to try next? and any pointers would be great.

Many thanks

Martin

R2000_Setup_scan_V1_5_WIRE_COMMENTS.ino (13 KB)

  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);                             // Set pin 13 as an output for onboard LED.
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);                           // Switch LED off.

On a UNO, pins 10, 11, 12, and 13 are the SPI pins that the Arduino uses to communicate with the Ethernet shield. They are not available for use in your sketch.

void requestudp()
{
  while (true)
  {

Running an infinite loop in a function called in an infinite loop does not make sense.

      client.println("GET /cmd/request_handle_udp?address=169.254.94.210&port=1337&watchdogtimeout=120000&watchdog=off HTTP/1.0\r\n\r\n");

Are
you
sure
all
those
carriage
returns
and
line
feeds
are
needed?

any pointers would be great.

char *question = "Where in the initialization section does it get stuck?";

Not wasting memory unnecessarily is a good approach to adopt.
Serial.println(F("L: Serial port initialised."));

Hi thanks for your reply,

The code i uploaded was the original, not my modified version now attached, i have change output pin to 7, and commented out pin 13, arduino version attached to this post.

The code gets stuck at failed to connect, and then presumably on a timer runs out and prints connection failed later.

   // start the Ethernet connection:
  Ethernet.begin(mac, ip);                         // Initialise ethernet connection and connect
  delay(1000);                                     // to R2000 laser scanner
  Serial.println("L:  Initialising...");           
  if (Ethernet.begin(mac) == 0)                    // If ethernet connection has failed, print message
  {
    Serial.println("L:  Failed to connect.");
  }
  if (Ethernet.begin(mac) == 1)                    // If ethernet connection is successful, print
  {                                                // message.
    Serial.println("L:  Ethernet initialised.");   
  }
  else 
  {
    // if you didn't get a connection to the server:
    Serial.println("L:  connection failed");

The other comments you have made if im honest are way out of my depth, all i can say is that when compiling 67% of dynamic memory is used, is this likely to cause a problem? should i try a mega as an alternative?

Thanks again,

Martin

R2000_arduino.ino (13 KB)

char dataOut[7]={'z','z','z','z','z','z','/0'};

There is a major difference between '/0' and '\0'. Only one is what you want there (and not the one you used).

You need to post your serial output, too. Your vague recollection of the sequence of (very similar) messages doesn't cut it.