Fixed bug causing the Arduino to not be able to read from the Linux process. Also refactored code a bit to make reuse easier.