1 Reply Latest reply on Jul 16, 2015 4:27 PM by Frederick Blais

    Unable to transmit on UART


      I have an Edison with an Arduino breakout board. When I open the UART port (/dev/ttyMFD1), I can receive data, but not send data. I've tried this on two Edisons with the same effect. The following is how I open and configure the port. Any ideas?


           int fd;


          fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC);

          if (fd < 0)


         perror ("error opening serial port");
         return fd;



          struct termios tty;

          memset (&tty, 0, sizeof tty);

          if (tcgetattr (fd, &tty) != 0)


         perror("error %d from tcgetattr");
         return -1;




          cfsetispeed(&tty, B57600);

          cfsetospeed(&tty, B57600);


          tty.c_cflag &= ~CSIZE; /* Mask the character size bits */

          tty.c_cflag &= ~PARENB;

          tty.c_cflag &= ~CSTOPB;

          tty.c_cflag &= ~CRTSCTS ;


          tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);


          tty.c_cflag = B57600 | CS8 | CLOCAL | CREAD;

          tty.c_iflag = 0;  // IGNPAR;

          tty.c_oflag &= ~OPOST;   // turn off output processing


          tty.c_cc[VTIME] = 0;    // block until read is ready

          tty.c_cc[VMIN] = 1;   // wait for one character



          tcflush(fd, TCIFLUSH);

          if (tcsetattr (fd, TCSANOW, &tty) != 0)


         perror ("error %d from tcsetattr");
         return -1;


          return fd;

        • 1. Re: Unable to transmit on UART
          Frederick Blais

          I would suggest you use a proper serial port library like this one : libserialport - sigrok

          you can install git easily with opkg install git if it is not already installed on your Yocto


          the library is added to /usr/local/lib instead of the standard /usr/lib

          this mean you need to add /usr/local/lib to /etc/ld.so.conf then run ldconfig

          when you compile with gcc, don't forget to add -lserialport

          This is an example program I tested to try the library with Edison Arduino Breakout. Just plug a usb serial adapter to your RX TX pin


          #include "stdio.h"
          #include "ctype.h"
          #include "libserialport.h"
          char PORT_NAME[] = "/dev/ttyMFD1";
          char DATA[] = "Serial Echo (press q to quit)\r\n";
          struct sp_port* port;
          void main()
              sp_get_port_by_name(PORT_NAME, &port);
              printf("Port Name: %s\n", sp_get_port_name(port));
              if (sp_open(port, SP_MODE_READ_WRITE)==SP_OK)
                  printf("Port opened!\n");
              sp_nonblocking_write(port, DATA, sizeof(DATA));
              char rx = 0;
              setbuf(stdout, NULL);
                  sp_nonblocking_read(port, &rx, sizeof(rx));
                  if isprint(rx)
                      if (rx=='q')
                      rx = 0;
              if (sp_close(port)==SP_OK)
                  printf("Port closed!\n");