Ubuntu: How to receive/read raw file sent using Gtkterm thru serial?


I've downloaded Gtkterm in 2 desktop systems each with a RS-232 serial port. I'm attempting to transfer a simple .txt file between the 2 systems thru one of the available serial ports. The 2 systems are connected at their respective RS-232 port using a null-modem RS232 cable.

I've selected the appropriate ttyS# port, and am sending the file on 1 computer. But, how do I read this sent file on the other computer.


Here's what you a gotta do:

If the name of the file is blahblah.txt

On the sending machine:

sudo cat blahblah.txt > /dev/ttyS0  

On the receiving machine:

sudo cat /dev/ttyS0 > blahblah.txt  

Don't forget the sudo, since some systems may need that.


If you have a serial login from one ubuntu workstation (local) to another ubuntu machine (remote), you can send a raw file over gtkterm with the following:

First, check the md5sum of the file so that we can be confident we transferred it successfully. If the file you wish to send is binary (contains non-ascii text) then I recommend that you first base64 encode the data. For example


user@local:~$ md5sum my_file.bin  9426054eb507e98605d7a6b94189168b  my_file.bin  user@local:~$ base64 my_file.bin > my_file.bin.base64  user@local:~$ gtkterm --port /dev/ttyUSB1 --speed 115200 &  


user@remote:~$ cat > my_file.bin.base64  

Now use the gtkterm menu to "send raw file" and select your file. You'll see every byte of the file echo'ed on the gtkterm window. When the file is finished sending press Ctrl+D in the gtkterm window to send a EOF to cat. You'll see a new terminal prompt pop up. Then base64 decode the file. Finally it's a good idea to check the integrity of the data.


user@remote:~$ base64 -d my_file.bin.base64 > my_file.bin  user@remote:~$ md5sum my_file.bin  9426054eb507e98605d7a6b94189168b  my_file.bin  

Notes Note that the file transfer will proceed at the rate of the serial connection. You can't feasibly send very large files this way. Furthermore (and especially if the serial connection doesn't support flow control) there's always the possibility of some dropped bytes.


Once you've started cat > my_file.bin.base64 on the remote machine through gtkterm, you can bypass gtkterm to do the actual file transfer. For instance you can use plain ole cat:


user@local:~$ cat my_file.bin > /dev/ttyUSB1  

Or if you want a fancy progress bar give pv a try:


user@local:~$ pv my_file.bin | cat > /dev/ttyUSB1  

This technique will work with other serial terminal clients, including terminal based clients (i.e. creen, minicom, etc).

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »