12 Replies Latest reply on Nov 13, 2014 1:37 PM by Intel_Alvarado

    udp.parsePacket issues

    GISMikeMyers

      Hi everyone,

       

         I am having a problem with udp.parsePacket.  I am trying to move a program that I have been using on the Uno and Mega over to the Galileo.  On my second read of udp.ParsePacket it just freezes, never hits the next line.

       

         I have stripped down my code to just the basics thinking it may be something else not compatible but I cannot figure it out.  I have seen a few mentions of others having a similar issue but no solutions that I could find.

       

         Any thoughts would be greatly appeciated.

       

      Oh, here is the test code and the output:

       

      #include #include          // needed for Arduino versions later than 0018
      #include 
      EthernetUDP Udp;
      
      void setup() {
           
      }
      
      void loop() {
        uint16_t packetSize = 0;
        
        while(true) {     
          Serial.println("A2");
          packetSize = Udp.parsePacket();
                                         
          Serial.println(packetSize);
                
          if (Udp.available() && packetSize !=0)   {  
            Serial.println("A22");
          } else {
            Serial.println("A31");
            break;     
          }
                
        }
        Serial.println("A3");     
      }
      

       

      And here is the output:

       

              A2
           20
           A22
           A2
           20
        • 1. Re: udp.parsePacket issues
          GISMikeMyers

          Anyone have an ideas for this problem?

          • 2. Re: udp.parsePacket issues
            Intel_Alvarado

            Hi GISMikeMyers,

            I believe that you need to set a port to listen if there are any UDP packets. Maybe initializing a port value and add udp.begin(port) in the void setup() part of your code. Let me know if this worked.

            Regards

            Sergio

            • 3. Re: udp.parsePacket issues
              GISMikeMyers

              Agreed for some reason nothing in my setup made it to the post.  Here is what I have running now.  I added some debugging. I can duplicate the issue 100% of the time.  This exact sketch minus the 2 lines that are setting the ip address work fine on uno or mega.  When this locks up it locks up really good, it never comes out of it.  The blinking I added stops.    Also, see the output log after the code.  After the log, look at the image capture from the top command in clanton after the lockup.

               

              #include #include          // needed for Arduino versions later than 0018
              #include #include 
              EthernetUDP Udp;
              
              long timeout=0;
              bool onoff = false;
              
              void setup() {
                Udp.begin(12345);
                Serial.begin(115200);
                pinMode(13, OUTPUT);
                
                system("ifconfig eth0 10.232.1.251 netmask 255.255.255.0 up");
                system("route add default gw 10.232.1.1");
              }
              
              void loop() {
                uint16_t packetSize = 0;
                
                if (millis() >= timeout) 
                {
                  if (onoff) {
                    digitalWrite(13, LOW);
                    onoff = false;
                  } else {
                    digitalWrite(13, HIGH);
                    onoff = true;
                  }
                    
                  timeout = millis() + 1000;
                }
                
                while(true) {     
                  Serial.println("A2");
                  packetSize = Udp.parsePacket();
                                                 
                  Serial.println(packetSize);
                        
                  if (Udp.available() && packetSize !=0)   {  
                    Serial.println("A22");
                  } else {
                    Serial.println("A31");
                    break;     
                  }
                        
                }
                Serial.println("A3");     
              }

               

              Output:

              A2
              0
              A31
              A3
              A2
              21
              A22
              A2
              

               

              This is just the last time it passed by ok then the failure.  The A2 is before the UDP read, 0 bytes to read everything goes ok.  next A2 there are 21 bytes to read.  A22 passes by then back to A2 and then the udp read and that is where it freezes up.

               

              Checkout the top command:

               

              galileolockup.png

               

              I am stumped and really need to get this to work.  You can take my ketch upload it then just send any number of bytes to the UDP port and it locks up.

               

              Mike

              • 4. Re: udp.parsePacket issues
                GISMikeMyers

                Is there a way to report a bug to intel for this?  After much more time researching I have it down to a few scenerios.  I looked at the library for UDP.  Upon further testing I know that if I call just UDP.read() it locks up.  The flush function calls UDP.read() until there in no more data using the UDP.available function (more on this in a bit) and flush locks up as well.  The UDP.parsepacket function calls flush before reading in data.  So it looks like something in just read.  However, there are other anomalies as well.

                 

                Here is a snippet of code:

                 

                Serial.print("Udp Avail before: ");
                Serial.println(Udp.available());
                Udp.read(_packetBuffer, 25);
                Serial.print("Udp Avail after: ");
                Serial.println(Udp.available());
                

                 

                Here is the output:

                 

                Udp Avail before: 26
                Udp Avail after: 26

                 

                As you can see, doing a UDP.read(variable, numbertoread) does not decrement the UDP.Available() as it should.  So there is a bug around that as well.

                 

                I am running the arduino IDE on a Mac, I have not tried on Windows but I am not sure why that would make a difference.

                 

                Anyone have any ideas before I give up on the Galileo and look for a better CPU?

                 

                BTW..  This is the 1st generation, I ordered a 2nd generation just to see if anything would change.

                • 5. Re: udp.parsePacket issues
                  Intel_Alvarado

                  Hi GISMikeMyers,

                  We will report this bug to the appropriate team, thank you for letting us know about this. Regarding the UDP functions not working correctly, there might be some problems with the libraries that make this functions work. Why don’t you try using python scripts instead of the code you use in the IDE. The python code can be used in the Linux console. Take a look at this link https://wiki.python.org/moin/UdpCommunication for a couple examples on how the UDP communication would work on Python.

                  Regards

                  Sergio

                  • 6. Re: udp.parsePacket issues
                    Intel_Alvarado

                    Also, what software release are you using?

                    Regards

                    Sergio

                    • 7. Re: udp.parsePacket issues
                      GISMikeMyers

                      I assume you are wanting the IDE version.  I am using the 1.5.3 version that fixes the boot from sd card issue.  I am running it on a Mac.  I also tried the other 1.5.3 version that had the problem with booting from the SD card and it has the same issue.

                      • 8. Re: udp.parsePacket issues
                        Intel_Alvarado

                        There is a new software release v1.0.4 for the Galileo board https://communities.intel.com/docs/DOC-23388 , you have to download the IDE of this version and upgrade the firmware version you have so that it matches the new image available. Download this new image and let us know if this resolved your issue.

                        Regards

                        Sergio

                        • 9. Re: udp.parsePacket issues
                          GISMikeMyers

                          It is the same after downloading the new version and updating the firmware.  I did have more problems uploading the sketch after the upgrade.  I kept seeing errors and failed uploads.  I cannot duplicate that right now, but for this thread, the udp issue still exists.  The version now says 1.5.3-intel 1.0.4.

                          • 10. Re: udp.parsePacket issues
                            Intel_Alvarado

                            Hi GISMikeMyers,

                            This might be a bug in the IDE software remoteIP() and remotePort() are not returning the correct values. We will report this bug to the appropriate team.

                            Regards

                            Sergio

                            • 11. Re: udp.parsePacket issues
                              GISMikeMyers

                              What is the typical turnaround for bug fixes?  Is there a way to track when this is fixed?  I have a project I would really like to use this board for but cannot wait too long till I need to find another option.

                              • 12. Re: udp.parsePacket issues
                                Intel_Alvarado

                                Hi GISMikeMyers,

                                 

                                In general each bug is different and there is no ETA, we will share more information once it is available.

                                 

                                Regards

                                Sergio