Monthly Archives: January 2017

Converting Mac OS X text/hex files to Windows

Mac OS X produces files with just an LF the end of each line.  Windows produces files with both CR and LF.

I ran into a problem building HEX files with MPLAB X IDE on my Mac, the hex files had just LF’s terminating each line but my downloading process required that I have CR and LF marking EoL.

The internet–and I don’t reference one site because I found this in many places–had the answer as usual.

Here is a short Perl incantation that can replace each LF with a CRLF:

perl -pi -e 's/\r\n|\n|\r/\r\n/g' YOURFILENAMEHERE

I use the above as part of a bash script that automatically converts and uploads my hex files to a server:

#!/bin/bash
fwVer=$(date +%y%m%d%H%M%S)
if [ -n "$1" ]
then
  fwVer=$1
fi
perl -pi -e 's/\r\n|\n|\r/\r\n/g' /my/local/path/myprojectfile.hex
scp /my/path/myfile.hex myuser@my.server.com:/my/remote/path/$fwVer.hex

If I supply an argument when calling the script it will use that name when uploading the file, otherwise it will name the file based on the current time using YYMMDDHHMMSS format which allows the latest files to sort up to the top of a list and gives you some clues about when you built one vs. the other.

A quick note, there is no line break in the scp command, but it may appear that way due to formatting on this page.

NASA: Never Assume Something’s Apparent

The Voyagers’ Galactic Trek [NASA.gov]

Thank you NASA for specifically letting me know that this ~40 year old probe will not be functioning in tens of thousands of years.

That said, here’s to hoping that one day we offer cruises along the historic paths these probes took and they become moving historical artifacts that we can visit.

Setting up RPI3 for RTL_433

Install RTL-SDR

apt-get install rtl-sdr

Install gpsd and clients

apt-get install gpsd gpsd-clients python-gps

Install the parts needed for rtl_433

apt-get install libtool libusb-1.0.0-dev librtlsdr-dev

Install cmake

apt-get install cmake

Clone the rtl_433 git repository and install

git clone https://github.com/merbanan/rtl_433.git
cd rtl_433/
mkdir build
cd build
cmake ../
make
sudo make install

Install the parts needed to write your own gpsd programs

apt-get libgps-dev

Go off and do stuff that needs doing…