title: Bash, serial I/O and Arduino
body: <p>So, I'm in a bit over my head, and I feel like I'm very close to a solution, but it's just not working quite yet. Here's my situation:</p>
  
  <p>I'm working with an Arduino microcontroller, and I'm attempting to write two Bash scripts (right now running in Mac&nbsp;OS&nbsp;X 10.6) which will (a) print all serial data coming out of the Arduino unit to the standard output, and (b) allow me to send serial data to the Arduino unit. These scripts will then be called using Adobe AIR's NativeProcess API to allow a tight integration between the Arduino unit and a Flex <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application.</p>
  
  <p>My two scripts are very simple -</p>
  
  <p>Here's my WriteToSerial.sh script:</p>
  
  <pre><code>echo $1 &gt; $2
  </code></pre>
  
  <p>($1 is obviously my string, $2 is the location of the serial port - currently /dev/tty.usbserial-A800eIUj)</p>
  
  <p>And here's my ReadSerialOutput.sh script:</p>
  
  <pre><code>tail -f $1
  </code></pre>
  
  <p>($1 is the location of my serial port, currently /dev/tty.usbserial-A800eIUj)</p>
  
  <p>When I call either of these scripts (or even if I just type the commands directly into the Bash console), my computer just hangs - I can type characters, but nothing happens until I <kbd>Ctrl</kbd> + <kbd>C</kbd> out of the process.</p>
  
  <p>However, if I open the Arduino IDE and turn on the Serial Monitor, then <code>tail -f</code> the port, close the serial monitor, and then echo "test" > serial port, everything works just great.</p>
  
  <p>This suggests to me that opening the Serial Monitor within the Arduino IDE is somehow initializing the serial port, which in turn allows me to tail it with no problem. This in turn suggests to me that I'm simply failing to input some sort of initialization command. However, I've been searching high and low for days and can't seem to find anything that addresses this issue.</p>
  
  <p>What is the solution?</p>