3 Replies Latest reply on Sep 18, 2015 4:41 AM by xthunderheartx

    Problem: UART0 receiving on Galileo Gen 2, Linux Sysfs

    EslamZidane

      I have a problem in UART0 receiver of Intel Galileo Gen2.

       

      Sending data through UART0 goes okey, the problem here in receiving, I am following the procedure mentioned in this URL:

      Intel Galileo - Configuring the Serial Port in Linux - Malinov Family Web Presence

       

      I am receiving garbage data which sometimes contains the sent data

       

      So, what may cause this problem?

       

      Also I need a solution to configure UART0 receiver through libmraa so that I can totally operate it from the compiled C program file. I tried to use libmraa but seems that initialization doesn't work properly and I don't receive any thing with a program coded using libmraa.

        • 1. Re: Problem: UART0 receiving on Galileo Gen 2, Linux Sysfs
          JPMontero_Intel

          Hi EslamZidane,

           

          I suggest you first to make sure the baud rate speed and serial settings match with the sender device. You can check the port settings with the following command: stty –F /dev/ttyMFD1

          To change the speed of the port you use the same command in the following way: stty –F /dev/ttyMFD1 115200

          About having issues with mraa make sure you have the latest version and try with a sample code first, you can give it a try with this one. You also mentioned you tried with mraa, you can try reading the port directly with the command cat /dev/ttyMFD1 Let us know if you have the same behavior with mraa and reading the port directly. In case is does not work please attach the output of the command cat /sys/kernel/debug/gpio . Additionally what are you using to read and write into the Edison?

           

          Regards,
          JPMontero_Intel

          • 2. Re: Problem: UART0 receiving on Galileo Gen 2, Linux Sysfs
            EslamZidane

            Hi JPMontero_Intel

             

            Thanks too much for ur reply

             

            I am using Galileo Gen2 and it uses ttyS0 for UART0, I checked the baud rate after running the program and it was 9600 which is the same baud rate of the other device

             

            I think I have the latest version as I upgraded the libraries very soon.

             

            I am just using MRAA and Sysfs GPIOs , This is my /dev/kernel/debug/gpio output after executing MRAA code to send a message over UART0:

             

            GPIOs 0-1, platform/sch_gpio.2398, sch_gpio_core:

            gpio-0 (sysfs               ) in  lo

            gpio-1 (sysfs               ) in  lo

             

            GPIOs 2-7, platform/sch_gpio.2398, sch_gpio_resume:

            gpio-4 (sysfs               ) in  lo

            gpio-5 (sysfs               ) in  lo

            gpio-6 (sysfs               ) in  lo

            gpio-7 (sysfs               ) in  lo

             

            GPIOs 8-15, intel_qrk_gip_gpio:

            gpio-8 (SPI_CS              ) out hi

            gpio-9 (pcal9555a-exp2-int  ) in  hi

            gpio-10 (sysfs               ) in  lo

            gpio-11 (sysfs               ) in  hi

            gpio-12  (sysfs               ) in lo

            gpio-13 (sysfs               ) in  lo

            gpio-14 (sysfs               ) in  lo

            gpio-15 (sysfs               ) in  lo

             

            GPIOs 16-31, i2c/0-0025, pcal9555a, can sleep:

            gpio-16 (sysfs               ) out hi

            gpio-17 (sysfs               ) in  lo

            gpio-18 (sysfs               ) out hi

            gpio-19 (sysfs               ) in  lo

            gpio-20 (sysfs               ) out hi

            gpio-21 (sysfs               ) in  lo

            gpio-22 (sysfs               ) out hi

            gpio-23 (sysfs               ) in  lo

            gpio-24 (sysfs               ) out hi

            gpio-25 (sysfs               ) in  lo

            gpio-26 (sysfs               ) out hi

            gpio-27 (sysfs               ) in  lo

            gpio-28  (sysfs               ) out lo

            gpio-29 (sysfs               ) in  hi

            gpio-30 (sysfs               ) out hi

            gpio-31 (sysfs               ) in  lo

             

            GPIOs 32-47, i2c/0-0026, pcal9555a, can sleep:

            gpio-32 (sysfs               ) out hi

            gpio-33 (sysfs               ) in  hi

            gpio-34 (sysfs               ) out hi

            gpio-35 (sysfs               ) in lo

            gpio-36 (sysfs               ) out hi

            gpio-37 (sysfs               ) in  lo

            gpio-38 (sysfs               ) in  lo

            gpio-39 (sysfs               ) in  lo

            gpio-40 (sysfs               ) in  lo

            gpio-41 (sysfs               ) in  lo

            gpio-42 (sysfs               ) out hi

            gpio-43 (sysfs               ) in  lo

            gpio-44 (sysfs               ) out lo

            gpio-45  (sysfs               ) out hi

            gpio-46 (sysfs               ) out lo

            gpio-47 (sysfs               ) out hi

             

            GPIOs 48-63, i2c/0-0027, pcal9555a, can sleep:

            gpio-48 (sysfs               ) in  lo

            gpio-49 (sysfs               ) in  lo

            gpio-50 (sysfs               ) in  lo

            gpio-51 (sysfs               ) in  lo

            gpio-52 (sysfs               ) in  lo

            gpio-53  (sysfs               ) in  lo

            gpio-54 (sysfs               ) in  lo

            gpio-55 (sysfs               ) in  lo

            gpio-56 (sysfs               ) in  lo

            gpio-57 (sysfs               ) in  lo

            gpio-58 (sysfs               ) in  lo

            gpio-59 (sysfs               ) in lo

            gpio-60 (sysfs               ) out hi

            gpio-61 (sysfs               ) in  lo

            gpio-62 (sysfs               ) in  lo

            gpio-63 (sysfs               ) in  hi

             

            GPIOs 64-79, pca9685-gpio, can sleep:

            gpio-64 (sysfs               ) out lo

            gpio-66 (sysfs               ) out lo

            gpio-68 (sysfs               ) out lo

            gpio-70 (sysfs               ) out lo

            gpio-72 (sysfs               ) out lo

            gpio-74 (sysfs               ) out lo

            gpio-76 (sysfs               ) out lo

            gpio-77 (sysfs               ) out lo

            gpio-78 (sysfs               ) out hi

            gpio-79 (sysfs               ) out hi

             

            And this is my code:

             

            #include "mraa.h"

            #include <stdio.h>

            int main(void)

            {

                    mraa_uart_context uart;

                    char buffer[15]="Hello, Galileo";

                    int op;

                    uart=mraa_uart_init(0);

                    mraa_uart_set_baudrate(uart, 9600);

                    mraa_uart_set_mode(uart,8,MRAA_UART_PARITY_NONE,1);

                    if(uart==NULL) printf("Game Over!\n");

                    while(1)

                    {       printf("Hi\n");

                            op=mraa_uart_write(uart,buffer,15);

                            printf("Send: %i", op);

                            sleep(10);

                    }

                    return 0;

            }

            • 3. Re: Problem: UART0 receiving on Galileo Gen 2, Linux Sysfs
              xthunderheartx

              Not sure why the code above doesn't work, but frankly I skip mraa to use the serial ports.  I init the hardware with mraa and then let Linux handle things from there via the standard libraries. Termios to configure serial options and then just open, read, write, close.  Q.E.D.