   
   func dumpCommandPacket(data: Data) -> Void
   {
+    if data.count == 0
+    {
+        print("Unable to dump empty packet")
+        return
+    }
+    
     let packetNumber = data.first!
     let commandTypeByte = data.suffix(from: 1).first!
     let commandType = DeviceCommandType(rawValue: commandTypeByte)!

                    repeats: true)
                }
              }
            case .Diagnostic:
              print(self.receiveBuffer)
            default:

              {
                if #available(OSX 10.12, *)
                {
                  self.heartbeatTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true)
                  { timer in
                    self.getTime()
                    self.getTimeMs()
