While waiting for the hardware I need to get any further on my little programming project I have been experimenting with sending and receiving data from the FRDM-KL25Z through a serial port. Mostly to prepare the tools I will need to debug the system I’m planning on building, and in particular the code and algorithms I will use for file encryption. Unfortunately, sending and receiving files and binary data over a serial port proved to be a little harder to do than I had anticipated. It was possible to do this to some extent by using simple tools like ‘cat’ to write data to the serial port’s device file, but I could not get it to work reliably for binary data or files over a few kilobytes in size. It would sometimes drop data or stop halfway for no apparent reason.
Because of this I wrote a simple little program ‘writetoserial’ that reads the contents of file and writes it to a serial port as binary data. This works far more reliably and I’m now able to send both large text files and binary files to the FRDM-KL25Z.