I need to communicate with serial port from Node.js then. I found I need to run this commands.
echo -n "28" > /sys/class/gpio/export
echo -n "out" > /sys/class/gpio/gpio28/direction
echo -n "0" > /sys/class/gpio/gpio28/value
echo -n "32" > /sys/class/gpio/export
echo -n "out" > /sys/class/gpio/gpio32/direction
echo -n "1" > /sys/class/gpio/gpio32/value
echo -n "45" > /sys/class/gpio/export
echo -n "out" > /sys/class/gpio/gpio45/direction
echo -n "1" > /sys/class/gpio/gpio45/value
I have few questions:
- When I run first and few other commands, I'm getting "-sh: echo: write error: Device or resource busy". Is this OK?
- Should I run this commands on every reboot?
I ran your code and I was able to send data through the Serial1 interface (pin 1 - Tx). Take a look at the screenshot below:
How are you testing your code? How do you know that there is nothing being sent?
Answering your last questions:
- The error message "-sh: echo: write error: Device or resource busy" appears when you are trying to export a GPIO that is already exported. You can ignore the message, it doesn't affect anything. It only tells you that the GPIO was already exported.
- You should run the required commands to configure the GPIO on every reboot. However, those commands shouldn't be necessary because the pins Tx and Rx are configured by the Arduino IDE (or at least they should be). When I ran your code I only compiled and uploaded it to the Galileo board and it worked.