Endianess support for communication.cpp

TODO: code polishing.
Thanks to the kind dr. Melletti for the debug! :D