4 Replies Latest reply on May 22, 2017 1:12 PM by Intel Corporation

    End of line issue in Edison with telegesis

    shubham0000gupta

      Hi All,

       

      Thanks for looking at this issue.

       

      I am facing this issue from the beginning. I have 3 Edisons with me I tried

       

      Use Conditions:

      • Edison yocto linux kernel image -> 3.10.78 (I think this is latest available)
      • Telegesis dongle firmware version -> Telegesis ETRX357 R310
      • Iotivity version -> 1.1.0
      • ARDUINO BREAKOUT KIT

       

      When i build Iotivity for System(Ubuntu Linux) It is building successfully and after running with telegesis dongle it worked properly as expected.

       

      When i build Iotivity for Edison(yocto) It is building successfully and after running with telegesis dongle it is giving error.

       

      Telegesis is sending/receiving commands via socket file. It is using \r and then \n to terminate a line(AT commands). But in Edison, telegesis is terminating the line(AT commands) with \n and then \n. Means it is interpreting(converting) \r as \n. I think this may be problem with Linux kernel.

       

      Please help me with this issue because i am not able to get the endofline because some time Telegesis is putting \n\n to show endofline or some time with \n\n\n.

       

                  if(bufferChar == '\r')

                  {

                      endOfLine1 = true;

                      continue;

                  }

                  if(bufferChar == '\n')

                  {

                      endOfLine2 = true;

                      continue;

                  }

       

      With consecutive \r for endofline it is giving \n. This above code looks good of this type of condition. but with Edison consecutive \n are coming which is making programming very complex to come to the endofline.

       

      Thanks for time to look at this issue. if possible please give me correct procedure to solve this.

       

      Thanks and Regards

      Shubham Gupta

        • 1. Re: End of line issue in Edison with telegesis
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Shubham,

           

          Thanks for reaching out!

           

          First of all, I'd like to point out that you are not using the latest image. The kernel on the latest image is 3.10.98 not 3.10.78, you can download the latest image in https://software.intel.com/en-us/iot/hardware/edison/downloads. I'd suggest you to update your Edison and try again to see if the issue persists before trying anything else.

           

          Regarding the main issue, I haven't worked with Iotivity or Telegesis but following the snippet you posted above, you can create a logic that detects both signals \r\n and \n\n and that leaves simple \n signals alone this is how the logic would look like:

           

          //The signal \r means carriage return
          //The signal \n means new line
          //Both \r\n and \n\n will be taken as the end line signal
          //Both \r and \n individually should not be taken as the end line signal
          
          bool endOfLine = false;
          //When endOfLine is true, it means that the last signal was \r\n or \n\n
          bool lastchr = false;
          //When lastchr is true, it means that the last character is \r
          bool lastchn = false;
          //When lastchn is true, it means that the last character is \n
          
          .
          .
          .
          
          if(bufferChar == '\r')
          {
           lastchr = true; //The last character is \r
           lastchn = false; //The last character is not \n
              continue;
          }
          
          if(bufferChar == '\n')
          {
           if(lastchr == true)
           {
            endOfLine = true; //you've encountered the signal \r\n, end of line
            
            //Reset lastchr and lastchn here if needed, you could also reset them before 
            //the loop, it's up to you.
          
            //break; 
            
            //I'm not sure if there should be a break here or not or perhaps a continue,
            //this depends on how you manage the end of line signal, so I'm simply going 
            //to leave it as a comment.
            //Maybe you don't even need endOfLine and simply exit loop with break, I'll 
            //leave this up to you
           }
           if(lastchn == true)
           {
            endOfLine = true; //you've encountered the signal \n\n, end of line
          
            //Reset lastchr and lastchn here if needed, you could also reset them before 
            //the loop, it's up to you.
          
            //break; 
            
            //I'm not sure if there should be a break here or not or perhaps a continue,
            //this depends on how you manage the end of line signal, so I'm simply going 
            //to leave it as a comment.
            //Maybe you don't even need endOfLine and simply exit loop with break, I'll 
            //leave this up to you
           }
           lastchn = true; //The last character is \n
           lastchr = false; //The last character is not \r
              continue;
          }
          
          //Note that the following lines are executed only after we've verified that the 
          //characters are not \r or \n
          if(bufferChar != '\r' && bufferChar != '\n')
          {
           lastchr = false;
           lastchn = false;
           //We do not force the following loop iteration with continue
          }
          

           

          Note that if we remove the comments the logic is very simple and small, so I think it might be of help for you. However, if this does not help you, I'd suggest you to contact either Iotivity or Telegesis for further assistance. You can contact them at the following sites:

           

          http://www.silabs.com/about-us/contact-us
          https://jira.iotivity.org/secure/Dashboard.jspa

           

          I hope this information helps you,
          Pedro M.

          • 2. Re: End of line issue in Edison with telegesis
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello Shubham,

            Do you have any updates about this?

            Pedro M.

            • 3. Re: End of line issue in Edison with telegesis
              shubham0000gupta

              Hi Pedro,

               

              Thanks for your reply. I appreciate for your time given to this issue.

               

              The code snippet which you have given is looks good for all conditions but as i said earlier telegesis is sending \r\n with some commands and with some commands it sends \r\r\n. When i use telegesis dongle in edison it convert \r\r\n to \n\n\n. This random \n\n\n  and \n\n makes programming difficult.

               

              Programming for this is not an issue, if there is any thing which can solve this conversion of carriage return to newline, that would be a great help.

               

              Things i tried after your post.

              1) update the firmware of Edison(3.10.98). No changes in results.

              2) trying to contact silabs support.(this is not the issue with telegesis)

               

              In system telegesis is running without any problem. I think this might be a problem with properties or something in edison.

               

              Right now i am trying to install custom linux(4.10) by yocto project. Let's see if that solves my problem.

               

              Thanks Pedro for your valuable time.

               

              Shubham Gupta

              • 4. Re: End of line issue in Edison with telegesis
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                I understand your situation. Unfortunately, since I don't have access to the dongle you are using I can't provide further suggestions. However, I encourage you to continue your tests and let us know how they go. 

                Anyhow, I must mention that since you are now trying to build a custom image with a newer kernel, we may not be able to help you if you encounter issues as this is out of the support scope. Nevertheless, if you do have issues with this new image, we'll do our best effort to help.

                We hope to hear back from you!
                Pedro M.