Thunderbird mail notification flag via USB

In 2021 I made a MQTT notification Flag using a Servo and python code and webhooks to get notifications.
Webhook was used for Mattermost.

Now i’ve changed the notification flag for Email using Thunderbird.
Just connect the wemos to a USB on your computer, no mqtt/wifi needed. (On the road solution)

Steps:

Install FiltaQuilla Add-on in thunderbird
select run program in config.

Next create a filter

Create two bash files (i’ve got mine in ~/bin/ )
Change ttyUSB0 if needed

::::::::::::::
flagoff.sh
::::::::::::::
#!/bin/bash
stty -F /dev/ttyUSB0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
echo 0 > /dev/ttyUSB0

::::::::::::::
flagon.sh
::::::::::::::
#!/bin/bash
stty -F /dev/ttyUSB0 ispeed 9600 ospeed 9600 -ignpar cs8 -cstopb -echo
echo 1 > /dev/ttyUSB0

Install YAD and a autostart icon to make the systemtray to pull the flag down.

henri@zspot:~$ cat .config/autostart/servoflag.desktop 
[Desktop Entry]
Type=Application
Version=1.0.0
Name=flag-off
Comment=
Icon=
Exec=yad --notification --image="gtk-execute" --command="bash /home/henri/bin/flagoff.sh" --image="mail-app"
Terminal=false

Arduino Code

#include <Servo.h> 

Servo flag; 
char val;
 
void setup() {
  Serial.begin(9600);
  flag.attach(D5);
  }

void loop () {
  val = Serial.read(); 
  if (val == '0') {
     flag.write(180); 
  } 
  if (val == '1') {
     flag.write(0); 
  }
}

Webos Developer Mode and Homebrew

Besides sending notifications and controlling my tv using bash, Nodered and HomeAssistant, i wanted to look at developing and homebrew for WebOS.

Goto the WebOS Dev website and register.

Install Developer App on your TV.

Login and write down your access information.

Remain session can be extended using the button, or using a script.

Below how to access you tv using ssh

wget http://IP_FROM_YOUR_TV:9991/webos_rsa
mv webos_rsa .ssh/
chmod 600 .ssh/webos_rsa
ssh -i .ssh/webos_rsa prisoner@10.1.0.14 -p9922 -T
       Enter passphrase for key '.ssh/webos_rsa':
Enter the key mentioned on the Developer App Screen on your TV

Note the -T .. this disables pseudo terminals,
You won't see a prompt, but commands work

You can remove passphrases on ssh keys using below
ssh-keygen -p -f .ssh/webos_rsa
Enter old passphrase:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.


Download WebOS manager from here:

https://github.com/webosbrew/dev-manager-desktop/releases/tag/v1.11.18

Install and use same ip/access key info to install homebrew

After that you can install homebrew apps using the App on your TV or via above dev-manager.
Also nice .. A ad-free version of Youtube!

By the way, I tried rootmy.tv .. but that didn’t work for me.
My TV was already patched for that exploit

Raspberry PI and Arduino black hole

This is NOT a post about the pi-hole project. Of which I apparantly never posted my setup.

I needed an extra PI for a project, and I always try to keep one spare.
But they are always gone, in use, missing .. whatever.

So I can´t work on this project right now, so lets rant about disappearing stuff

Like they are being sucked up in another dimension .. gone. WHERE ARE THEY?!?

How to keep track of them?

Any suggestions?


I used to have a sheet, but I often forget to keep track.
Do I use a MAC address scan on my switches?
First 3 parts of the Mac address are vendor specific.

So far i’ve found : Octopi, Beerbrew computer, Retro Arcade, Picore, Nodered, Domoticz 433toMqtt, Ledserver, Lasercutter-etch-a-sketch, mobile LMS music server, Pressure Lab AP, Escape Game AP (3 of them), one unused Raspberry zero (without Wifi), One at my old work, one broke, Kodi+Netflix,Ansible project, found another one .. Jumanji/Dashticz/NoderedDashboard demo (with screen)
WHERE THE F are the rest of them?
(Sdcards with temporary projects on them 29, I need to combine project on those cards. I’ve got a 64Gb card holding a Rpi OS and only a 1K python script!)

And Arduino’s are even worse … they are all over the place.
Those are probably 100+
(ESP32, 8266, Nano’s, Mega, M5Stack and alikes)

I know i have many temporary projects, but I keep most things organized in my projects containers.

One of the rows with Ikea containers, a few for bigger projects and now i’m using the plastic boxes you get when you order chinese or thai.

Obfuscating color logo in bash

Something from my old archive.

Colleage’s used to like the method.

source with color escape code applied
32=green 31=red and 97=white

echo  -e "\e[0;32m '.::///+:/-.        --///+//-:'' " 
echo  -e "\e[0;32m  '+oooooooooooo:   '+oooooooooooo: " 
echo  -e "\e[0;32m   /oooo++//ooooo:  ooooo+//+ooooo. " 
echo  -e "\e[0;32m   '+ooooooo:-:oo-  +o+::/ooooooo: " 
echo  -e "\e[0;32m    ':oooooooo+''    '.oooooooo+- " 
echo  -e "\e[0;32m      ':++ooo/.        :+ooo+/.' " 
echo  -e "\e[0;31m        ...'  '.----.' ''.. " 
echo  -e "\e[0;31m      .::::-'':::::::::.'-:::-'            \e[0;97m    www.henriaanstoot.nl" 
echo  -e "\e[0;31m     -:::-'   .:::::::-'  '-:::-           \e[0;97m    Test logo"
echo  -e "\e[0;31m    '::.  '.--.'  '' '.---.''.::' " 
echo  -e "\e[0;31m        .::::::::'  -::::::::' ' " 
echo  -e "\e[0;31m  .::' .:::::::::- '::::::::::''::. " 
echo  -e "\e[0;31m -:::' ::::::::::.  ::::::::::.':::- " 
echo  -e "\e[0;31m ::::  -::::::::.   '-::::::::  :::: " 
echo  -e "\e[0;31m -::-   .-:::-.''....''.-::-.   -::- " 
echo  -e "\e[0;31m  .. ''       .::::::::.     '..'.. " 
echo  -e "\e[0;31m    -:::-'   -::::::::::'  .:::::' " 
echo  -e "\e[0;31m    :::::::' -::::::::::' :::::::. " 
echo  -e "\e[0;31m    .:::::::  -::::::::. :::::::: " 
echo  -e "\e[0;31m     '-:::::'   ..--.'   ::::::. " 
echo  -e "\e[0;31m       '...'  '...--..'  '...' " 
echo  -e "\e[0;31m             .:::::::::: " 
echo  -e "\e[0;31m              '.-::::-'  " 

Obfuscate the logo to a file (1 time only)

cat source | base64 - -w0 1> ~/bin/logo.ob

Writes file (safe to copy paste/transfer) with:
ZWNobyAgLWUgIlxlWzA7MzJtICcuOjovLy8rOi8tLiAgICAgICAgLS0vLy8rLy8tOicnICIgCmVjaG8gIC1lICJcZVswOzMybSAgJytvb29vb29vb29vb286ICAgJytvb29vb29vb29vb286ICIgCmVjaG8gIC1lICJcZVswOzMybSAgIC9vb29vKysvL29vb29vOiAgb29vb28rLy8rb29vb28uICIgCmVjaG8gIC1lICJcZVswOzMybSAgICcrb29vb29vbzotOm9vLSAgK28rOjovb29v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OicgLTo6Ojo6Ojo6OjonIDo6Ojo6OjouICIgCmVjaG8gIC1lICJcZVswOzMxbSAgICAuOjo6Ojo6OiAgLTo6Ojo6Ojo6LiA6Ojo6Ojo6OiAiIAplY2hvICAtZSAiXGVbMDszMW0gICAgICctOjo6OjonICAgLi4tLS4nICAgOjo6Ojo6LiAiIAplY2hvICAtZSAiXGVbMDszMW0gICAgICAgJy4uLicgICcuLi4tLS4uJyAgJy4uLicgIiAKZWNobyAgLWUgIlxlWzA7MzFtICAgICAgICAgICAgIC46Ojo6Ojo6Ojo6ICIgCmVjaG8gIC1lICJcZVswOzMxbSAgICAgICAgICAgICAgJy4tOjo6Oi0nICAiIAo=

Create an alias with the logo

alias logo=$(cat ~/bin/logo.ob | base64 -d )

executing logo will produce the logo

Bookstack – A new (for me) way do document stuff.

I’m always looking for new better ways to document stuff.

I’ve tested a lot, some things i’ve used personally for years.
Same or other tools I implemented also at Customers.

Everybody starts off with text files.
Then I used Hyper when I was using MS-Dos.

Many wiki’s came, and went.

  • Twiki – Work
  • Foswiki – Work, Highland Valley Pipeband, personal
  • Docuwiki
  • MediaWiki (pipetunesearch) and more

I tried to document in wordpress, but that’s not suitable.

I still got stuff in Nextcloud, Google Drive and Joplin. These are only for fast access to unstructured information.

I don’t like Wysiwig that much, also I like to use OpenSource and Open standards.

So discovering a knowledge base engine like Bookstack is always nice.

I installed a docker version in my Lab to experiment with.

So far so good.
Markup Language, and export to PDF, Markup, Html and Contained webfile.

I’ve changed the docker-compose.yml because I’ve got my dedicated Database server for that:

---
version: "2"
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://bookstack.henriaanstoot.nl:6875/
      - DB_HOST=IPDATABASESERVER
      - DB_PORT=3306
      - DB_USER=bookstackuser
      - DB_PASS=bookstackpassword
      - DB_DATABASE=bookstackapp
    volumes:
      - ./bookstack_app_data:/config
    ports:
      - 6875:80
    restart: unless-stopped
    volumes:
      - ./bookstack_db_data:/config
    restart: unless-stopped

While playing with this I forgot my credentials .. duh

Using portainer terminal access to the docker to add a new admin user

OpenPLC editor with Raspberry and Arduino

Here I’m going to post my tests with OpenPLC.

UPDATE 20231012 202301015

It’s a long time i’ve made a PLC ladder, but lets see how and what this integration brings me.

OpenPLC interface on a Raspberry, I could not start a program on RPI 5!
But it compiled correctly. See below rpi3
Schematic with a led and two buttons (and one floating in the middel, which i forgot to remove)
Working example ( wemos and display are from another project those are not connected )

UPDATE 20231015 – Raspberry 3 with OpenPLC

GND to leds and buttons
GPIO2 (pin 3) to a button
GPIO3 (pin 5) to another button
GPIO14 (pin 8) to the led

Now OpenPLC works correct (RPI3)

https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3
./install.sh rpi 

## Warning .. takes a really long time

Wiringpi is deprecated
But can be installed using the last git repo

git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build

I’ve got a Raspberry 5, lets start experimenting

So many things to try .. and probably buy.
I’m lucky to have this already, official it’s not even out yet.

Specification

  • Processor : Broadcom BCM2712 2.4GHz quad-core 64-bit Arm Cortex-A76 CPU, B with cryptography extensions, 512KB per-core L2 caches, and a 2MB shared L3 cache

Features:

  • VideoCore VII GPU, supporting OpenGL ES 3.1, Vulkan 1.2
  • Dual 4Kp60 HDMI® display output with HDR support
  • 4Kp60 HEVC decoder
  • LPDDR4X-4267 SDRAM
    (4GB and 8GB SKUs available at launch)
  • Dual-band 802.11ac Wi-Fi
  • Bluetooth 5.0 / Bluetooth Low Energy (BLE)
  • microSD card slot, with support for high-speed SDR104 mode
  • 2 × USB 3.0 ports, supporting simultaneous 5Gbps operation
  • 2 × USB 2.0 ports
  • Gigabit Ethernet, with PoE+ support
    (requires separate PoE+ HAT)
  • 2 × 4-lane MIPI camera/display transceivers
  • PCIe 2.0 x1 interface for fast peripherals
    (requires separate M.2 HAT or other adapter)
  • 5V/5A DC power via USB-C, with Power Delivery support
  • Raspberry Pi standard 40-pin header
  • Real-time clock (RTC), powered from external battery
  • Power button

Some things come to mind to test:

  • Kubernetes
  • Dual Camera OpenCV – depthmap and more

You really want to use a case with an active blower to cool the rpi.

Measurements without cooling:

  • Power off – part most hot 28 degrees
  • Power on – Idle, around 40 degrees
  • Power on – Playing 4k for 5 minutes – 60+ degrees

Flir info https://www.henriaanstoot.nl/2023/06/05/checking-faulty-chips-hardware/

I didn’t have a image for Raspberry OS 5 at first, so I took a rpi 4 version and first replaced files in /boot
(Device Tree blob files)

Now at least i could boot into an OS.

Later I got a link to the Alpha boot images, this greatly improved usability and speed 🙂

Youtube 4k movie on a 2560×1080 monitor

Made a little overview website:

https://media.henriaanstoot.nl/websites/rpi5/index.html

Some old and some new demo stuff

A dentro (Combination of demo and intro.) from 1995

It using only background colors behind existing text to display the dentro text. There is (somewhere) a version with animations.

New work:

Booting from floppy, showing a flash screen in mode 13h.
Starting a trackloader, which loads a raw adlib file and plays it.
All sectors written to floppy using my new sector writer.
WOOT .. music at boot time!

Sector writer

use16
org 0100h
; 0 0 1
; bootblock with flashcode
	mov cl,1  ; start
	mov al,1  ; # sectors
	mov dh,0  ; head
	mov bx,bootblock
	call wrtsector

; flash image
	mov cl,8
	mov al,4
	mov dh,0
	mov bx,gfx
	call wrtsector

; Music loader
	mov cl,7  ; start
	mov al,1  ; # sectors
	mov dh,0  ; head
	mov bx,nextpart
	call wrtsector

; Music raw
	mov cl,13  ; start
	mov al,4  ; # sectors
	mov dh,0  ; head
	mov bx,musicraw
	call wrtsector

	jmp do_exit

printerror:
	push cs		; make ds same as cs
	pop ds
	MOV DX,TxtErr1	; error
	MOV AH,09h
	INT 21h
	mov ax,4c00h
	int 21h
do_exit:
	mov ax,4c00h
	int 21h
wrtsector:
;       On entry:      AH         03h
;                      AL         Number of sectors to write
;                      CH         Cylinder number (10-bit value; upper 2 bits
;                                 in CL)
;                      CL         Starting sector number
;                      DH         Head number
;                      DL         Drive number
;                      ES:BX      Address of memory buffer
; 
;       Returns:       AH         Status of operation (See Service 01h)
;                      AL         Number of sectors written
;                      CF         Set if error, else cleared

	cld
	mov ah, 3h    ; int13h function 2
	mov ch, 0     ; from cylinder number 0
	mov dl,0
	push cs 
	pop es
	int 13h
	jc printerror
ret

TxtErr1:	 DB "Error!",7,10,13,"$"

bootblock:
	file 'flash_b.bin'
gfx:
	file 'flashgfx.raw'
nextpart:
	file 'nextpart.bin'
musicraw:
	file 'LVLINTRO.RAW' 

I wanted to know how a floppy differs from a floppy.
So i wrote below code to fill each sector on a floppy disk or image with information at the start of each sector.
(Head, Cylinder and Sector)

empty.bin was made using
dd if=/dev/zero of=empty.bin count=1 bs=512

use16
org 0100h

	mov ch,0  ; cyl
	mov cl,1  ; sector
	mov dh,0  ; head
nextsector:
	mov bx,empty
	mov [empty],dh
	mov [empty+1],ch
	mov [empty+2],cl
	push cx
	push ax
	push dx
	call printer
	call wrtsector
	pop dx
	pop ax
	pop ax
	inc cl
	cmp cl,19
	jnz nextsector
	mov cl,1
	inc ch
	cmp ch,79
	jnz nextsector
; other side
	mov dh,1
	mov ch,0
	mov cl,1

nextsector1:
	mov bx,empty
	mov [empty],dh
	mov [empty+1],ch
	mov [empty+2],cl
	push cx
	push ax
	push dx
	call wrtsector
	pop dx
	pop ax
	pop ax
	inc cl
	cmp cl,19
	jnz nextsector1
	mov cl,1
	inc ch
	cmp ch,79
	jnz nextsector1


	jmp do_exit

printerror:
	push cs		; make ds same as cs
	pop ds
	MOV AX,3	; default text mode 3
	INT 10h
	MOV DX,TxtErr1	; error
	MOV AH,09h
	INT 21h
	mov ax,4c00h
	int 21h


do_exit:
	mov ax,3
	int 10h
	mov ax,4c00h
	int 21h

printer:
	push cx
	push dx
	mov dl,dh
	mov ah, 02h
	add dl, 30h
	int 21h
	mov dl,ch
	add dl, 30h
	int 21h
	mov dl,cl 
	add dl, 30h
	int 21h
	mov dx,13
  mov ah,2
  int 21h  
  mov dx,10
  mov ah,2
  int 21h
	pop dx
	pop cx
	ret

wrtsector:
;       On entry:      AH         03h
;                      AL         Number of sectors to write
;                      CH         Cylinder number (10-bit value; upper 2 bits
;                                 in CL)
;                      CL         Starting sector number
;                      DH         Head number
;                      DL         Drive number
;                      ES:BX      Address of memory buffer
; 
;       Returns:       AH         Status of operation (See Service 01h)
;                      AL         Number of sectors written
;                      CF         Set if error, else cleared
;

	cld
	mov ah, 3h    ; int13h function 2
	mov al,1
	mov dl,0
	push cs 
	pop es
	int 13h
	jc printerror
ret

TxtErr1:	 DB "Error!",7,10,13,"$"

empty:
	file 'empty.bin'

Viewing the floppy image with ghex

Offset 7000 = Head 1, Cylinder 1 and sector 3

When doing
times 512 – ($-$$) db 0
to fill binaries to 512 bytes, you could cat the sectors to a disk/file with this knowledge.

80×86 boot demo generic work plus code optimalisation and tricks

Writing tools and effects for my new boot demo.

  • Started a generic sector read/writer
  • Some effects
  • A sin/cos data writer to include into your source
  • Working on a library of functions (sector loaders, color palette, vert/hor retrace functions)
  • Laying out a memory map for the demo

Below the output of the sin/cos generator ( see used in video below )
(It also shows a visual plot of the function)

Source code python script

# importing the required module
import matplotlib.pyplot as plt
import numpy as np
import math

# Change these
numberofdatapoints = 360
maxamp = 180
howmuchfromwave = 0.5
numberofharmonies = 1
# Number of harmonies are sin/cos additions in the calculation line below

# not here
step = 360/numberofdatapoints*howmuchfromwave
offset = maxamp
maxamp = maxamp / numberofharmonies
offset = 0


x = [ ]

for xv in range(numberofdatapoints):
    xvstep=xv * step
# Calculation line
#    datapoint=np.sin(math.radians(xvstep))
# Double harmony example
    datapoint=np.sin(math.radians(xvstep)) + (np.sin(math.radians(xvstep*3))/2)

    datapoint=datapoint * maxamp
    datapoint=datapoint + offset
    x.append(int(datapoint))

print("    db ", end="")
print(*x, sep = ",") 
  
# plotting the points 
plt.plot(x)
  
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
  
# giving a title to my graph
plt.title('Example')
  
# function to show the plot
plt.show()

Minimalistic very fast boot loader flash screen effect

Graffiti bouncher test (probably ends up bounching a 320×400 image)
This one uses the generated sintab (Using the python script above)

Test code for a text scroller

Code optimalisation/tricks

clear a (double) register?
xor ax,ax
is faster than
mov ax,0h

Want to make ds pointer same as cs?
Instead of
mov ax,cs
mov ds,ax
use
push cs
pop ds

self modifying code
mostly we just move data around, but you also can change the runtime code (instructions)

  • a – increment ax on line 103h
  • b – another part of the code/maybe in a interrupt
    10Fh load al with 48h (thats the opcode for decrement (see c)
    111h place the opcode in address 103h, which had 40h ..
    Now we changed the code to decrement next time

Speedcode

Populair on the C64 where resources are even more limited, you could use speedcode.
Most of the speedcode you generate, due to its repeating lines.
When looking at clock cycles you can save some extra cycles, by using a little more memory but saving on “expensive” loops.

Simple example

Left a funtion with a loop, right is the same but all instuctions sequencial

Left 15 bytes but 284 cycles

Right 39 bytes but only 102 cycles!

4
4
; below part 9 times
9
3
4
16 or 4
= 284 cycles

Speedcode
4
2 ; xor is faster
9
3 ; even 2 when you can use BX pair!
9
3
9
3
9
3
9
3
9
3
9
3
9
3
9
= 111 cycles (or 102 BX pair)

Moving memory blocks (No DMA)

;DS:(E)SI to address ES:(E)DI
    push cs          ; example to set es to code segment
    pop es
    mov si,1000      ; offset pointer source
    xor di,di        ; destination offset
    mov cx,320*100   ; number of transfers (See below words)
    mov ax,0a000h    ; Destination
    mov es,ax        ; destination segment 
    cld              ; Clear direction flag set SI and DI to auto-increment
    rep movsw        ; repeat mov words! until number of transfers is 0
;  

Short binary > bcd > dec (ascii) convert for numbers (0-99)

mov ax,01ch ; = 28 
mov bx,0ah ; = 10
div bl ; divide BL by AX
       ; AX = 0802 ; Remainder/Divider
xchg ah,al ; change around (dont use if you want to keep little endian)
add ax,3030h ; offset to ascii 30=0 31=1
             ; ax ends up with 3238 .. 28 

"If something is worth doing, it's worth overdoing."