3 Replies Latest reply on Apr 27, 2015 11:02 AM by sk1tt1sh

    Sparkfun Arduino Block - Read serial output from arduino

    sk1tt1sh

      Hello and thanks for taking a look!

       

      Background: I'm using the following 2 blocks:

      Arduino Block - SparkFun Block for Intel® Edison - Arduino - DEV-13036 - SparkFun Electronics

      Base Block - SparkFun Block for Intel® Edison - Base - DEV-13045 - SparkFun Electronics

       

      Goal:

      1. Arduino reads a sensor and prints data to Serial

      2. Node.js app on edison reads data from the serial and posts the data to server, and possibly writes a command back.

       

      Is there a way to use ttyMFD1 to read the data from the serial output?

       

      When I try these instructions Re: How to receive data from 0RX? (with the answer) the first "echo -n 214 > /sys/class/gpio/export" fails with a not found error.

      Following on that here's my cat /sys/kernel/debug/gpio output:

      "

      GPIOs 0-191, pci/0000:00:0c.0, 0000:00:0c.0:

      gpio-61  (SW1UI4              ) in  hi

      gpio-64  (bcm43xx_irq         ) in  lo

      gpio-71  (bcm_bt_lpm          ) out lo

      gpio-77  (sd_cd               ) in  hi

      gpio-96  (vwlan               ) out hi

      gpio-111 (Arduino Shield SS   ) out hi

      gpio-124 (hsu                 ) in  hi

      gpio-125 (hsu                 ) in  hi

      gpio-126 (hsu                 ) in  hi

      gpio-127 (hsu                 ) in  hi

      gpio-128 (hsu                 ) in  lo

      gpio-129 (hsu                 ) in  hi

      gpio-130 (hsu                 ) in  hi

      gpio-131 (hsu                 ) in  hi

      gpio-132 (hsu                 ) in  lo

      gpio-133 (hsu                 ) out lo

      gpio-134 (hsu                 ) in  hi

      gpio-184 (bcm_bt_lpm          ) out lo

      gpio-185 (bcm_bt_lpm          ) in  lo

      "

       

      Which from posts I found is not all of the gpio pins?

       

      Interestingly I can read data from the MFD1 serial with node but it's just random bytes.

       

      Thank you!

        • 1. Re: Sparkfun Arduino Block - Read serial output from arduino
          CMata_Intel

          Hi sk1tt1sh

           

          The error you are receiving after echo -n 214 > /sys/class/gpio/export is because you are not using the Arduino Expansion Board. The gpio 214 corresponds to a tri-state buffer which is available only in the Arduino Expansion Board. This error message also appers in the Mini-Breakout Board if you run the same line.

          In the community you will find different configurations made for the mini-breakout board or for the Arduino Expansion board so there will be some differences if you want to use those SparkFun blocks.

          Try to use gpio134 and gpio135 (Rx & Tx). Also be sure you have all the settings and parameters like baud rate correct.

           

          Regards;

          CMata

          • 2. Re: Sparkfun Arduino Block - Read serial output from arduino
            sk1tt1sh

            I have the baud on the arduino serial output at 115200, is it true that the edison dislikes >9600? I saw that on a post while trying to figure this issue out.

             

            "ls /sys/class/gpio"

            export

            gpio124 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio124

            gpio125 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio125

            gpio126 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio126

            gpio127 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio127

            gpio128 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio128

            gpio129 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio129

            gpio130 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio130

            gpio131 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio131

            gpio132 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio132

            gpio133 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio133

            gpio134 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio134

            gpiochip0 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpiochip0

            unexport

             

            Here is a copy from my attempt with your instructions:

            "

            root@edison:~# echo -n 134 > /sys/class/gpio/export

            sh: write error: Device or resource busy #134 already doing something?

            root@edison:~# echo -n 135 > /sys/class/gpio/export

            root@edison:~# echo mode1 > /sys/kernel/debug/gpio_debug/gpio134/current_pinmux

            root@edison:~# echo in > /sys/class/gpio/gpio134/direction

            root@edison:~# echo mode1 > /sys/kernel/debug/gpio_debug/gpio135/current_pinmux

            root@edison:~# echo out > /sys/class/gpio/gpio135/direction

            root@edison:~# stty -F /dev/ttyMFD1

            speed 115200 baud; line = 0;

            intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;

            eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;

            werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;

            -brkint -imaxbel

            root@edison:~# cat /dev/ttyMFD1

            ▒▒▒▒▒▒▒▒z@ruu

             

            ▒▒▒▒▒▒▒@▒▒▒▒z@p

             

            ▒▒▒▒`▒▒▒▒▒▒z p

             

            ▒▒▒▒▒▒▒▒z@ru5

             

            ▒▒▒▒▒▒▒@▒▒▒▒z`p

             

            ▒▒▒▒`▒▒▒▒▒▒`▒▒▒@▒▒▒▒▒▒▒▒`▒▒▒▒@▒▒▒▒`qup //This appears to be something from the arduino, when triggering a sensor I have attached.

            "

            • 3. Re: Sparkfun Arduino Block - Read serial output from arduino
              sk1tt1sh

              It appears 115200 is an unusable baud for the Edison serial to Arduino block!

              I set the baud to 9600 and have successfully gotten the expected data!!

               

              echo -n 130 > /sys/class/gpio/export //may not need, may already be exported

              echo -n 131 > /sys/class/gpio/export //may not need, may already be exported

              echo mode1 > /sys/kernel/debug/gpio_debug/gpio130/current_pinmux // potentially unneeded as well.

              echo mode1 > /sys/kernel/debug/gpio_debug/gpio131/current_pinmux // potentially unneeded as well.

              echo in > /sys/class/gpio/gpio130/direction

              echo out > /sys/class/gpio/gpio131/direction

              ..

              cat /dev/ttyMFD1