Raspberry Pi GPSD with Pepwave MAX Transit

I’ve been wanting to do some GPS data programming with the Raspberry Pi that’s on my boat. The Pi is connected to the NMEA 2000 network, and so should be able to retrieve GPS coordinates from either my chartplotter or my AIS unit when they are powered on, but it should also be able to get the GPS data from my Max Transit cellular gateway device.

It turns out that configuring gpsd to retrieve the data from the max transit was fairly easy. I edited the file /etc/default/gpsd to include the internal address and port of my router and restarted gpsd and now the Pi has the correct location.

/etc/default/gpsd

The devices section was initially empty. I added tcp://192.168.50.1:60660 between the pair of double quotes. After that, I was able to run gpsmon with no parameters and it connects to the local machine and reports the gps statistics.

gpsmon

I’d verified that I can read the device directly over the network with the command gpsmon 192.168.50.1:60660 but I wanted to be able to write my programs without needing to know where the gps was located.

gpsmon

B&G Zeus™ 3S 9 Tracks Truncated

I’ve been extremely happy with my new chartplotter when I’m actively using it. I’ve been frustrated by some of the features.

I wish it would automatically start recording a new track every time it was turned on. It seems that this should be an option in the settings, but I’ve not been able to find such an option.

The bigger issue is that it seems to reduce the size of stored tracks. This may be related to whatever it’s doing to synchronize with the online map, but the behavior is extremely annoying as it means I don’t have the true logged data of where I visited on my two week trip to the San Juan Islands over July 4th.

Tracks on return from trip

The image above shows the track that had been running from my leaving of Odlin County Park on Lopez Island on July 5th, going north to Orcas Island, then sailing south to Mackaye Bay on Lopez Island on July 6th, and finally motoring south to Shilshole on July 7th, arriving a little past 3pm.

Tracks after the boat has not moved for two weeks.

The second image was taken on July 22nd. You can see that the number of points for the Leave ODLIN track has reduced from 16063 to 178. Even stranger is that the Spencer Spit log has increased from 124 points to 134, and Deer Harbor has increased from 56 to 61.

Synchronize Settings

I had the plotter set to automatically synchronize settings with the mobile app and the web site, but have disabled it as of today to see if future logs will not be truncated. The auto synchronization was a very nice thing initially because I was able to create a series of places at my desktop using the full keyboard and mouse, and then the next time I turned on my chart plotter they appeared on the plotter with my intervention.

Waypoints

I realized that the waypoints I’d created all had the default icon. I went in and changed the icon on the chart plotter for each if the locations and something also truncated the names. I don’t know if it was the synchronization with the online service, or the chartplotter itself, but losing data is never a good thing.

Another feature that would be extremely nice would be if the time at the top of the screen included the date and UTC offset or timezone.

AppleCare+ with Theft & Loss Monthly Subscription

Tuesday July 20th I had a shock after upgrading my iPhone with the latest iOS.

I went digging around in my email for records of apple communications. I’d cancelled Apple TV+ before I had to start paying for it on July 1st. I was hoping that I’d not mistakenly cancelled multiple subscriptions. I know that I’d purchased my iPhone about two years ago, but knowing Apple’s release schedule, wouldn’t have bought it until after September.

I found the email invoice from June 20th, 2021, paying for the monthly update, as well as the 20th of each month, going back until I had initiated AppleCare on December 20th, 2019.

I had a conversation with a friend via texts about AppleCare in which he checked the situation on his sons iPad and recognized that it would end coverage at 24 months fairly soon. My conclusion was that I’d probably purchased my phone 90 days before I purchased the AppleCare subscription. I didn’t like the fact that it was currently showing coverage expired in the phone, but didn’t want to deal with apple to find out what was going on, hoping that this was simply a bug in the interface on the monthly renewal date.

At nearly 8:30pm on July 21st I got an invoice for the next month’s AppleCare in my email, and went and checked the about box. Now it’s correctly showing my coverage. I’m glad that it resolved itself without my intervention, but I think it’s a bad bug in the system that shows coverage expired on the regular monthly renewal date. I wonder what would happen if I were to lose my phone on the 20th of any particular month?

One of the things that’s still unknown is if I’ll be able to maintain this coverage past the 24 month period. AppleCare can be purchased up front as a fixed cost, or spread over monthly fees. One of the benefits of the monthly mode is that you can cancel at any time. The small print makes it slightly ambiguous if the recurring cost will continue indefinitely, or if it will automatically end after 24 months of phone ownership. I’m hoping for the former, because I’ve usually kept my phones for three years instead of two. I’ve never needed to use the phone insurance, but liked the idea of dealing directly with Apple if I needed to get anything fixed with the phone.

Canon CanoScan LiDE 400

I’ve had a Canon CanoScan LiDE 210 for at least 7 years. One of the deciding factors when I bought it was that it used a single USB cable, with no need for a second power cable.

The 210 used a mini-usb cable, which was sometimes difficult to make sure it was inserted in the correct direction. I occasionally had problems with the software driving losing communication during a scan. I switched lengths of cable at various times, with shorter cables seeming to be more consistent, but never truly conclusive.

Recently the scanner stopped moving the scan bar back to the starting location before each scan. First it would leave the scan bar at the finish location, and move to the beginning position when I would start the next scan, but then that functionality stopped and it would only return to the start position when it was first plugged into the USB port. If I tried to scan a second page without unplugging the USB cable, the movement motor would make a nasty grinding sound as it tried to move the scanner further down the page, and would result in a messy black page in the scan results. It was especially frustrating if I was trying to create a multi page PDF.

I read several online reviews, and decided to get another Canon scanner. The reviews recommended saving $20 and getting the less expensive scanner, but from my reading, only the more expensive scanner used the USB C plug, which has the advantage that it can be plugged in either direction.

I found it fascinating how similar the new packaging is to the old packaging. The old box was designed with a carrying handle, while the new box is not. I expect that’s largely due to the predominance of mail order over retail purchase. The dimensions of the new scanner and the box are pretty much the same. The boxes can be stacked 13 high. The temperature range on the old one could go 5° to 35°C while the new one goes from 0° to 40°C. Each scanner lists a maximum 4800 dpi. The 210 reported 10 seconds per page. The 400 reports 8 seconds per page.

The new software is slightly nicer working with the most recent version of windows 10, but still nothing to be too excited about. My biggest issue is that the settings for the Auto button on the scanner will not allow me to specify it will always save a JPG file. I could do that with the old scanner software. Now, to make sure I always get the format I want I much launch the software and initiate the scanning from the PC.

iOS14 Date Time Picker Rant

I upgraded to iOS14 as soon as it was released just because I almost always keep my devices running the most up to date software I can. I don’t care about the widgets or interface customization options that were introduced with iOS14. I think much of that customization is actually what has kept me away from running Android.

The one thing that I really hate that was introduced was the date time picker in iOS14. I’ve included screenshots from my iPhone 11 Pro Max running the new version and my iPhone 7 running the old version.

The old version had the issue that it was not intuitive to be able to pick a minute that didn’t align to five minute increments, but was very easy to select the day, hour, or minute individually and scroll to a reasonable number for the start time, then switch the the end time and do the same. The keyboard was only shown when I was typing the name of the appointment or the location.

The new one uses half of the screen to pick just the day, as well as displaying the keyboard, which does not seem to affect the time. I touch the tiny display with the time, and if I can select the hour, I can scroll my finger up and down over the entire screen to scroll the number. If I miss the number slightly, the screen moves to show my another part of the entry field. Then I have to repeat the same solution with the minute. When I’m trying to hit the hour, I hit the minute, and vice versa.

Because of the size of the calendar entry, I have to scroll the entire screen to find where the end time might be.

This change just feels like change for change sake, and poorly implemented. I wonder if it’s even worse on a smaller screen.

Old Man Yells at Cloud

iOS14.1 was released today, and I’ve already upgraded to it, but don’t see anything I’d consider an improvement to this issue.

GoveeBTTempLogger as a Debian Package

After getting my program to listen and log Bluetooth Low Energy advertisements from Govee thermometers running reliably, I needed to figure out how to make the program automatically start when my Raspberry was rebooted. I was led down two paths to get things working, systemd unit files, and debian package files created with dpkg-deb.

The final file structure I came up with is visible in https://github.com/wcbonner/GoveeBTTempLogger but still can use some explanation as to what I did.

To create the debian package, I created a file structure under my source repository that mimicked what I wanted to put on the target system.

\GOVEEBTTEMPLOGGER\GOVEEBTTEMPLOGGER
├───DEBIAN
│       control
│       postinst
│       postrm
│       prerm
│
├───etc
│   └───systemd
│       └───system
│               goveebttemplogger.service
│
├───usr
│   └───local
│       └───bin
│               goveebttemplogger
│
└───var
    └───log
        └───goveebttemplogger
                gvh507x.txt

I had decided I wanted my executable to be located in /usr/local/bin. It’s the file named goveebttemplogger. I wanted it to write log files into /var/log/goveebttemplogger/ and the easiest way to make sure that directory was created was to put a zero length file in that directory, gvh507x.txt.

The files in the DEBIAN directory are used by the dpkg-deb program when building the distributable package. More on those later.

To get the program configured to automatically run when the machine boots, and properly stop when it shuts down, I settled on the systemd unit files as the both the easiest and most reliable method. I’ve been around linux long enough to first think of /etc/rc.local manipulation, then script files for various runlevels in the /etc/init.d/ directories, and was amazed at both the power and ease of setting up to use the systemd unit files. The hardest part was figuring out what other services my program must have already started. I knew it was dependent on Bluetooth, but the specific services was a bit of a guess.

# Contents of /etc/systemd/system/goveebttemplogger.service
[Unit]
Description=GoveeBTTempLogger service
After=bluetooth.target dbus-org.bluez.service network.target
Requires=bluetooth.target
KillSignal=SIGINT

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/goveebttemplogger -v 0 -l /var/log/goveebttemplogger/

[Install]
WantedBy=multi-user.target

After creating that file in the specified location, I was able to issue the following commands to make systemd start the program.

sudo systemctl daemon-reload
sudo systemctl enable goveebttemplogger.service
sudo systemctl start goveebttemplogger.service

The most unique bit of my unit file is that I specifically want my program to be sent the SIGINT signal to kill it, since I will recognize that and flush the log files before exiting. The ExecStart line is the command line to run my program, which I’m also specifying the log directory as one of the parameters.

I had the systemd unit file and the initial DEBIAN/control file figured out pretty easily. I’d come across this https://linuxconfig.org/easy-way-to-create-a-debian-package-and-local-package-repository article which helped understanding the control file.

Package: GoveeBTTempLogger
Version: 1.20200725-1
Section: custom
Priority: optional
Architecture: armhf
Essential: no
Installed-Size: 95
Maintainer: wcbonner@users.noreply.github.com
Description: Listen and log Govee Thermometer Bluetooth Low Energy Advertisments
Depends: libbluetooth3

What took me a while to figure out was how to get the systemctl commands to be run after the files were put in place by the package manager. There are four script commands, which I’m using three. preinst, postinst, prerm, and postrm. Each of them is a simple script and needs to be marked executable in the file system. They are each run at various stages by the package manager, Pre-Installation, Post-Installation, Pre-Removal, and Post-Removal.

#!/bin/sh
# POSTINST script for goveebttemplogger

echo "\033[36m HI I'M A POSTINST SCRIPT `date +"%s"` \033[39m"
systemctl daemon-reload
systemctl enable goveebttemplogger.service
systemctl start goveebttemplogger.service

exit 0

After installation of my program and the systemd unit file, I reload the systemd database, enable my service, and start my service.

#!/bin/sh
# PRERM script for goveebttemplogger

echo "\033[36m HI I'M A PRERM SCRIPT `date +"%s"` \033[39m"
systemctl stop goveebttemplogger.service
systemctl disable goveebttemplogger.service

exit 0

Before removal of my program, I stop the service and disable the service.

#!/bin/sh
# POSTRM script for goveebttemplogger

echo "\033[36m HI I'M A POSTRM SCRIPT `date +"%s"` \033[39m"
systemctl daemon-reload

exit 0

After removal of my program, I reload the systemd database, to make sure it’s not got my unit file in its database any longer.

When I retrieve a copy of my code with the command git clone https://github.com/wcbonner/GoveeBTTempLogger I then have a subdirectory below the GoveeBTTempLogger that is also named GoveeBTTempLogger. That deeper directory is the structure that will be created into the package.


GoveeBTTempLogger/usr/local/bin/goveebttemplogger: goveebttemplogger.cpp
        mkdir -p GoveeBTTempLogger/usr/local/bin
        g++ -lbluetooth goveebttemplogger.cpp -o GoveeBTTempLogger/usr/local/bin/goveebttemplogger

deb: GoveeBTTempLogger/usr/local/bin/goveebttemplogger GoveeBTTempLogger/DEBIAN/control GoveeBTTempLogger/etc/systemd/system/goveebttemplogger.service
        mkdir -p GoveeBTTempLogger/var/log/goveebttemplogger
        touch GoveeBTTempLogger/var/log/goveebttemplogger/gvh507x.txt
        chmod a+x GoveeBTTempLogger/DEBIAN/postinst GoveeBTTempLogger/DEBIAN/postrm GoveeBTTempLogger/DEBIAN/prerm
        dpkg-deb --build GoveeBTTempLogger

I made the very simple makefile above to both compile the code and build the debian package with the simple command of make deb. It produces the package ‘goveebttemplogger’ in ‘GoveeBTTempLogger.deb’.

I can then install the package and start it running with the command sudo apt-get install ./GoveeBTTempLogger.deb

I can stop and either remove it or purge it with the command sudo apt-get remove goveebttemplogger or sudo apt-get purge goveebttemplogger.

Windows File Recovery from Microsoft

Last week Microsoft released a new command line tool in the Microsoft Store. It requires running Windows Version 2004.

Last year when I was importing pictures from a camera memory card, the import program crashed. It only managed to import a few of the pictures, but it deleted all of the pictures from the memory card.

Because of my long history understanding how file systems work, I knew that the pictures were likely still on the card, just not in the directory system I couldn’t find a tool at the time to recover the files. I’d put a label on the card and set it aside. As soon as I heard about this program I installed it and tried it out on the memory card.

The funny thing is that it recovered several thousand images, going back several years. I ran it in signature mode, looking for jpeg files. In doing that, It’s just looking at all the data blocks on the drive, looking for jpeg files.

This time I used Adobe Lightroom CC to import the images and group them by the embedded EXIF data. Looking at the details, the photos that got deleted by mistake were likely from 10/28/2018. All of the photos attributed to 06/29/2020 are missing exifdata, and are just recorded as the date they were recovered.

This is a good reminder that you probably don’t want to throw away old digital media, even when you think you’ve gotten rid of all incriminating data.

https://storebadge.azureedge.net/src/badge-1.8.4.js mspb(‘9n26s50ln705’, function(badge) { document.getElementById(‘mspb-yfhgln7xadp6’).innerHTML = badge; });

Retrieve Wi-Fi Password in Windows 10

Sometimes I go to a place I’ve been before and my computer remembers the WiFi password while my brain does not. The following Windows PowerShell commands will display most of the remembered passwords.

netsh wlan show profiles

netsh wlan show profiles name=’ProfileToDisplay’ key=clear

The first command displays all of the networks your computer has remembered. It can be rather long if you’ve had your computer for several years and done a reasonable amount of traveling and using WiFi in strange locations.

2019-11-27 (1)

The second command takes the profile name that you retrieved with the first command and displays details of the selected profile. The password is displayed as the Key Content section of the Security settings.

2019-11-27 (2)

Microsoft Surface Pro 4 Screen Flicker

My nearly four year old Microsoft Surface Pro 4 recently developed a screen flicker issue. I’m sure it was some driver update that was installed, but I’m not exactly sure when. The observed activity is that a horizontal section at the bottom of the screen about the same size of the mouse cursor flickers with data that is duplicated from the top of the screen. The rest of the screen appears to be bouncing up and down by one scan line, making the text nearly unreadable.

I searched online, and found references to flicker problems with some cases being purely hardware related and requiring replacement by Microsoft. I also found references to the problem only occurring after the screen data had not changed for a few seconds. This static screen problem matched my problem exactly.

I found a workaround by enabling the seconds display in the clock in the task bar. This is done by creating a registry entry. If the following is in a “.reg” file it will set the value to show the seconds on the clock.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"ShowSecondsInSystemClock"=dword:00000001

I read that the seconds are not enabled by default because it saves a bit of processing power, which can be important on battery powered devices. For me the difference is minimal and worth not spending more time researching a probable driver issue that may be taken care of automatically in some future windows update.

2019-10-04 (1)2019-10-04

I hope that this helps someone else. The screen flicker/jitter was annoying and I wasn’t able to find the root cause.

 

Access Windows share from Raspberry Pi

I have a shared directory from my windows server that I’d like to read and write from my Raspberry Pi. I want the share to be automatically available on my Raspberry Pi whenever both the Raspberry and the Windows server are running, but I don’t want the system to spend too much time hung up if the windows server is not available. My easy solution is below.

My Windows servername is Acid. The share I want to connect to is Web. The IP address of the server is 192.168.0.12.

sudo echo 192.168.0.12 Acid>>/etc/hosts
sudo mkdir --parents /media/acid/web
sudo echo username=WindowsUsername >/etc/wimsworld.smb.credentials
sudo echo password=WindowsPassword >>/etc/wimsworld.smb.credentials
sudo echo domain=OptionalDomainName >>/etc/wimsworld.smb.credentials
sudo chmod 0600 /etc/wimsworld.smb.credentials
sudo echo //acid/web /media/acid/web/ cifs credentials=/etc/wimsworld.smb.credentials,noauto,x-systemd.automount,x-systemd.idle-timeout=1min,_netdev 0 0>>/etc/fstab

That series of commands, with the correct details in the credentials, and the system automounter will automatically attempt to connect whenever there’s an access under /media/acid/web and then disconnect again after it’s been idle for over a minute.

I needed to add Acid to my local hosts file because the name doesn’t resolve from the DNS server the raspberry pi is using.

I put the windows Username/Password and Domain in a file with only read/write permissions to root so that it wasn’t clear text in the fstab file for anyone on the machine to read.

I did all of this on a machine that had been built from the Raspian Buster Lite image from 2019-07-10. I didn’t explicitly install the cifs-utils package. It might be needed on other distributions.