brain4free

Benutze dein Gehirn oder wir nehmen es dir wieder weg!

So ist der Homepagetitel zu verstehen. Wie ihr unter Ideen lesen könnt, wäre mit ungenutztem Hirnpotenzial durchaus ein sehr lukratives Geschäft zu machen. Die nötige Ressource wäre ja genügend vorhanden. Bis wir die Techniken dazu besitzen beschränke ich mich hier auf eine private Homepage mit meinen 3D Photos und vor allem meinen Projekten die euch hoffentlich nützlich sind.

brain4free Blog

Scanner upcycling - Leuchttisch

Dies ist eine kurze Beschreibung eines alten Kleinprojekts von mir, kurz und schmerzlos damit es anderen nützlich sei.

Manchmal ist man an einem Projekt dran und organisiert Baumaterial bzw. recycled ein defektes Gerät und nebenbei kommt einem etwas in die Finger, dass dann schnell zum separaten Projekt wird. So ist es hier geschehen, als ich einen Scanner umgebaut habe zu einem knapp funktionierendem Laser Cutter. Beim Scanner war auch eine Durchlichteinheit dabei um Negative oder Dias zu scannen.

Diese Durchlichteinheit wurde kurzerhand umgebaut, so dass sie als Leuchttisch benutzt werden kann. Eignet sich gut zum Sortieren von Dias oder Negativen könnte aber auch zum betrachten von Röntgenbildern benutzt werden.

2020/06/04 08:40 · dogbert

Script to reconnect Bluetooth device in Linux

Example of a radio with iPod dock connector, now with Bluetooth receiver

Today I wasted several hours to write a small script that helps you to use a Bluetooth audio device with several Linux computers.

Problem: Several computers, one Bluetooth receiver

Our radio in the kitchen got upcycled with a Bluetooth receiver that fits into the obsolete 30 pin iPod dock connector. This receivers are cheap and easy and help lots of devices to get an interface to modern equipment.

Unfortunately our receiver can only handle one pairing, which means that every-time my girlfriend used the radio before me, I had to open the KDE bluedevil menu to delete, search and newly connect the device before I could listen to music in the kitchen (and vice versa). Time consuming and annoying.

Linux and Bluetooth

Bluetooth is a very common standard to connect phones and computers to audio devices like headphones and loudspeakers. But for Linux users Bluetooth is not the easiest thing and it's known to be not very well documented. OK, the Bluetooth standard changes more often than other technologies and the Linux Bluetooth tools improved as well, but also the tool names changed more then once and there was also the chance from pure ALSA to PulseAudio…

None of that helped me today to find a quick, simple solution for my small problem. I found numerous old guides for long gone tools and interfaces and the current Linux Bluetooth tools are not built to be run from scripts?!

Solution

OK, after many searches, try and errors and climbing up from the legacy tools to the more recent ones I managed to have a script that:

  • Deletes a connection to previously used Bluetooth device
  • Scans for Bluetooth devices
  • Creates a new connection incl. pairing to the deleted device.

connect-i-link.sh

#!/bin/bash

# remove old connection 
echo -e 'power on\ndisconnect EB:06:BF:0A:13:6F\nremove EB:06:BF:0A:13:6F\nquit' | bluetoothctl

# scan bluetooth devices for 20 s
timeout -k 20 15 bt-adapter --discover

# create a new pairing and connection
bt-device --connect EB:06:BF:0A:13:6F

# the command above does not connect audio, so do again a connection with bluetoothctl
echo -e 'trust EB:06:BF:0A:13:6F\nconnect EB:06:BF:0A:13:6F\ninfo EB:06:BF:0A:13:6F\nquit' | bluetoothctl

You have to replace the MAC address (EB:06:BF:0A:13:6F) in the script with the address of your device. You find this address in bluedevil or with bluetoothctl (command: scan on)

To get Bluetooth audio working in recent Linux distributions (> 2018) you have to install:

apt install bluez bluez-tools bluez-firmware pulseaudio-module-bluetooth
2020/04/15 23:44 · dogbert

Insel Mainau

Wir hatten Besuch und haben diese Gelegenheit genutzt um die Insel Mainau zu besuchen. Ich habe meine 3D Photoausrüstung mitgenommen und die besseren Photos habe ich vorhin online gestellt.

Zur Photogalerie: Insel Mainau

Insel Mainau, 3D, Orchidee

Raspberry Pi als Spielkonsole

Diesmal habe ich ganz einfach etwas nachgebaut, das andere mir vorgelebt haben: Ich habe mir eine Spielkonsole gebaut mit einem Raspberry Pi. Anleitungen dazu gibt es auf Youtube, Thingiverse und anderen Projektseiten für alle möglichen Formen und grössen. Es werden GameBoys, PSPs, PlayStations VCS2600 und andere Konsolen umgebaut, einigen reicht sogar ein SNES Controller (Dank dem Pi Zero).

In meinem Fall habe ich einen Arcade Controller Umgebaut der ursprünglich für den GameCube verkauft wurde. Das Ding lag jahrelang herum und sollte mal auf USB umgebaut werden. Tja, die OpenSource Community hat in der Zwischenzeit fleissig gearbeitet und so kann man nun gleich aus drei super Distributionen auswählen für so einen Umbau:

Die drei können eine grosse Anzahl an Spielkonsolen emulieren und liefern eine Oberfläche mit, die direkt mit den Controller Tasten bedient werden kann und es gibt fertige Images für den Raspberry Pi.

Als Controller können USB, Bluetooth, NES/Atari/Amiga, SNES oder direkt Taster die an die GPIOs angeschlossen werden eingesetzt werden. Es gibt sogar eine vorinstallierte Möglichkeit um den Touchscreen eines Smartphones als Controller zu benutzen (Wenn mal Freunde zu Gast sind und sie auch mitspielen wollen).

Danke an all die Entwickler und Unterstützer von diesen Projekten und den dutzenden Emulatoren, Bibliotheken und Tools ohne so etwas anwenderfreundliches nicht möglich wäre (Mein komplettes Projekt war innerhalb von ca. 6 h fertiggestellt!).

2017/11/11 21:03 · dogbert · 1 Comment

cups-lpd - A way to generate PDF documents with older equipment

What I mean by this title is, that my Tektronix TDS3012B oscilloscope (With floppy drive and Ethernet) is now able to produce nice PDF documents. Before you had to use the floppy drive to get the pictures out of the oscilloscope.

I'm sure that this description is helpful for other people with older equipment or legacy software. The requirement is, that the equipment has a network interface and can somehow print to a standard Unix printer (LPD).

The central program in this setup is called cups-lpd. This program acts as a LPD server and forwards the print-jobs as CUPS client to the already running CUPS server.

This guide is divided into three parts, the common stuff, then the integration into the boot process on your computer (which is different for Sys-V/init and systemd) and then the configuration of the oscilloscope as an example use case.

Install and create the common stuff

I assume here that you already have a working CUPS printing server on your computer, that a virtual PDF printer exist and that the printer is named PDF (To install a CUPS-PDF printer you can follow this how-to).

We use a shell script here to pass additional options to cups-lpd and to do some post-processing on the PDFs (just copy and rename in this case). The CUPS-PDF back-end has also a mechanism to achieve this, but I wanted to limit the post-processing only to LPD print-jobs.

1. Create the destination folder and adjust the access rights (The cups server is running as user lp on debian. Change this if your distribution handle this differently):

sudo mkdir /var/spool/PDF
sudo chown lp /var/spool/PDF && chmod 777 /var/spool/PDF

2. Copy the following shell script (cups-lpd.sh) to the path /usr/local/bin and make it executable:

sudo cp <path to your file>cups-lpd.sh /usr/local/bin/
sudo chmod +x /usr/local/bin/cups-lpd.sh
cups-lpd.sh
#! /bin/sh

# Receive the print data and let it forward it to the PDF printer:
/usr/lib/cups/daemon/cups-lpd -o job-sheets=none,none -o document-format=application/octet-stream

cupspdffolder=/var/spool/cups-pdf/ANONYMOUS
outputfolder=/var/spool/PDF


# Wait until the print-job is finished and do some post-processing
logger -s "Wait until cups-lpd is finished"
while pgrep --exact cups-lpd >/dev/null 2>&1
do
     sleep 5
done 

sleep 5

logger -s "Cups-lpd finished, copy file to destination folder"

newfiles=$(find $cupspdffolder -atime -1 -type f)

for f in $newfiles 
do
	destname=$(basename $f .pdf)-$(date +%H-%M-%S_%d-%m-%Y).pdf
	/bin/cp $f $outputfolder/$destname
        /bin/chmod 666 $outputfolder/$destname
done

Configure inetd to start cups-lpd (Traditional init/Sys-V boot style)

If your system is using the traditional boot process using init and rc scripts. If you are unsure you can check it by running the following command. It will tell you the name of the program with the PID 0:

ps -p 1 -o "comm="

If it is init then follow with this part, if it is systemd use the description in the next chapter.

The program cups-lpd will be started only when it is needed. This is done by inetd, an internet super-server (sometimes xined is used). To enable our script you have to add this line to the file /etc/inetd.conf:

printer                stream tcp      nowait lp	/usr/local/bin/cups-lpd.sh cups-lpd.sh

If there is no such configuration file, it is highly possible that you first have to install inetd with the help of your package management.

After that, restart the inetd server:

sudo /etc/init.d/inetd restart

Now it's time to configure your older equipment or legacy software and test the cups-lpd setup.

Configure systemd to start cups-lpd (New Linux boot system)

Newer Linux installations use systemd to manage the boot process and a lot of other things. Systemd replaces the traditional System-V init system and the init scripts (anything that was in /etc/rc*.d/ and /etc/init.d/). If you are unsure you can check it by running the following command. It will tell you the name of the program with the PID 0:

ps -p 1 -o "comm="

If it is systemd then follow with this part, if it is init use the description in the chapter above.

With systemd there is no need for an additional internet super-server like inetd, systemd can handle that directly! Here is a detailed description: Socket unit configuration

In our case we have to create two files: cups-lpd.socket and cups-lpd@.service (ListenStream means a TCP socket and 515 is the TCP port used by LPD):

cups-lpd.socket
[Unit]
Description=cups-lpd - receive print jobs and report printer status to lpd clients 

[Socket]
ListenStream=515
BindIPv6Only=both
Accept=true

[Install]
WantedBy=sockets.target
cups-lpd@.service
[Unit]
Description=cups-lpd - receive print jobs and report printer status to lpd clients 
After=network.target

[Service]
User=lp
ExecStart=/usr/local/bin/cups-lpd.sh
StandardInput=socket

1. Copy this two files to the path /etc/systemd/system/:

cd <path to your files>
sudo cp cups-lpd.socket cups-lpd@.service /etc/systemd/system/

2. Activate this service so that it is started during boot (Like “Add to runlevel” in the older days). For this you have to enable it:

sudo systemctl enable cups-lpd.socket

3. To start it right away to test your setup, type this:

sudo systemctl start cups-lpd.socket

Or if something went wrong or you changed your configuration file you can also restart your new systemd service:

sudo systemctl restart cups-lpd.socket

Now it's time to configure your older equipment or legacy software and test the cups-lpd setup.

Configure a Textronix TDS30**B

I own a TDS3012B but this description should be true for the whole series (TDS3054B, TDS3014B and so on).

1. Go to the menu: UtilitySystem I/OEthernet Printer Settings
Ethernet printer settings with configured network printer

2. Press Add Printer and enter the needed information. Printer Name is essential, it is the name of the desired printer from the CUPS server! (My virtual PDF printer is named PDF)
Add your CUPS PDF printer to your device

3. Go to the menu: UtilitySystem Hard Copy Select as hard copy format EPS Color and for port Ethernet
Configure the desired behaviour of the //Print// button

4. Restart your oscilloscope and test your new PDF printing feature. No more fiddling around with storage media. Your measurements are already on your PC!

Links:
Description of the line printer daemon (LPD) protocol
Manual page for the cups-lpd deamon
Details about systemd socket configuration files for network sockets or file system FIFOs controlled and supervised by systemd

2015/07/29 23:37 · dogbert

Wichtiger Hinweis:

Trauen sie diesem Text nicht! Die Person die ihn geschrieben hat leidet unter psychischen Störungen, extremer Verwirrtheit, steht unter der Wirkung einer nicht unbedenklichen Menge an toxischen Umweltgiften und Hormonen die aus Abwässern stammen oder direkt in die Nahrungskette eingebracht wurden und Wirkungen zeigen können, wie unter massivem Drogeneinfluss.
Die Weltanschauung dieser Person kann nicht als objektiv bezeichnet werden. Durch einen massiv übermässigen Konsum von Unterhaltungsmedien wie Fernseher und Computerspiele in seiner Kindheit, die eine heikle Entwicklungsphase darstellt, konnte sich diese Person nicht wie andere normal in seine Umgebung integrieren.
Nehemen sie sich vor dieser Person in acht, sie kann sehr sprunghaft reagieren, ist sehr launisch, wierderspricht sich dauernd, nimmt nichts ernst und versucht andere Leute dauerhaft zu verwirren und damit ihr schönes, kleines Leben zu zerstören.

Der EG Gesundheitsminister

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International