8 Replies Latest reply on Sep 13, 2016 11:00 AM by Intel Corporation

    Serial2 galileo gen 2

    wilson caro

      friends need help.

       

      I had already solved the problem of communicating an LCD and a printer to the intel.

      but install Linux image yocto, and now does not work well my sketch, I can do ?.

       

      the problem is that the LCD does not connect this to Serial2, the printer is operating correctly

       

      attached a piece of mcodigo to see how it did.

       

       

       

      #include <genieArduino.h>

      #include "Adafruit_Thermal_Galileo.h"

      Adafruit_Thermal_Galileo printer;

      #include <avr/dtostrf.h>

      Genie display2; // Genie Display 2

      #include <EEPROM.h>

      int x,y,w,v=0,menu=0,boton,cont=0,cont2=0,cont3,c=0,z=0,m=0,pri=0;   // variables revisadas todas usadas

      int f=0,cote,cope,porteuno,p=0,b=0,h=0,d=0,display=0,prop=0,j=0;              // variables revisadas todas usadas

      int acc,k=0,memory,temp,pres=0,pro=0,lastOperator,errorCondition;    // variables revisadas todas usadas

      long previousMillis=0,previousMillis2=0,previousMillis3=0,config;

      long intervalo = 59900;    // 1 minuto

      long intervalo2 = 1000;    // 1 segundos

      long intervalo3 = 50;    // 1 segundos

      char *buf;

      char buf2[9];

       

       

      void setup(){

        //EEPROM.write(0,35);    //tiem ciclo de MOTORES

        //EEPROM.write(1,10);    //tiem ciclo de instrumental

        //EEPROM.write(2,30);    //tiem ciclo BOWIE & DICK

        //EEPROM.write(3,10);    //tiem ciclo ROPA

        //EEPROM.write(4,121);   //temp ciclo MOTORES

        //EEPROM.write(5,134);   //temp ciclo instrumental

        //EEPROM.write(6,135);   //temp ciclo bowie

        //EEPROM.write(7,136);   //temp cicwlo ROPA

        //EEPROM.write(8,10);    //correcion temperatura

        //EEPROM.write(9,169);   //correcion presion

        //EEPROM.write(10,30);   //tiempo de secado instrumental

        //EEPROM.write(11,41);   //tiempo de secado MOTORES

        //EEPROM.write(12,0);    //ciclos maquina 1 "cuenta 250"

        //EEPROM.write(13,0);    //ciclos maquina 2 "cuenta 250"

        //EEPROM.write(14,0);    //ciclos maquina 3 "cuenta 200"

        //EEPROM.write(15,30);   //tiempo de secado BOWIE

        //EEPROM.write(16,41);   //tiempo de secado ROPA

        //system("date 010112002015"); //sets the date & time to 12:00 1st Jan 2013

        system("telnetd -l /bin/sh"); //Start the telnet server on Galileo

        system("ifconfig eth0 192.168.0.5 netmask 255.255.255.0 up");

        pinMode(A0, INPUT);   //entrada temperatura

        pinMode(A1, INPUT);   //entrada presion

        pinMode(A2, INPUT);   //entrada puerta cerrada lado limpio

        pinMode(A3, INPUT);   //entrada puerta cerrada lado sucio

        // ++++++++++++++++   configuracion salidas

        pinMode(A4, OUTPUT);  //salida vacio sellos lado limpio

        pinMode(A5, OUTPUT);  //salida vacio sellos lado sucio

        pinMode(4, OUTPUT);   //salida vapor

        pinMode(5, OUTPUT);   //salida Vacio

        pinMode(6, OUTPUT);   //salida sellos puerta

        pinMode(7, OUTPUT);   //salida buzzer

        pinMode(8, OUTPUT);   //salida ventilacion

        pinMode(9, OUTPUT);   //salida subir puerta lado limpio

        pinMode(10, OUTPUT);  //salida bajar puerta lado limpio

        pinMode(11, OUTPUT);  //salida subir puerta lado sucio

        pinMode(12, OUTPUT);  //salida bajar puerta lado sucio

        pinMode(13, INPUT);   //entrada disparo termico vacio

       

        Serial.begin(9600);   // Serial0 @ 9600 (9,6K) Baud for printer

        printer.begin();

        Serial2.begin(115200);  // Serial1 @ 115200 (115,2K) Baud for lcd 4dsystems

        display2.Begin(Serial2);  // Use Serial1 for talking to the Genie Library, and to the 4D Systems display #2

        display2.AttachEventHandler(myGenieEventHandler2); // Attach the user function Event Handler for processing events for display 2

        f=(EEPROM.read(12)+EEPROM.read(13)+EEPROM.read(14));

        printer.justify('C');

        printer.println("AUTOCLAVE STERIS V120  \n Ciclos Maquina");

        printer.println(f);  // imprime numeros de ciclos que lleva la maquina

        printer.println("\n\n");

        display2.WriteObject (GENIE_OBJ_TIMER, 0x00,0); //apago timer0

        display2.WriteObject (GENIE_OBJ_FORM, 1, 0) ;   // Select Form1 of the Display

        menu=1;        

      }

        • 1. Re: Serial2 galileo gen 2
          FGT

          Hi wilson941,

           

          Just a suggestion (I don't have any Intel Galileo Gen2 to help): since the problem is Serial2 strp down the sketch in order to work only with Serial2 up to the point in which it works again and, later, combine the result with the rest of the code you need/have in the current sketch.

           

          HTH,

           

          Fernando.

          • 2. Re: Serial2 galileo gen 2
            wilson caro

            I tried what you tell me did not work.

             

            looking for telnet I found that only 2 are configured UART and I have understood you are 3

             

            tty.png

             

            there is the Linux version, and UART.

             

             

            They understand are ttyS0, ttyS1 and ttyS3, please correct me if I'm wrong

            • 3. Re: Serial2 galileo gen 2
              FGT

               

              I tried what you tell me did not work.

               

               

              I did not suggested how to solve the issue, but to help solving in the sense of working only with the code that shows some kind of error, i.e. the Serial2 related code. Please post the sketch so every people would be able to reproduce your problem.

               

              looking for telnet I found that only 2 are configured UART and I have understood you are 3

               

              tty.png

               

              there is the Linux version, and UART.

               

               

              They understand are ttyS0, ttyS1 and ttyS3, please correct me if I'm wrong

               

              I do not understand what you are trying to explain here. I do not have any Intel Galileo Gen2 to exactly reproduce the problem you have. I've not worked with genie, btw.

               

              Fernando.

              • 4. Re: Serial2 galileo gen 2
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hi Wilson,

                If I understood correctly, you were able to connect the LCD to the Galileo in the past, right? Do you remember if anything in your code or circuitry has been changed since then? I would also like to know which image you are using.
                Just as Fernando suggested, it would be a very good idea to split up/isolate the code to easily identify the source of the issue. The printing part is working correctly, so separate that from the LCD part.

                Regards,
                -Pablo

                1 of 1 people found this helpful
                • 5. Re: Serial2 galileo gen 2
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi Wilson, 

                  I'm wondering if you've been working on this case lately. If so, do you have any news or updates?

                  Regards, 
                  -Pablo

                  • 6. Re: Serial2 galileo gen 2
                    wilson caro

                    hello, I was traveling outside the country but we resume the project. Like I persist with the problem, the version of yocto linux is in the photos published previously, and followed I upload the code to use test which is the same as the library, but the screen two were not connected, the one if it works correctly.

                     

                    I hope you can help me. placing probe indicated that the serial and serial1 code, then probe with serial and serial2, but does not work.

                     

                    codigo:

                     

                     

                    #include <genieArduino.h>
                    // This Demo extends the genieArduino_Demo, by showing how to use more than 1 screen at a time, attached to an Arduino with 2+ Serial Ports.
                    // This Demo uses the same WS4 Genie program on both displays, in this case, 2x uLCD-32PTU's, and an Arduino Mega.
                    // NOTE: Both displays must be connected for this demo to function.
                    // This Demo communicates with 2 4D Systems Displays, configured with ViSi-Genie, utilising the Genie Arduino Library - https://github.com/4dsystems/ViSi-Genie-Arduino-Library.
                    // The display demo has a slider, a cool gauge, an LED Digits, a string box and a User LED.
                    // The program receives messages from the Slider0 object on each display using the Reported Events. This is triggered each time the Slider changes on the display, and an event
                    // is genereated and sent automatically. Reported Events originate from the On-Changed event from the slider itself, set in the Workshop4 software.
                    // Coolgauge is written to using Write Object, and the String is updated using the Write String command, showing the version of the library.
                    // The User LED is updated by the Arduino, by first doing a manual read of the User LED and then toggling it based on the state received back.
                    // As the slider changes, it sends its value to the Arduino (Arduino also polls its value using genie.ReadObject, as above), and the Arduino then
                    // tells the LED Digit to update its value using genie.WriteObject, but of the other displays LED Digit! So the Slider message goes via the Arduino to the LED Digit
                    // of the other display.
                    // Coolgauge is updated via simple timer in the Arduino code, and updates the display with its value.
                    // The User LED is read using genie.ReadObject, and then updated using genie.WriteObject. It is manually read, it does not use an Event.
                    // This demo illustrates how to use genie.ReadObject, genie.WriteObject, Reported Messages (Events), genie.WriteStr, genie.WriteContrast, plus supporting functions.
                    // Application Notes on the 4D Systems Website that are useful to understand this library are found: http://www.4dsystems.com.au/appnotes
                    // Good App Notes to read are:
                    // ViSi-Genie Connecting a 4D Display to an Arduino Host - http://www.4dsystems.com.au/appnote/4D-AN-00017/
                    // ViSi-Genie Writing to Genie Objects Using an Arduino Host - http://www.4dsystems.com.au/appnote/4D-AN-00018/
                    // ViSi-Genie A Simple Digital Voltmeter Application using an Arduino Host - http://www.4dsystems.com.au/appnote/4D-AN-00019/
                    // ViSi-Genie Connection to an Arduino Host with RGB LED Control - http://www.4dsystems.com.au/appnote/4D-AN-00010/
                    // ViSi-Genie Displaying Temperature values from an Arduino Host - http://www.4dsystems.com.au/appnote/4D-AN-00015/
                    // ViSi-Genie Arduino Danger Shield - http://www.4dsystems.com.au/appnote/4D-AN-00025/
                    Genie display1; // Genie Display 1
                    Genie display2; // Genie Display 2
                    #define RESETLINE1 4  // Reset pin attached to Display 1
                    #define RESETLINE2 2  // Reset pin attached to Display 2
                    void setup()
                    {
                      // Use a Serial Begin and serial port of your choice in your code and use the genie.Begin function to send
                      // it to the Genie library (see this example below)
                      // 200K Baud is good for most Arduinos. Galileo should use 115200.
                     
                      Serial.begin(115200);  // Serial0 @ 200000 (200K) Baud
                      display1.Begin(Serial);  // Use Serial0 for talking to the Genie Library, and to the 4D Systems display #1
                     
                      Serial1.begin(115200);  // Serial1 @ 200000 (200K) Baud
                      display2.Begin(Serial1);  // Use Serial1 for talking to the Genie Library, and to the 4D Systems display #2
                      display1.AttachEventHandler(myGenieEventHandler1); // Attach the user function Event Handler for processing events for display 1
                      display2.AttachEventHandler(myGenieEventHandler2); // Attach the user function Event Handler for processing events for display 2
                     
                      // Reset the Displays
                      // THIS IS IMPORTANT AND CAN PREVENT OUT OF SYNC ISSUES, SLOW SPEED RESPONSE ETC
                      pinMode(RESETLINE1, OUTPUT);  // Set D4 on Arduino to Output to control the reset line to Display 1
                      pinMode(RESETLINE2, OUTPUT);  // Set D2 on Arduino to Output to control the reset line to Display 2
                      digitalWrite(RESETLINE1, 1);  // Reset Display 1
                      digitalWrite(RESETLINE2, 1);  // Reset Display 2
                      delay(100);
                      digitalWrite(RESETLINE1, 0);  // unReset Display 1
                      digitalWrite(RESETLINE2, 0);  // unReset Display 2
                      delay (3500); //let the display start up after the reset (This is important)
                      //Set the brightness/Contrast of the Display - (Not needed but illustrates how)
                      //Most Displays, 1 = Display ON, 0 = Display OFF
                      //For uLCD-43, uLCD-220RD, uLCD-70DT, and uLCD-35DT, use 0-15 for Brightness Control, where 0 = Display OFF, though to 15 = Max Brightness ON.
                      display1.WriteContrast(1); // Display ON
                      display2.WriteContrast(1); // Display ON
                     
                      //Write a string to the Display to identify each display
                      display1.WriteStr(0, "Hello Display 1");
                      display2.WriteStr(0, "Hello Display 2");
                    }
                    void loop()
                    {
                      static long waitPeriod = millis(); // Time now
                     
                      static int gaugeAddVal1 = 1; // Set the value at which the Gauge on Display 1 increases by initially
                      static int gaugeVal1 = 10; // Starting Value for Gauge on Display 1
                      static int gaugeAddVal2 = 2; // Set the value at which the Gauge on Display 2 increases by initially
                      static int gaugeVal2 = 50; // Starting Value for Gauge on Display 2
                      display1.DoEvents(); // This calls the library each loop to process the queued responses from display 1
                      display2.DoEvents(); // This calls the library each loop to process the queued responses from display 2
                      if (millis() >= waitPeriod)
                      {
                       // Write to CoolGauge0 with the value in the gaugeVal variable on Display 1
                      display1.WriteObject(GENIE_OBJ_COOL_GAUGE, 0, gaugeVal1);
                      
                       // Simulation code for Gauge on Display 1, just to increment and decrement gauge value each loop, for animation
                      gaugeVal1 += gaugeAddVal1;
                       if (gaugeVal1 >= 99) gaugeAddVal1 = -1; // If the value is > or = to 99, make gauge decrease in value by 1
                       if (gaugeVal1 <= 0) gaugeAddVal1 = 1; // If the value is < or = to 0, make gauge increase in value by 1
                       // The results of this call will be available to myGenieEventHandler() after the display has responded
                       // Do a manual read from the UserLEd0 object on Display 1
                      display1.ReadObject(GENIE_OBJ_USER_LED, 0);
                      
                       // Write to CoolGauge0 with the value in the gaugeVal variable on Display 2
                      display2.WriteObject(GENIE_OBJ_COOL_GAUGE, 0, gaugeVal2);
                      
                       // Simulation code for Gauge on Display 2, just to increment and decrement gauge value each loop, for animation
                      gaugeVal2 += gaugeAddVal2;
                       if (gaugeVal2 >= 99) gaugeAddVal2 = -2; // If the value is > or = to 99, make gauge decrease in value by 2
                       if (gaugeVal2 <= 0) gaugeAddVal2 = 2; // If the value is < or = to 0, make gauge increase in value by 2
                       // The results of this call will be available to myGenieEventHandler() after the display has responded
                       // Do a manual read from the UserLed0 object on Display 2
                      display2.ReadObject(GENIE_OBJ_USER_LED, 0);
                      waitPeriod = millis() + 50; // rerun this code to update Cool Gauge and Slider in another 50ms time.
                      }
                    }
                    /////////////////////////////////////////////////////////////////////
                    //
                    // This is the user's event handler. It is called by the DoEvents()
                    // when the following conditions are true
                    //
                    // The link is in an IDLE state, and
                    // There is an event to handle
                    //
                    // The event can be either a REPORT_EVENT frame sent asynchronously
                    // from the display or a REPORT_OBJ frame sent by the display in
                    // response to a READ_OBJ (genie.ReadObject) request.
                    //
                    // Event Handler Function for Display 1
                    void myGenieEventHandler1(void)
                    {
                      genieFrame Event;
                      display1.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
                      //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
                      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
                      {
                       if (Event.reportObject.object == GENIE_OBJ_SLIDER)  // If the Reported Message was from a Slider
                      {
                       if (Event.reportObject.index == 0// If Slider0 (Index = 0)
                      {
                       int slider_val = display1.GetEventData(&Event);  // Receive the event data from the Slider0
                      display2.WriteObject(GENIE_OBJ_LED_DIGITS, 0, slider_val);  // Write Slider0 value of Display 1 to to LED Digits 0 of Display 2 !
                      }
                      }
                      }
                      //If the cmd received is from a Reported Object, which occurs if a Read Object (genie.ReadOject) is requested in the main code, reply processed here.
                      if (Event.reportObject.cmd == GENIE_REPORT_OBJ)
                      {
                       if (Event.reportObject.object == GENIE_OBJ_USER_LED)  // If the Reported Message was from a User LED
                      {
                       if (Event.reportObject.index == 0// If UserLed0 (Index = 0)
                      {
                       bool UserLed0_val = display1.GetEventData(&Event);  // Receive the event data from the UserLed0
                      UserLed0_val = !UserLed0_val;  // Toggle the state of the User LED Variable
                      display1.WriteObject(GENIE_OBJ_USER_LED, 0, UserLed0_val);  // Write UserLed0_val value back to to UserLed0
                      }
                      }
                      }
                    }
                    // Event Handler Function for Display 2
                    void myGenieEventHandler2(void)
                    {
                      genieFrame Event;
                      display2.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
                      //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
                      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
                      {
                       if (Event.reportObject.object == GENIE_OBJ_SLIDER)  // If the Reported Message was from a Slider
                      {
                       if (Event.reportObject.index == 0// If Slider0 (Index = 0)
                      {
                       int slider_val = display2.GetEventData(&Event);  // Receive the event data from the Slider0
                      display1.WriteObject(GENIE_OBJ_LED_DIGITS, 0, slider_val);  // Write Slider0 value of Display 2 to to LED Digits 0 of Display 1
                      }
                      }
                      }
                      //If the cmd received is from a Reported Object, which occurs if a Read Object (genie.ReadOject) is requested in the main code, reply processed here.
                      if (Event.reportObject.cmd == GENIE_REPORT_OBJ)
                      {
                       if (Event.reportObject.object == GENIE_OBJ_USER_LED)  // If the Reported Message was from a User LED
                      {
                       if (Event.reportObject.index == 0// If UserLed0 (Index = 0)
                      {
                       bool UserLed0_val = display2.GetEventData(&Event);  // Receive the event data from the UserLed0
                      UserLed0_val = !UserLed0_val;  // Toggle the state of the User LED Variable
                      display2.WriteObject(GENIE_OBJ_USER_LED, 0, UserLed0_val);  // Write UserLed0_val value back to to UserLed0
                      }
                      }
                      }
                      /********** This can be expanded as more objects are added that need to be captured *************
                      *************************************************************************************************
                      Event.reportObject.cmd is used to determine the command of that event, such as an reported event
                      Event.reportObject.object is used to determine the object type, such as a Slider
                      Event.reportObject.index is used to determine the index of the object, such as Slider0
                      genie.GetEventData(&Event) us used to save the data from the Event, into a variable.
                      *************************************************************************************************/
                    }

                     

                    • 7. Re: Serial2 galileo gen 2
                      wilson caro

                      good day,

                       

                      friends for those interested discovered that:

                      NO it communicated the serial2 for the simple reason that the MicroSD card was not class 10.

                      the truth, not sure that it was using a scandisk but not class 10

                      • 8. Re: Serial2 galileo gen 2
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        Hi Wilson,

                        Thank you very much for the update. Your discovery will definitely be useful for other users.

                        Regards,
                        -Pablo