2 Replies Latest reply on Nov 17, 2014 1:30 PM by jblackston

    Basic UART work in C

    jblackston

      I'm trying to open up the serial port with the Edison in a C application. The MRAA seems to be limited on examples for this, but I was just planning on using the old try and true method of calling open()... What or where do I find the filename to open up UART1, is it tty0? Or do I need to handle accessing the UART differently?

       

      Also on a side note to access the gpio pins with MRAA are the gpio pin numbers the literal number I use. So for access to GPIO80 I would use the number 80 in the mraa_gpio_init() function for MRAA?

        • 1. Re: Basic UART work in C
          KurtE

          The first question is which Uart?

          Whenever I have questions about which uart, I look at the thread: Using Serialx on Edison

           

          If you are using the Arduino board and you are interested for example in the equivalent of Serial1 (pins 0, 1), than it is the device: /dev/ttyMFD1

           

          In several of my Linux programs I prefer to abstract those away as for example which device I use to hook up an XBee.  On some boards it can be an actual physical device like the ttyMFD1 and on other boards I may use an USB xbee and it may be ttyUSBx, so in those cases I often create a link like:

          /dev/ttyXBEE  and have my code use that.

          Sometimes i use hard coded ones (as I have not figured out udev rules for those cases) like I have the following in my .profile file:

          ln -s /dev/ttyMFD1 /dev/ttyXBEE

           

          In other cases my preferred way is udev rules, where the system detects the hardware and creates the symbolic link for you...

          If you are interested in what I have done in these cases, there is more up on my Raspberry Pi github project (KurtE)...

          I have a Serial class that is built around Arduino code...

           

          As for Pin numbers for MRAA_GPIO.. the pin number is not the internal processor board pin number, but instead the logical pin number.  On Arduino board: this is in the range 0-19.   For the Intel breakout board, this is in the range 0-55.  More details in the MRAA docs:

          https://github.com/intel-iot-devkit/mraa/blob/master/docs/edison.md

          1 of 1 people found this helpful
          • 2. Re: Basic UART work in C
            jblackston

            Thanks