Thursday, August 27, 2020

Three Important Things to Work From Home

As most people around the world with a desk job have been working from home for the better part of the last 6 months, and as I sit here displaced because of the California fires without my normalcy, I just wanted to write about a few things that I find important working from home, but the same can apply to working from an office as well:

1. A good headset

I have tried a lot of headsets. There are two that I really like 

Sennheiser GAME ZERO Gaming Headset

Apple AirPods

Both of these have noise cancelling and just work. Don't bother with the AirPod Pro noise cancelling, I'm sure they're nice but they are super expensive, and if you don't get the wireless charging case then you can get AirPods for around $120 which is still expensive but they really work great. Other similar headphones are out and I haven't tried all of them but considering I'd probably try 2-3 at half the price then surpassing the price of the AirPods and the AirPods work great I just go with it.


2. A good desk adjusted ergonomic desk that is adjusted properly



Buy a set of these legs and an IKEA butcher block counter top and you have yourself one awesome desk.

3. Exercise

Daily minimum 30 minutes of hard exercise. Find a routine and stick to it. Burpies in a tight space are great but get the heart rate up there.

Wednesday, August 26, 2020

Evacuated from the Fires in Santa Cruz - Tried to Rescue the Raspberry Pi Mini Super Computer

We had to evacuate our home because of the fires in Santa Cruz California. Trying to find some humor in a very difficult situation.



Thursday, July 30, 2020

Upgrade to macOS Catalina broke the Arduino IDE

Everything was working fine and then I upgraded to macOS Catalina. The Arduino IDE version 1.8.12 just wouldn't start. Then I ran from terminal and looked at the actually error.

./Arduino
Set log4j store directory /Users/cbensen/Library/Arduino15
2020-07-30 08:39:47.311 Arduino[73800:11442574] name is : .SFNS-Regular
2020-07-30 08:39:47.311 Arduino[73800:11442574] family is : .AppleSystemUIFont
2020-07-30 08:39:47.311 Arduino[73800:11442574] name is : .SFNS-Bold
2020-07-30 08:39:47.311 Arduino[73800:11442574] family is : .AppleSystemUIFont
2020-07-30 08:39:47.312 Arduino[73800:11442574] name is : .SFNSMono-Regular
2020-07-30 08:39:47.312 Arduino[73800:11442574] family is : .SF NS Mono
2020-07-30 08:39:47.706 Arduino[73800:11442574] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.706 Arduino[73800:11442574] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2020-07-30 08:39:47.706 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNS-Regular
2020-07-30 08:39:47.707 Arduino[73800:11442574] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.707 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNS-Bold
2020-07-30 08:39:47.707 Arduino[73800:11442574] CoreText note: Client requested name ".SFNSMono-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.707 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNSMono-Regular
2020-07-30 08:39:47.710 Arduino[73800:11442574] CoreText note: Client requested name ".SFNSMono-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.710 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNSMono-Regular
2020-07-30 08:39:47.710 Arduino[73800:11442574] CoreText note: Client requested name ".SFNSMono-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.710 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNSMono-Regular
2020-07-30 08:39:47.713 Arduino[73800:11442574] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.713 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNS-Regular
2020-07-30 08:39:47.713 Arduino[73800:11442574] CoreText note: Client requested name ".SFNS-Bold", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2020-07-30 08:39:47.713 Arduino[73800:11442574] needed to substitute Lucida Grande for: .SFNS-Bold
java.lang.NullPointerException
at cc.arduino.contributions.packages.ContributionsIndexer.parseIndex(ContributionsIndexer.java:134)
at processing.app.BaseNoGui.initPackages(BaseNoGui.java:483)
at processing.app.Base.<init>(Base.java:273)
at processing.app.Base.main(Base.java:150)

After some digging around, trying a few things I came across this article https://github.com/arduino/Arduino/issues/9828 and I decided to live life on the edge and try the hourly build! And that did it. So there's an issue and it apparently is known and has been fixed.

Thursday, July 23, 2020

Running Out of Memory with SQL Developer

Previously I wrote about getting SQL Developer to work, well, just work here. It just doesn't work as downloaded and is still a very useful tool when connecting to databases. I recently ran into another issue, which is out of memory problems. It's rather easy to fix but I spent all day tracking down in the boot scripts for how. So here's how (even if all I'm doing is documenting it for my future self):

1. Open the file in your favorite text editor:

/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/ide/bin/ide.conf

2. Search for the line:

AddVMOption  -Xmx800M

3. Change it to more, a lot more! I just added a couple zeros and I'm all good:

AddVMOption  -Xmx80000M

So there you have it.

Wednesday, July 1, 2020

Behind the Scenes - Building the World's Largest Raspberry Pi Cluster

I thought I'd published this already. Well, better late than never. Here is a look behind the scenes of building this amazing piece of equipment.

https://youtu.be/KbVcRQQ9PNw

 

Monday, May 4, 2020

Java Preview Features

Today I went to write some Java and test out the preview features. It wasn't as easy to use them as I thought it'd be. I normally use Netbeans. Don't ask. I use a lot of different IDEs but quickly realized yeah, JDK 14 and the preview features don't work in 11.3 at all. So here's how to get it working in InntelliJ IDEA.

1. Go to File and choose Project Stucture




















2. From here set the "Project language level" to 14 so you can write some records and text blocks.




Viola!

Thursday, April 16, 2020

3D Printed Face Shield


https://www.thingiverse.com/thing:4292328

I uploaded a quick easy to print 3D printed face shield. This is based off the model by:

https://3dverkstan.se/protective-visor/

I have included both the STL and the Fusion 360 files.

I solved three problems with the original design:

1. Healthworkers didn't like the curls at the end since it conflicted with face mask straps and headbands so now the ends are straight.

2. I changed it to use a standard 3 hole punch. It doesn't attached to as many places but it isn't a problem because of the other fixes.

3. Each of the three visor attachment nubs is notched so the plastic goes over easier. This also solved the problem where the visor plastic would tear and fall off.

Now some hospitals will only accept face shields that come up over the head. This could be easily modified but would require a laser cutter or had cutting plus additional material, or extra time 3D printing. Many hospitals will accept this design and they are far faster to produce. So I suggest testing it out.


 

Wednesday, April 15, 2020

SQL Developer on Mac

I'm doing a little Autonomous Database project so I downloaded SQL Developer for Mac. When I run it I get the error:

SQL Developer requires a minimum of Java 8.
Java 8 can be downloaded from:
 http://www.oracle.com/technetwork/java/javase/downloads/

Fortunately this is really easy to fix. I will file a bug so you don't have to make these changes but here's how to fix it.

1. Right click on SQL Developer in the dock and choose Options | Show in Finder
2. Right click on SQLDeveloper.app and choose "Show Package Contents"
3. Double click on Contents and then MacOS
4. Go to http://www.oracle.com/technetwork/java/javase/downloads/ and download JDK 1.8 JRE
5. Unzip it and copy the directory into the MacOS directory
6. Open sqldeveloper.sh in any text editor. I commented out everything in the file and pasted in the following:

export PATH=/Applications/SQLDeveloper.app/Contents/MacOS/jre1.8.0_251.jre/Contents/Home/bin:$PATH
export JAVA_HOME=/Applications/SQLDeveloper.app/Contents/MacOS/jre1.8.0_251.jre/Contents/Home

/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper

so now sqldeveloper.sh looks like this:

#!/bin/bash

# TMP_PATH=`/usr/libexec/java_home -F -v 1.8`
# if [ -z "$TMP_PATH" ] ; then
#   TMP_PATH=`/usr/libexec/java_home -F -v 9`
#   #TMP_PATH='/Applications/SQLDeveloper.app/Contents/MacOS/jre-9.0.4.jre/Contents/Home'
#   if [ -z "$TMP_PATH" ] ; then
#     osascript -e 'tell app "System Events" to display dialog "SQL Developer requires a minimum of Java 8. \nJava 8 can be downloaded from:\n http://www.oracle.com/technetwork/java/javase/downloads/"'
#     exit 1
#   fi
# fi
#
# export JAVA_HOME=$TMP_PATH
#
# if [[ -f $HOME/.sqldeveloper/19.1.0/env.sh ]];
# then
#   source "$HOME/.sqldeveloper/19.1.0/env.sh" >> /dev/null
# elif [[ -f $HOME/.sqldeveloper/env.sh ]];
# then
# source "$HOME/.sqldeveloper/env.sh"  >> /dev/null
# fi
#
#
# here="${0%/*}"
# cd "${here}"
# cd ../Resources/sqldeveloper/sqldeveloper/bin
# bash ./sqldeveloper >>/dev/null


export PATH=/Applications/SQLDeveloper.app/Contents/MacOS/jre1.8.0_251.jre/Contents/Home/bin:$PATH
export JAVA_HOME=/Applications/SQLDeveloper.app/Contents/MacOS/jre1.8.0_251.jre/Contents/Home

/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper

7. Save sqldeveloper.sh

Now run it and you should get the splash screen.



I actually worked on the core product that SQL Developer uses and built that splash screen, the fancy progress bar graphics and all the loading code of the plugins and migration system.

Monday, February 10, 2020

Fusion 360 On Mac

For the last year I've been using Fusion 360. Solidworks is too expensive for what I do, I haven't really liked Rhino or ViaCad, OpensCAD or FreeCAD. For the most part it works pretty good. There is however one problem I constantly encounter and that is the auto update mechanism leaves a lot to be desired. Chrome does this extremely well and I wish Autodesk would replicate their excellent system because at least once a month the Fusion 360 app either changes location in my dock or disappears completely. The disappearing completely is the biggest problem because then I have to go searching for it. Usually it lives here:

 /users/<username>/library/application support/autodesk/webdeploy/production/Autodesk Fusion 360.app

So hopefully this saves someone some time.

Monday, January 27, 2020

Raspberry Pi Overlay Root Filesystem

I copied this from https://yagrebu.net/unix/rpi-overlay.md so I don't loose it. I have done a lot of network booting and overlay file system work this last year and these are the best directions for overlay file system and don't want to loose them. I will rewrite them to include my own subtle changes at some point, and publish network booting and network booting + overlay file system (which is a total crazy mess with no directions).
Raspberry Pi Overlay Root Filesystem
This document describes a method to protect the root filesystem from writes while still allowing all applications to function as normal while writing to a temporary Overlay filesystem. Figuring this out would have been impossible for me without this excellent post by ejolson on the RPI.org forums.
For my installation I used a RPI 3 and the latest Raspbian Stretch Lite image (2017-11-29). I do not know if these instructions will work without modification on earlier RPI hardware.
Note: When the overlay filesystem is in place your RPI will function as usual, but any data generated after startup is only saved in RAM and will be lost upon reboot.

Let's Begin

First we need to create a initramfs image that contains the overlay module and a boot script to mount our root partition with the overlay. (All this could of course be compiled into the kernel image, but initramfs-tools(8) is an easier way to learn about the early init-process.)
echo overlay >>/etc/initramfs-tools/modules
Place the following boot script in /etc/initramfs-tools/scripts/overlay (download):
# Local filesystem mounting                     -*- shell-script -*-

#
# This script overrides local_mount_root() in /scripts/local
# and mounts root as a read-only filesystem with a temporary (rw)
# overlay filesystem.
#

. /scripts/local

local_mount_root()
{
        local_top
        local_device_setup "${ROOT}" "root file system"
        ROOT="${DEV}"

        # Get the root filesystem type if not set
        if [ -z "${ROOTFSTYPE}" ]; then
                FSTYPE=$(get_fstype "${ROOT}")
        else
                FSTYPE=${ROOTFSTYPE}
        fi

        local_premount

        # CHANGES TO THE ORIGINAL FUNCTION BEGIN HERE
        # N.B. this code still lacks error checking

        modprobe ${FSTYPE}
        checkfs ${ROOT} root "${FSTYPE}"

        # Create directories for root and the overlay
        mkdir /lower /upper

        # Mount read-only root to /lower
        if [ "${FSTYPE}" != "unknown" ]; then
                mount -r -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /lower
        else
                mount -r ${ROOTFLAGS} ${ROOT} /lower
        fi

        modprobe overlay

        # Mount a tmpfs for the overlay in /upper
        mount -t tmpfs tmpfs /upper
        mkdir /upper/data /upper/work

        # Mount the final overlay-root in $rootmnt
        mount -t overlay \
            -olowerdir=/lower,upperdir=/upper/data,workdir=/upper/work \
            overlay ${rootmnt}
}
Create the initramfs image:
update-initramfs -c -k $(uname -r)
It will be placed in /boot/initrd.img<kernel_version> - you can rename it to match your kernel file if you want.
Add the following to /boot/config.txt - where initrd7.img is the initramfs image you created in the previous step:
kernel=kernel7.img
initramfs initrd7.img
And finally, add boot=overlay to the beginning of /boot/cmdline.txt.
This should do it. Reboot and keep your fingers crossed.

Kernel Panic

If the OS doesn't come back up, there is probably a typo somewhere, or you missed something.
You can remove boot=overlay from cmdline.txt to boot as normal.
A serial connection can be really handy when trying to troubleshoot the startup process. USB TTL console cables are dirt cheap, just make sure you get one that outputs 3.3V on the TX line so that you don't fry your RPI. Use screen(1)'s buffer to scroll back and try to figure out where it went wrong.
The documentation is also quite good. Read the man page for initramfs-tools(8) and the default boot scripts themselves:
less /usr/share/initramfs-tools/init
less /usr/share/initramfs-tools/scripts/local

Finishing Touches

Read-Only /boot

The /boot filesystem is still mounted rw. You can protect it as well by adding ro to the boot partitions mount options in /etc/fstab:
PARTUUID=72a9e9a9-01   /boot   vfat   defaults,ro   0   2

overctl

Since I would be updating the filesystem on my RPI regularly, I wanted a secure way to enable and disable the overlay. overctl has the following features:
Usage: overctl [-h|-r|-s|-t|-w]
   -h, --help     This message
   -r, --ro       Set read-only root with overlay fs
   -s, --status   Show current state
   -t, --toggle   Toggle between -r and -w
   -w, --rw       Set read-write root
Place the script in /usr/local/sbin and mark the file as executable. You will also need to create the following files containing the cmdline.txt options that you wish to toggle between:
/boot/cmdline.txt.orig
/boot/cmdline.txt.overlay

motd(5)

I figured I could use a reminder of which state the RPI is in. So I cobbled together this motd(5) script:
#!/bin/sh

str=$(mount | grep ' on / ')

if echo $str | grep -q 'overlay'; then
        printf "\n------ INFO: / MOUNTED WITH OVERLAY ------\n\n"
elif echo $str | grep -q 'rw'; then
        printf "\n++++++ INFO: / MOUNTED READ-WRITE ++++++\n\n"
else
        printf "\n!!!!!! WARNING: / UNKNOWN STATE !!!!!!\n\n"
fi
Place the code above in /etc/update-motd.d/80-overlay and make sure the file is executable.

Wednesday, January 8, 2020

Sony vs Canon: DSLR and Mirrorless

I had the Sony A9 and AIII and just couldn't use them because they are way too small for my hands. I think there has been so much attention on mirrorless, as well as marketing money to influencers on YouTubers which makes it seem like everyone is using Sony. I get it, mirrorless has it's place, and there are some great features. there's also some terrible features. I currently use a number of Canon DSLR cameras including the Canon EOS R. The R isn't my favorite camera, but it has grown on me. Anytime I reach for a camera, certainly for traveling, that is what I bring 90% of the time. The R and a Canon 7GX MII has been with me to 4 continents over the last year and I honestly wouldn't trade them for any Sony, despite having access to them. So here is my list of pluses and minuses:

- Blackout: The A9 has no blackout, all other mirrorless cameras have way too much blackout in my opinion. Canon R blackout is better than any Sony other than A9 but impossible to oh take photos of whales because they move too fast. Any DSLR such as Canon 5D MIV work fine for sports and wildlife photography, I just don't get the complaining of DSLR blackout. A DSLR instantly refreshes, where a mirrorless displays the previous image for way way too long and then refreshes. Only the A9 is usable for any wildlife or sports photography period.

- In body image stabilization (IBIS) I really don't understand why everyone wants IBIS. IBIS actually is a detractor if you want a seriously durable camera because the sensor shakes around.

- Smaller bodies are good for small hands, but not good for big hands. I have tried every battery grip available for the A series and they just don't work. The new body design is better, but not even close to a Canon or Nikon. Also the grip is shallow enough and the lens release is at the base of the body so when I grab the camera I've released the lens more than a few times.

- Sony can't handle water. If a Sony looks at water it stops working. Where I have dropped my 1D in river water and they keep working.

- Sony has no service support. When a camera needs servicing Sony suggest throwing it away and buying a new one. Canon has CPS, which is awesome if you need a camera serviced. Absolutely ridiculous Sony. No professional can depend on a Sony because of this.

- Shake a Sony camera and it makes noise. Strange.

- Love Sony A9 silent shooting, amazing for Wedding photography. Absolutely a game changer.

- I like the flip out LCDs on Canon better than Sony. Also the touchscreen. The menu system on Canon is way better too. The video codec is a little better on Sony.

- Canon color science is the best there is. Nikon is actually really great too. Hasselblad is pretty awesome too. Sony, not so much, every photo and video needs to be adjusted to look good. But Nikon video is lacking.

- Weight. Anyone that tells me that a Sony weighs less is crazy. Put a comparable lens on both cameras and compare the weight, they are basically the same and actually the Sony weighs more, just with a tiny camera in your hands. If you put a super small lens on a Sony then you have a weight savings, but meh. Now size is a bit smaller for traveling which is nice. But go for a micro 4/3 if size is a real issue.

- What is really nice about mirrorless is there's a shutter release button for photos and a record button for video. You don't have to switch between modes and remember do I look through the eyepiece or the rear screen.

- Lastly, all camera's do their best autofocus in good light. However, mirrorless cameras have poor autofocus anytime the light is anything less than good. The reason for this is what you see is what you get, but that is also what you autofocus from, where a DSLR will flip the mirror down and open up the lens aperture, evaluate then flip everything back to take the photo. This can take time, but 16 FPS for the pro series and 5FPS for the low end is pretty darn good.

Friday, December 20, 2019

Get MAC Address for a Pi Cluster

There are a lot of ways to get the MAC address for a Raspberry Pi. For the Super Pi there were a lot of Pi, 1050 to be specific (two of them are dead on arrival and we disabled 24 of them to get the exact number we wanted, 1024), we looked at the DHCP log files. Roy and Mike spent a few days doing this. Think about it, if you spend one minute times 1050, that's 17.5 hours! I'm surprised they didn't go crazy but they seemed to be having fun. For the Mini Super Pi, I need to know the order.

At this point I'm going to digress a little. When building a large Raspberry Pi cluster at some point it's worth network booting. I'd say after 8 the cost of network booting is worth it. Just the time and expense of buying and cloning eight network cards. Network booting a Pi isn't terribly difficult, it's doing it consistently with a lot of them that's the problem. The netboot on a Pi times out after a short period of time, it isn't implemented 100% to spec, I could go on but these are things you can find out with some research. Although it's buried so if people want me to document these issues let me know in the comments. If there are any problems netbooting the Pi can be dead in a big cluster with no way to reboot it except reboot the entire thing. It helps to have a static IP address. Best way of doing this is by using DHCP (yeah, that's confusing) but map the MAC address to an IP address. Oh, also if you have enough Raspberry Pi, the MAC address may not be unique. We have two Pi with the same MAC addresses. Most clusters won't run into this. Also, network booting while not difficult requires the use of overlay file system. The problem comes when combining the two which is rather difficult. I got overlay file system working. Roy merged netboot and overlay and Vijay did this with Oracle Linux. There are a few other options netboot and redirect all writes to separate files and hope you got all them, create an NFS mount for each Pi (yeah, no). The only downside to netboot + overlay file system is you can't run Docker, which means you can't run K8 because Docker uses overlay and you can't use overlay on top of overlay.


OK, back to the reason for this blog post. My new system for obtaining the MAC address is as follows:

1. Install Raspbian on an SD card. I used belenaEtcher on Mac just because it's easy.
2. Copy the following Python script to the Pi and call it pimac.py

import socket
import time
import threading
import datetime
import uuid
import random

# This is needed so we get a network interface
time.sleep(20)

# Global variables
MacAddress = hex(uuid.getnode())
print(MacAddress)
print(type(MacAddress))

if MacAddress.endswith('L'):
    MacAddress = MacAddress[:-1]
    print(MacAddress)

client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client.bind((""2222))


server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
server.settimeout(0.2)
server.bind((""3333))
hostname = socket.gethostname()    
IPAddr = socket.gethostbyname(hostname)    
print("Your Computer Name is:" + hostname)    
print("Your Computer IP Address is:" + IPAddr)

def SendMessage(portmessage):
    data = message
    endodeddata = data.encode()
    server.sendto(endodeddata, ('<broadcast>', port))
    print("message sent!" + data)

while True:
    SendMessage(3333, MacAddress)
    time.sleep(2)

3. Create a cron job:

sudo crontab -e

4. Add this line to the end of the file:

@reboot python /home/pi/pimac.py &

5. Copy the following Python script to your desktop and run it. I'm running it in Visual Studio Code.

import datetime
import os
import signal
import socket
import threading
import time
import re
import uuid

if os.name == 'nt':
    signal.signal(signal.SIGINT, signal.SIG_DFL)


server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
print("Your Computer Name is: {0}\n".format(hostname))
print("Your Computer IP Address is: {0}\n".format(IPAddr))


def waitForPosts():
  print('Ready')

addresses = {}

class Listen(threading.Thread):
    def __init__(selfport):
        threading.Thread.__init__(self)
        self.port = port
        self.UIDCount = 0

    def run(self):
        client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
        client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
        client.bind((""self.port))

        while True:
            data, addr = client.recvfrom(1024)
            mac = data
            if mac not in addresses:
                addresses[mac] = mac
                val = mac.decode()
                print (':'.join(re.findall('..''%012x' % int(val, 16)))) 


publish_thread = Listen(3333)
publish_thread.start()

waitForPosts()

Note: If you decide you want to remove the dictionary in the code above to allow duplicate MAC addresses to print out, which his a great debugging tool and since UDP is not guaranteed is a perfectly fine way to go, then you might want to remove duplicates. To do this in Visual Studio Code this is one way I found to do it:

  1. Control+F
  2. Toggle "Replace mode"
  3. Toggle "Use Regular Expression" (the icon with the .* symbol)
  4. In the search field, type ((^[^\S$]*?(?=\S)(?:.*)+$)[\S\s]*?)^\2$(?:\n)?
  5. In the "replace with" field, type $1
  6. Click the Replace All button ("Replace All").
6. So now insert the SD card, plug the Pi into network, and power and wait. The output on your desktop will be a list of your MAC addresses in a known order and it is easy to know if one is dead and which one.