Pages: [1]   Go Down
Author Topic: Python to Arduino via Ethernet Xport  (Read 555 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to send a simple test message from a python program to my arduino over ethernet. The arduino has an Xport ethernet shield from adafruit. I can't seem to get the arduino to receive the message.

Here is my Python script:
Code:
       print "sending TCP packets"
        port = 40000
        host = "192.168.1.155"
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((host,port))
        s.send('Hello, world')
        #s.sendto("Send complete!", (host,port))
        s.close()

Here is my basic wait function for my arduino:
Code:
uint16_t requested(void)
{
  uint8_t read, x;
  char *found;
  Serial.print(".");
  while (1) {
    read = xport.readline_timeout(linebuffer, 128, 200);
    //Serial.println(read, DEC);   // debugging output
    if (read == 0)     // nothing read (we timed out)
      return 0;
    if (read)          // we got something!
    {
      Serial.println("Got something!");
      Serial.println(linebuffer);
    }
  }
}
With the Loop running that method every time.

This is what my Xport configuration screen looks like:


I've also tried adjusting the port forwarding settings on my router to forward everything to the arduino.

Anyone who's done something similar I would happy to know how you got it working. Thanks!
Logged

Pages: [1]   Go Up
Jump to: