14 Replies Latest reply on Apr 27, 2015 11:34 AM by JPMontero_Intel

    how to read from serial2

    shb

      hi

      i am trying to read from serial2 because serial1 is already used

      i want to use the arduino sketch

       

      int inByte =0;

       

       

      void setup() {

        Serial2.begin(9600);

      }

       

       

      void loop() {

       

       

        // read from port 1, send to port 0:

        if (Serial2.available()) {

          int inByte = Serial2.read();

        }

      }

      pretty easy, nothing special

      but i cant compile:

       

       

      sketch_dec10a.ino: In function 'void setup()':

      sketch_dec10a.ino:4:3: error: 'Serial2' was not declared in this scope

      sketch_dec10a.ino: In function 'void loop()':

      sketch_dec10a.ino:10:7: error: 'Serial2' was not declared in this scope

      iI use Arduino 1.5.4-Intel.1.0.3 and edison is selected

      and here is described, that i can use Serial2.begin()

      Serial1 is compiling

       

      an ideas?

       

      regardes stefan

        • 1. Re: how to read from serial2
          KurtE

          Builds for me.  But I am using the current build 1.5.4-Intel.1.0.4

           

          Try updating to the newer release and see if that helps.

          • 2. Re: how to read from serial2
            vivo133

            KurtE   AlexT_Intel mhahn intel_admin bert


            I want to sheild the uart2's  terminal function and use uart2 as simple data transfer.But there is something wrong.


            As it  is said,when you run Serial2.begin(115200),You will see how the Arduino system detaches the console from the serial port.  It also sets up stuff such that the console is reattached when you end using the Serial2 and/or reboot.Then the problems come.


            First , I find  there is no file named telinit, then I replace it with file init, the probem seemed solved.


            Second, I find there is no content in the files named inittab and inittab.restore.


            finally,After I  detaches the console from the serial port. It starts again.the phenomenon  is like that:


            图片1.png


            Would you mind give some suggestions.

             

            Thanks a lot.

             

            PS:The hardware is Intel® Edison Board for Arduino*

            • 3. Re: how to read from serial2
              KurtE

              I have not done used the Serial2 object for much, so really not sure how much I can help.

               

              I have used it a couple of times for doing some limited debugging.  That is when I had an Arduino App that I launch using WiFI to upload and for example on the mini board, I am using the USB port with the converter to use it in server mode.  I don't have the normal USB serial port for debug information.  So in that case I have enabled it using the Serial2 object, which has worked for me.  Currently doing more stuff using Eclipse or building direct on Edison and as such do the debug using PuTTY windows instead of Serial2 object.

               

              And yes if you reboot without the Arduino APP or do a Serial2.end();  it will again launch the debug window.  When I was debugging earlier, I would run a different Arduino APP, that either cleared out running my app, or a real simple begin/end of Serial2 to get the system monitor back.

               

              Sorry I am not much help

              Kurt

              • 4. Re: how to read from serial2
                AlexT_Intel

                Before giving any suggesting I'd rather ask why do you need to mess up with init and inittab and how is that related to Arduino's Serial2 object in your context?

                 

                I'd suggest you to describe in more detail, step-by-step if possible, what your goal is and which steps have you performed so that you ended up with the above. Right now I'm afraid it's too generic of a description to me, to be able to suggest anything meaningful.

                • 5. Re: how to read from serial2
                  vivo133

                  Hi, AlexT_Intel,sorry,I should describe the situation in more detail.

                   

                  Hardware: Intel@ Edison Board for Arduino

                   

                  Why: There are two UART  provided by the Board, one is TTL ,and the other is used for terminal console.I want to use the terminal console port as simple UART function,that's to say ------ sheild the terminal function.

                   

                  ==================================================================

                   

                  In the link

                  https://communities.intel.com/thread/54236

                   

                  It tells  how to sheild the terminal fuction, but it did not work. When I run Serial2.begin(115200)

                   

                  You can read the  code (Serial2.begin(115200)) in arduino-windows-1.0.4(TTYUART.cpp),and understand what I want to describe.

                   

                  Thank you

                  • 6. Re: how to read from serial2
                    AlexT_Intel

                    Okay, thanks for clarification, now I see what you're talking about.

                     

                    It seems to me that what you see is a bug or not fully implemented functionality, because the TTYUART.cpp file for Edison is identical (except for two small and irrelevant to this problem pieces) to the one for Galileo and the trick used there to detach the console and then attach it back isn't going to work on Edison, because it doesn't use init-style OS initialization but a systemd one.

                     

                    I have tried a very simple sketch of Serial2.begin(115200)/pause/Serial2.end() and I actually don't see anything like you posted in that other thread, probably you've already modified something or used KurtE's library,or something else along these lines. In my case just nothing happens, maybe just the serial console becomes laggy after the first try.

                     

                    At the same time I'm not sure if this functionality of attaching Serial2 to this console is actually supported on Edison. I couldn't find any release notes on that as a proof, so I may be mistaken here, but my impression was that this specific feature was for Galileos only.

                     

                    I would say this needs an IDE development team clarification. JPMontero_Intel CMata_Intel, DiegoV_Intel - folks, could you please report this appropriately and see what the answer is going to be?

                    • 7. Re: how to read from serial2
                      JPMontero_Intel

                      Hi AlexT,

                       

                      Sure we will report this, thanks for letting us know.

                       

                      Regards,
                      JPMontero_Intel

                      • 8. Re: how to read from serial2
                        vivo133

                        Hi , JPMontero_Intel ,Is there any good news for this question. It's very important for us to achieve the function.

                        • 9. Re: how to read from serial2
                          JPMontero_Intel

                          Hi vivo133,

                           

                          Currently I have no updates on this. I’ll let you know as soon as I get more information.

                           

                          Regards,
                          JPMontero_Intel

                          • 10. Re: how to read from serial2
                            JPMontero_Intel

                            Hi vivo133,

                             

                            I apologize for the delay in my response. We have filed this issue, a fix should be available in future software releases.

                             

                            Regards,

                            JPMontero_Intel

                            • 11. Re: how to read from serial2
                              vivo133

                              Hi, JPMontero_Intel  ,I'm so glad to hear the good news.And how long it well take to release the  software,Maybe I will use the function in the beginning of the April. Thank you !

                              • 12. Re: how to read from serial2
                                JPMontero_Intel

                                Hi vivo133,

                                 

                                There is no approximate ETA for it at the moment.

                                 

                                Regards,
                                JPMontero_Intel

                                • 13. Re: how to read from serial2
                                  AKap

                                  I'm guessing this problem also applies to the use of Serial1, because I too can not declare Serial1 in the Arduino IDE 1.6.0, Edison Arduino Yocta environment. Also we can't even revert back to the use of SoftwareSerial because it's outdated for the Edison. So any news of the situation?

                                  • 14. Re: how to read from serial2
                                    JPMontero_Intel

                                    AKap - Serial1 should work on Arduino IDE 1.6.0, make sure you are selecting the Edison board before clicking on the Verify button. This could fail if another board is selected.

                                     

                                    Regards,
                                    JPMontero_Intel