Allgemein

ESP32S3 maximum SPI speed

The ESP32-S3 supports the following maximum speeds on the SPI peripheral:

  • As SPI master: 80 MHz
  • As SPI slave: 60 MHz

Note that the same clock speeds work for dual and quad SPI

Source: ESP32S3 datasheet,

Posted by Uli Köhler in Allgemein

How to install Syncthing on Ubuntu

sudo curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg   
echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list 
sudo apt -y install syncthing

 

Posted by Uli Köhler in Allgemein

How to read length-prefixed binary message from Serial using Arduino

The following function allows you to read a binary message, prefixed by a single length byte, from Serial:

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
}

void HandleMessage(String msg) {
    // TODO: Your code to handle the message goes here.
    // See https://techoverflow.net/2022/11/15/how-to-print-string-as-sequence-of-hex-bytes-in-arduino/
    // for an example of how to print the message as a sequence of hex bytes.
}

void ReadMessageFromSerial() {
    // Wait until the length byte is available on Serial
    while (Serial.available() == 0);

    // Read the length of the message
    int length = Serial.read();

    // Read the rest of the message
    String message = "";
    for (int i = 0; i < length; i++) {
      while (Serial.available() == 0);
      message += char(Serial.read());
    }

    // Handle the message
    HandleMessage(message);
}

void loop() {
    ReadMessageFromSerial();
}

 

 

Posted by Uli Köhler in Allgemein, Arduino, Electronics, Embedded

How to fix InvenTree remote_image: Downloading images from remote URL is not enabled

Problem:

While trying to create an InvenTree object using a remote_image URL, you see an error message like

requests.exceptions.HTTPError: {'detail': 'Error occurred during API request', 'url': 'https://inventree-test.mydomain.com/api/company/', 'method': 'POST', 'status_code': 400, 'body': '{"remote_image":["Downloading images from remote URL is not enabled"]}', 'headers': {'AUTHORIZATION': 'Token 6daae3817756e9c1a3603b14d9582e61f50db388'}, 'params': {'format': 'json'}, 'data': {'name': 'DigiKey', 'website': 'https://www.digikey.de/', 'remote_image': 'https://logodix.com/logo/1667872.jpg', 'description': '', 'is_manufacturer': False, 'is_supplier': True, 'is_customer': False, 'currency': 'EUR'}}

Solution:

Open the InvenTree webinterface, open Server Configuration on the left

and enable Download from URL.

The setting will be effective immediately. There is no need to click any Apply button or restart the server.

 

Posted by Uli Köhler in Allgemein

How to fix zincati not updating CoreOS: rpm-ostree deploy failed: error: Packages not found: …

Problem:

My zincati service – the service that automatically updates CoreOS could not update CoreOS due to the following logs (view with journalctl -xfu zincati.service):

[ERROR zincati::update_agent::actor] failed to stage deployment: rpm-ostree deploy failed:
    error: Packages not found: magic-wormhole

Solution:

The solution typically involves uninstalling the package – in this case magic-wormhole using

sudo rpm-ostree uninstall magic-wormhole

Note that this might uninstall a service that is required for your infrastructure, and it will delete files associated with the package in the process of uninstalling it. You should make a backup of valuable data in any case.

Posted by Uli Köhler in Allgemein, CoreOS

How to prevent redmine always logging out

In Redmine, by default you are always logged out after a very short period of time.

You can fix this by logging in as an administrator and opening Administration -> Settings -> Authentication and setting Autologin to 365 days. You can also choose a lower value if you want sessions to automatically expire sooner.

Posted by Uli Köhler in Allgemein

Python curses keycode to key mapping

The following mapping is helpful in order to determine the mapping of a keycode to the corresponding curses.KEY_... constant.

I extracted this mapping by using

import curses
print(curses.__dict__)

Curses key mapping

'A_ATTRIBUTES': 4294967040,
'A_NORMAL': 0,
'A_STANDOUT': 65536,
'A_UNDERLINE': 131072,
'A_REVERSE': 262144,
'A_BLINK': 524288,
'A_DIM': 1048576,
'A_BOLD': 2097152,
'A_ALTCHARSET': 4194304,
'A_INVIS': 8388608,
'A_PROTECT': 16777216,
'A_CHARTEXT': 255,
'A_COLOR': 65280,
'A_HORIZONTAL': 33554432,
'A_LEFT': 67108864,
'A_LOW': 134217728,
'A_RIGHT': 268435456,
'A_TOP': 536870912,
'A_VERTICAL': 1073741824,
'A_ITALIC': 2147483648,
'COLOR_BLACK': 0,
'COLOR_RED': 1,
'COLOR_GREEN': 2,
'COLOR_YELLOW': 3,
'COLOR_BLUE': 4,
'COLOR_MAGENTA': 5,
'COLOR_CYAN': 6,
'COLOR_WHITE': 7,
'BUTTON1_PRESSED': 2,
'BUTTON1_RELEASED': 1,
'BUTTON1_CLICKED': 4,
'BUTTON1_DOUBLE_CLICKED': 8,
'BUTTON1_TRIPLE_CLICKED': 16,
'BUTTON2_PRESSED': 64,
'BUTTON2_RELEASED': 32,
'BUTTON2_CLICKED': 128,
'BUTTON2_DOUBLE_CLICKED': 256,
'BUTTON2_TRIPLE_CLICKED': 512,
'BUTTON3_PRESSED': 2048,
'BUTTON3_RELEASED': 1024,
'BUTTON3_CLICKED': 4096,
'BUTTON3_DOUBLE_CLICKED': 8192,
'BUTTON3_TRIPLE_CLICKED': 16384,
'BUTTON4_PRESSED': 65536,
'BUTTON4_RELEASED': 32768,
'BUTTON4_CLICKED': 131072,
'BUTTON4_DOUBLE_CLICKED': 262144,
'BUTTON4_TRIPLE_CLICKED': 524288,
'BUTTON5_PRESSED': 2097152,
'BUTTON5_RELEASED': 1048576,
'BUTTON5_CLICKED': 4194304,
'BUTTON5_DOUBLE_CLICKED': 8388608,
'BUTTON5_TRIPLE_CLICKED': 16777216,
'BUTTON_SHIFT': 67108864,
'BUTTON_CTRL': 33554432,
'BUTTON_ALT': 134217728,
'ALL_MOUSE_EVENTS': 268435455,
'REPORT_MOUSE_POSITION': 268435456,
'KEY_BREAK': 257,
'KEY_DOWN': 258,
'KEY_UP': 259,
'KEY_LEFT': 260,
'KEY_RIGHT': 261,
'KEY_HOME': 262,
'KEY_BACKSPACE': 263,
'KEY_F0': 264,
'KEY_F1': 265,
'KEY_F2': 266,
'KEY_F3': 267,
'KEY_F4': 268,
'KEY_F5': 269,
'KEY_F6': 270,
'KEY_F7': 271,
'KEY_F8': 272,
'KEY_F9': 273,
'KEY_F10': 274,
'KEY_F11': 275,
'KEY_F12': 276,
'KEY_F13': 277,
'KEY_F14': 278,
'KEY_F15': 279,
'KEY_F16': 280,
'KEY_F17': 281,
'KEY_F18': 282,
'KEY_F19': 283,
'KEY_F20': 284,
'KEY_F21': 285,
'KEY_F22': 286,
'KEY_F23': 287,
'KEY_F24': 288,
'KEY_F25': 289,
'KEY_F26': 290,
'KEY_F27': 291,
'KEY_F28': 292,
'KEY_F29': 293,
'KEY_F30': 294,
'KEY_F31': 295,
'KEY_F32': 296,
'KEY_F33': 297,
'KEY_F34': 298,
'KEY_F35': 299,
'KEY_F36': 300,
'KEY_F37': 301,
'KEY_F38': 302,
'KEY_F39': 303,
'KEY_F40': 304,
'KEY_F41': 305,
'KEY_F42': 306,
'KEY_F43': 307,
'KEY_F44': 308,
'KEY_F45': 309,
'KEY_F46': 310,
'KEY_F47': 311,
'KEY_F48': 312,
'KEY_F49': 313,
'KEY_F50': 314,
'KEY_F51': 315,
'KEY_F52': 316,
'KEY_F53': 317,
'KEY_F54': 318,
'KEY_F55': 319,
'KEY_F56': 320,
'KEY_F57': 321,
'KEY_F58': 322,
'KEY_F59': 323,
'KEY_F60': 324,
'KEY_F61': 325,
'KEY_F62': 326,
'KEY_F63': 327,
'KEY_DL': 328,
'KEY_IL': 329,
'KEY_DC': 330,
'KEY_IC': 331,
'KEY_EIC': 332,
'KEY_CLEAR': 333,
'KEY_EOS': 334,
'KEY_EOL': 335,
'KEY_SF': 336,
'KEY_SR': 337,
'KEY_NPAGE': 338,
'KEY_PPAGE': 339,
'KEY_STAB': 340,
'KEY_CTAB': 341,
'KEY_CATAB': 342,
'KEY_ENTER': 343,
'KEY_SRESET': 344,
'KEY_RESET': 345,
'KEY_PRINT': 346,
'KEY_LL': 347,
'KEY_A1': 348,
'KEY_A3': 349,
'KEY_B2': 350,
'KEY_C1': 351,
'KEY_C3': 352,
'KEY_BTAB': 353,
'KEY_BEG': 354,
'KEY_CANCEL': 355,
'KEY_CLOSE': 356,
'KEY_COMMAND': 357,
'KEY_COPY': 358,
'KEY_CREATE': 359,
'KEY_END': 360,
'KEY_EXIT': 361,
'KEY_FIND': 362,
'KEY_HELP': 363,
'KEY_MARK': 364,
'KEY_MESSAGE': 365,
'KEY_MOVE': 366,
'KEY_NEXT': 367,
'KEY_OPEN': 368,
'KEY_OPTIONS': 369,
'KEY_PREVIOUS': 370,
'KEY_REDO': 371,
'KEY_REFERENCE': 372,
'KEY_REFRESH': 373,
'KEY_REPLACE': 374,
'KEY_RESTART': 375,
'KEY_RESUME': 376,
'KEY_SAVE': 377,
'KEY_SBEG': 378,
'KEY_SCANCEL': 379,
'KEY_SCOMMAND': 380,
'KEY_SCOPY': 381,
'KEY_SCREATE': 382,
'KEY_SDC': 383,
'KEY_SDL': 384,
'KEY_SELECT': 385,
'KEY_SEND': 386,
'KEY_SEOL': 387,
'KEY_SEXIT': 388,
'KEY_SFIND': 389,
'KEY_SHELP': 390,
'KEY_SHOME': 391,
'KEY_SIC': 392,
'KEY_SLEFT': 393,
'KEY_SMESSAGE': 394,
'KEY_SMOVE': 395,
'KEY_SNEXT': 396,
'KEY_SOPTIONS': 397,
'KEY_SPREVIOUS': 398,
'KEY_SPRINT': 399,
'KEY_SREDO': 400,
'KEY_SREPLACE': 401,
'KEY_SRIGHT': 402,
'KEY_SRSUME': 403,
'KEY_SSAVE': 404,
'KEY_SSUSPEND': 405,
'KEY_SUNDO': 406,
'KEY_SUSPEND': 407,
'KEY_UNDO': 408,
'KEY_MOUSE': 409,
'KEY_RESIZE': 410,
'KEY_MIN': 257,
'KEY_MAX': 511}

 

Posted by Uli Köhler in Allgemein

How to setup ZeroTier One & ZTNCUI using docker-compose in just 2 minutes

First, create a directory for the ZeroTier One / ZTNCUI files to reside in, e.g.:

mkdir /opt/zerotier-mydomain

Now, create docker-compose.yml in that directory

version: '3.4'

services:
  ztncui:
    container_name: ztncui
    restart: always
    image: keynetworks/ztncui
    ports:
      - 9993:9993/udp
      - 3180:3180
      - 3443:3443
    volumes:
      - ./etc:/opt/key-networks/ztncui/etc
      - ./zt1:/var/lib/zerotier-one   

After that, create .env in said directory containing some info about your node:

NODE_ENV=production
HTTPS_PORT=3443
MYDOMAIN=zerotier.mydomain.com

Now we’ll use the script from Create a systemd service for your docker-compose project in 10 seconds in order to create a systemd service to automatically run the service:

curl -fsSL https://techoverflow.net/scripts/create-docker-compose-service.sh | sudo bash /dev/stdin

This script will also automatically start the service (i.e. docker-compose up). ZTNCUI (which comes packaged with ZeroTier One) will generate a temporary admin password automatically, which we can extract from the log using this simple command:

docker-compose exec ztncui cat /var/log/docker-ztncui.log | grep "Current Password" | tail -n 1

Example output:

2022/08/19 14:32:37 Current Password: esh0Eengai

Be sure to open the ports 9993/udp, 3180 and (unless you are using a reverse proxy) 3443 in your firewall, for example:

sudo ufw allow 9993/udp
sudo ufw allow 3180
sudo ufw allow 3443

Now we can open https://[IP]:3443 to open the webinterface (ignore the certificate validation error). You can also setup a reverse proxy at this stage, which we’ll cover in future posts.

You should see a page like this one:

Click Login at the top right:

Enter admin as username and the password we extracted above (esh0Eengai in this example).

You will be asked to change your password, and after that you can create ZeroTier networks.

Posted by Uli Köhler in Allgemein, Networking, ZeroTier

Where to find ESP32S2 bare chip reference schematic?

If you are not using the ESP32S2 as a module but as a chip, you need a reference schematic to check if you have errors in a schematic.

A good place to start is by checking out the schematic of the ESP32S2-MINI, which you can find on page 19 & 20 of the module datasheet.

Posted by Uli Köhler in Allgemein

How to import mbox file in Thunderbird

  1. Install ImportExportTools NG
  2. Right click on Local folders and in the context menu, in the ImportExportTools NG menu, click on Import mbox file
Posted by Uli Köhler in Allgemein

How to add filename extension to every file in directory

This shell script will rename every file in a directory recursively and add a .docx extension to its filename (even if there is already an extension), preventing overwriting existing files of the same name via mv --backup=numbered:

find . -type f -exec mv -v --backup=numbered "{}" "{}.docx" \;

 

Posted by Uli Köhler in Allgemein

How to configure SMTP server on MikroTik RouterOS

Use the following command in order to configure SMTP settings for a MikroTik router:

/tool e-mail set address=smtp.mydomain.com from="MikroTik <[email protected]>" tls=starttls [email protected] password=uFoome0Noh

Alternatively, you can configure these settings directly on the web interface at WebFig => Tools => EMail.

Posted by Uli Köhler in Allgemein

SSH to LXC container with Pubkey

ssh [user]@[my-container-address]

Problem

[user]@[my-container-address] Permission denied (publickey). 

Solution

Change the sshd_config

vim /etc/ssh/sshd_config 

from this

# PubkeyAuthentication no

to this

PubkeyAuthentication yes

.
Do not forget to add your pubkey to your authorized keys.

mkdir /home/[myuser]/.ssh & vim /home/[myuser]/.ssh/authorized_keys
Posted by Joshua Simon in Allgemein

LXC container share host network

Goal

You want to share the host network with all your lxc containers.

Check network settings of your containers by typing:

lxc network list

If it displays something like that:

+---------+----------+---------+-------------+---------+
|  NAME   |   TYPE   | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| docker0 | bridge   | NO      |             | 0       |
+---------+----------+---------+-------------+---------+
| eth0    | physical | NO      |             | 0       |
+---------+----------+---------+-------------+---------+

Solution

Set up your container with the default settings of LXD, creating a network for all containers attached to the newly created lxdbr0 adapter on the host system with

lxd init

and accept the defaults:

Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:                                                             

and have your containers already connected to the lxdbr0 bridge on your host.
You might now see something like this.

+---------+----------+---------+-------------+---------+
|  NAME   |   TYPE   | MANAGED | DESCRIPTION | USED BY |
+---------+----------+---------+-------------+---------+
| docker0 | bridge   | NO      |             | 0       |
+---------+----------+---------+-------------+---------+
| eth0    | physical | NO      |             | 0       |
+---------+----------+---------+-------------+---------+
| lxdbr0  | bridge   | YES     |             | 5       |
+---------+----------+---------+-------------+---------+

Now try it

lxc exec [mycontainer] /bin/bash                                               
curl https://techoverflow.net
Posted by Joshua Simon in Allgemein

OctoPrint: Pause/Resume G-Code to move nozzle away

This pause / resume G-Code for OctoPrint (will likely also work with other platforms, but we only tested using OctoPrint) will move the nozzle 100mm away from the part being printed during the pause and (after clicking resume) will move to the original position i.e. it will continue the print normally.

This is useful to prevent heat damage to the part and also allow you to clean the nozzle during pause

Pause G-Code:

G91 ; Set relative positioning mode
G0Z100 ; Move Z up 100mm to assist nozzle cleaning
G90 ; Set absolute positioning mode

Resume G-Code:

G91 ; Set relative positioning mode
G0Z-100 ; Move Z down 100mm to return to print position
G90 ; Set absolute positioning mode
Posted by Uli Köhler in Allgemein

Excel: How to replace formula cell by its value

TL;DR: Press F2, then F9 to replace a cell by its value.

Click on the formula cell (click once, no need to click twice):

Now press the F2 key to edit the cell:

Now press the F9 key to replace the cell by its value:

Posted by Uli Köhler in Allgemein

How to fix MANIFEST.in graft having no effect on Windows

Problem:

In your MANIFEST.in, you have a line like

graft src/

but when you run

python setup.py sdist

some file in src is not included in the archive

Solution:

This is due to the slash at the end of src/! The slash works fine on Linux, but on Windows, backslashes are used to separate directory names. You can just remove the slash after src, it doesn’t serve any purpose on Windows or Linux:

graft src

After that, retry and you should see your file being included in the sdist archive.

Posted by Uli Köhler in Allgemein

Insurgency: Which RCON client should you use?

For most users, the in-game console is the best RCON client to use since you don’t need to install separate software and it has auto-complete features. See Insurgency: How to connect to RCON using the in-game console for a guide how to connect to RCON using said console.

Posted by Uli Köhler in Allgemein

Insurgency: How to connect to RCON using the in-game console

First, open the console using the configured hotkey (default: The key directly left of the 1 key). If that doesn’t work, remap the key in the settings.

Then enter

rcon_password "mypassword"

to set the password to connect to the RCON server.

Now you can use admin commands in the format

rcon <command>

 

Posted by Uli Köhler in Allgemein