I use a 3D printer type MK3S from Prusa.
I have written my program 3DPrinterComm.c to understand how the communication with this printer works. This program has been designed for this printer only. I think however that it can be applied (with some modifications) to other 3D printers also.
Note the following remarks and restrictions:
A different (and simpler) method to find out how the communication
works is the use of a typical modem program.
I used minicom (must probably be installed with apt-get)
with success:
sudo minicom -b 115200 -D /dev/tty/ACM0 -L -C /tmp/3D.txt
It may be necessary to turn local echo on and
to add LF after CR in minicom.