Updated to work with serial protocol  instead of sockets.