8 Replies Latest reply on Jul 3, 2014 5:04 PM by BuffordHumbkingle

    Galileo Telnet Problem

    BuffordHumbkingle

      Hello guys!,

      I recently tried to upload the wifichatserver example sketch onto the Galileo. In the code, I also added an if statement that checks if the client pressed the "r" button on his keypad.

      When I run the code, instead of reading one input when I press one button, it reads two inputs. I wanted to know if you guys know how to solve this problem. Thanks!

      Regards,

      Bufford

        • 1. Re: Galileo Telnet Problem
          AlexT_Intel

          Hi Bufford,

           

          As I mentioned in another post we started discussing this in - please post the sketch by attaching to the post (preferrable) or just pasting.

           

          Even though the change you've made may be trivial, it can be done in ten different ways by ten different people, probably, so it's better to work on exactly the thing you're having troubles with, rather than something each of the readers may come up with :-)

          • 2. Re: Galileo Telnet Problem
            BuffordHumbkingle

            I AllexT_Intel,

            Sorry about that.

             

             

             

             

            /*

            Chat  Server

             

            A simple server that distributes any incoming messages to all

            connected clients.  To use telnet to  your device's IP address and type.

            You can see the client's input in the serial monitor as well.

             

            This example is written for a network using WPA encryption. For

            WEP or WPA, change the Wifi.begin() call accordingly.

             

             

            Circuit:

            * WiFi shield attached

             

            created 18 Dec 2009

            by David A. Mellis

            modified 31 May 2012

            by Tom Igoe

             

            */

             

             

            #include <SPI.h>

            #include <WiFi.h>

             

             

            char ssid[] = "yourNetwork"; //  your network SSID (name)

            char pass[] = "secretPassword";    // your network password (use for WPA, or use as key for WEP)

             

             

            int keyIndex = 0;            // your network key Index number (needed only for WEP)

             

             

            int status = WL_IDLE_STATUS;

             

             

            WiFiServer server(23);

             

             

            boolean alreadyConnected = false; // whether or not the client was connected previously

             

             

            void setup() {

              //Initialize serial and wait for port to open:

              Serial.begin(9600);

              while (!Serial) {

                ; // wait for serial port to connect. Needed for Leonardo only

              }

             

              // check for the presence of the shield:

              if (WiFi.status() == WL_NO_SHIELD) {

                Serial.println("WiFi shield not present");

                // don't continue:

                while(true);

              }

             

             

              String fv = WiFi.firmwareVersion();

              if( fv != "1.1.0" )

                Serial.println("Please upgrade the firmware");

             

              // attempt to connect to Wifi network:

              while ( status != WL_CONNECTED) {

                Serial.print("Attempting to connect to SSID: ");

                Serial.println(ssid);

                // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   

                status = WiFi.begin(ssid, pass);

             

             

                // wait 10 seconds for connection:

                delay(10000);

              }

             

             

              // start the server:

              server.begin();

              // you're connected now, so print out the status:

              printWifiStatus();

            }

             

             

             

             

            void loop() {

              // wait for a new client:

              WiFiClient client = server.available();

             

             

             

             

              // when the client sends the first byte, say hello:

              if (client) {

                if (!alreadyConnected) {

                  // clead out the input buffer:

                  client.flush();   

                  Serial.println("We have a new client");

                  client.println("Hello, client!");

                  alreadyConnected = true;

                }

             

             

                if (client.available() > 0) {

                  // read the bytes incoming from the client:

                  char thisChar = client.read();

                  // echo the bytes back to the client:

                  server.write(thisChar);

                  // echo the bytes to the server as well:

                  Serial.write(thisChar);

                }

              }

            }

             

             

             

             

            void printWifiStatus() {

              // print the SSID of the network you're attached to:

              Serial.print("SSID: ");

              Serial.println(WiFi.SSID());

             

             

              // print your WiFi shield's IP address:

              IPAddress ip = WiFi.localIP();

              Serial.print("IP Address: ");

              Serial.println(ip);

             

             

              // print the received signal strength:

              long rssi = WiFi.RSSI();

              Serial.print("signal strength (RSSI):");

              Serial.print(rssi);

              Serial.println(" dBm");

            }

             

             

             

            Thanks again

            Bufford

            • 3. Re: Galileo Telnet Problem
              SpiderKenny

              Hi Bufford

              I don't see anything in that sketch that looks for the 'r' key in the input?

              • 4. Re: Galileo Telnet Problem
                BuffordHumbkingle

                Im so sorry about that SpiderKenny!

                Here is the actual code:

                 

                 

                /*

                Chat  Server

                 

                A simple server that distributes any incoming messages to all

                connected clients.  To use telnet to  your device's IP address and type.

                You can see the client's input in the serial monitor as well.

                 

                This example is written for a network using WPA encryption. For

                WEP or WPA, change the Wifi.begin() call accordingly.

                 

                 

                Circuit:

                * WiFi shield attached

                 

                created 18 Dec 2009

                by David A. Mellis

                modified 31 May 2012

                by Tom Igoe

                 

                */

                 

                 

                #include <SPI.h>

                #include <WiFi.h>

                 

                 

                char ssid[] = "yourNetwork"; //  your network SSID (name)

                char pass[] = "secretPassword";    // your network password (use for WPA, or use as key for WEP)

                 

                 

                int keyIndex = 0;            // your network key Index number (needed only for WEP)

                 

                 

                int status = WL_IDLE_STATUS;

                 

                 

                WiFiServer server(23);

                 

                 

                boolean alreadyConnected = false; // whether or not the client was connected previously

                 

                 

                void setup() {

                  //Initialize serial and wait for port to open:

                  Serial.begin(9600);

                  while (!Serial) {

                    ; // wait for serial port to connect. Needed for Leonardo only

                  }

                 

                  // check for the presence of the shield:

                  if (WiFi.status() == WL_NO_SHIELD) {

                    Serial.println("WiFi shield not present");

                    // don't continue:

                    while(true);

                  }

                 

                 

                  String fv = WiFi.firmwareVersion();

                  if( fv != "1.1.0" )

                    Serial.println("Please upgrade the firmware");

                 

                  // attempt to connect to Wifi network:

                  while ( status != WL_CONNECTED) {

                    Serial.print("Attempting to connect to SSID: ");

                    Serial.println(ssid);

                    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   

                    status = WiFi.begin(ssid, pass);

                 

                 

                    // wait 10 seconds for connection:

                    delay(10000);

                  }

                 

                 

                  // start the server:

                  server.begin();

                  // you're connected now, so print out the status:

                  printWifiStatus();

                }

                 

                 

                 

                 

                void loop() {

                  // wait for a new client:

                  WiFiClient client = server.available();

                 

                 

                 

                 

                  // when the client sends the first byte, say hello:

                  if (client) {

                    if (!alreadyConnected) {

                      // clead out the input buffer:

                      client.flush();   

                      Serial.println("We have a new client");

                      client.println("Hello, client!");

                      alreadyConnected = true;

                    }

                 

                 

                    if (client.available() > 0) {

                      // read the bytes incoming from the client:

                      char thisChar = client.read();

                      // echo the bytes back to the client:

                      if (thisChar == 0x72){          //the r key is hex in ascii is represented by 0x72

                        client.print("you pressed the 'r' key");

                      }

                      server.write(thisChar);

                      // echo the bytes to the server as well:

                      Serial.write(thisChar);

                    }

                  }

                }

                 

                 

                 

                 

                void printWifiStatus() {

                  // print the SSID of the network you're attached to:

                  Serial.print("SSID: ");

                  Serial.println(WiFi.SSID());

                 

                 

                  // print your WiFi shield's IP address:

                  IPAddress ip = WiFi.localIP();

                  Serial.print("IP Address: ");

                  Serial.println(ip);

                 

                 

                  // print the received signal strength:

                  long rssi = WiFi.RSSI();

                  Serial.print("signal strength (RSSI):");

                  Serial.print(rssi);

                  Serial.println(" dBm");

                }

                 

                 


                Regards,

                Bufford

                • 5. Re: Galileo Telnet Problem
                  AlexT_Intel

                  Okay, thanks and now - what's the expected behavior and what do you get? I don't have the board at hand right now to actually try, unfortunately.

                   

                  Are you trying to say that instead of reading one character it reads two? How do you determine that?

                  • 6. Re: Galileo Telnet Problem
                    Clayton Hofrock

                    I have run into this same problem with a different sketch.

                     

                    The Serial console window in the Arduino IDE has different settings on how it terminates the data it transfers. You will want to try using the different settings.
                    .

                    telnet.JPG

                    • 7. Re: Galileo Telnet Problem
                      AlexT_Intel

                      Good point! Yeah, that may very well be the reason for the strangeness Bufford sees.

                      1 of 1 people found this helpful
                      • 8. Re: Galileo Telnet Problem
                        BuffordHumbkingle

                        Thanks for the response Clayton,

                        I changed the settings, and it seems to be working nicely now!

                        Regards,

                        Bufford