Fixed serial writing. For bidirectional communication is now working. 

Beaware that gateway echoing the serial command leads to weird behaviour.