Jump to content


  • Content Count

  • Joined

  • Last visited

About Elrayes

  • Rank
    Noob Class

Profile Information

  • Location
  • Interests
    Embedded networking, control and rbotics
  1. Elrayes

    TCP/IP client

    Hello Gentlemen, I'm trying to develop a TCP/IP client with the new TI Connected LaunchPad board but I have some problem with the code that I couldn't figure out and maybe someone can give me a hand, here is the code (based on the Web client example but with some modifications): #include <Ethernet.h> // Enter a MAC address for your controller below. byte mac[] = { 0x00, 0x1F, 0xB0, 0x02, 0xFE, 0x30 }; IPAddress ipLocal(169,254,41,200); IPAddress server(169,254,41,198); unsigned int localPort = 8080; // local port to listen on char SendBuffer[] = "Something to send\n"; //test data char ReceiveBuffer[64] = " "; //receive buffer // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client; void setup() { //start the Ethernet Ethernet.begin(mac,ipLocal, server); Ethernet.enableLinkLed(); Ethernet.enableActivityLed(); //Connect to server client.connect(server, localPort); //start the serial library: Serial.begin(9600); Serial.println("\n\nTCP/IP Client setup"); // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } // print your local IP address: Serial.print("My IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); Serial.print("connecting to server\n"); //Serial.println(server); server.printTo(Serial); // if you get a connection, report back via serial: if (client.connect(server, localPort)) { Serial.println("connected to"); server.printTo(Serial); // Make a HTTP request: //client.println("GET /search?q=arduino HTTP/1.0"); //client.println(); } else { // kf you didn't get a connection to the server: Serial.println("connection failed"); } } void loop() { // if there are incoming bytes available // from the server, read them and print them: if (client.available()) { char c = client.read(); Serial.print(c); } client.write(SendBuffer); // if the server's disconnected, stop the client: if (!client.connected()) { Serial.println(); Serial.println("disconnecting."); client.stop(); // do nothing forevermore: while(true); } } //End of code On the serial monitor it displays "TCP/IP Client setup" then stops, when I try to find the board using "arp -a" command from the windows cmd it shows nothing about the board (neither the MAC nor the IP address I have assigned to it), tried to connect to the board using a small sockets example written in C++ and for sure nothing happened (just to make sure windows networking utilities aren't screwed). Thanks in advance folks
  • Create New...