Archive for the ‘Webtechnology’ Category

No Comments

Fixing the annoying rsync auto-completion bug with path containing spaces

Tuesday, December 5th, 2023

Experimenting with a Raspberry Pi 5, I tried to sync some files from the Pi to my Ubuntu 22.04 Desktop.

Once you have setup ssh-keys with ssh-copy-id, and added an entry to .ssh/config you can easily connect to your pi with

ssh pi

using rsync on the Raspberry Pi

Copying a file or directory can be done with rsync:

rsync pi:pathtofile/file.txt .

Now the file will be copied to your working directory (directory your running the command from)

rsync will magically autocomplete the path in the same way it does for local path by pressing tab.

I have a dir called `new map` on my pi. It contains a space.

When I type `rsync pi:new` and press TAB rsync will auto-complete it to `rsync pi:new\\\ map`

It will double-escape the path.

But executing the command after auto-completion does not work:

rsync pi:new\\\ map .
rsync: [sender] link_stat "/home/pi/new\ map" failed: No such file or directory (2) 
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1865) [Receiver=3.2.7] 
rsync: [Receiver] write error: Broken pipe (32)

Using spaces in maps of file-names is a nasty thing that should be avoided. Sooner or later it will give you troubles.

As it seems newer versions of rsync (> 3.2.4) do NOT require double escaping anymore, but the auto-completion still uses it.

This is clearly a bug:

https://github.com/scop/bash-completion/issues/848

Use the –old-args argument for rsync to fix auto-complete double escaping

The workaround is to use the –old-args argument for rsync

rsync --old-args pi:new\\\ map

Now it is working fine, I suppose this will be fixed in a newer version of rsync.

 

No Comments

Raspberry Pi 5 FAQ

Wednesday, October 4th, 2023

Can the RPI5 suspend to RAM?

Yes, but not yet. Here an RPI engineer states that a future firmware update could implement it. And in the new HAT+ spec for newer HAT+ introduced with the RPI5 that is confirmed. The older HAT was introduced in 2014, so nearly ten years later there is the preliminary HAT+ spec (PDF).

In the spec Chapter 3. Power States:

Raspberry Pi supports the following power states:

  • OFF
    No power connected to the board (the board unplugged).
  • WARM-STANDBY
    The Raspberry Pi is halted/off, but all of the power rails are still enabled. This is the default mode when doing a sudo
    halt or soft power-button-off operation.
  • STANDBY
    The Raspberry Pi has the 5V rail powered — so the power management chip is powered — but no other power
    supplies on the PMIC and board are enabled. You can configure sudo halt or power-button-off using the EEPROM to
    enter this mode instead of WARM-STANDBY.
  • SLEEP
    Some rails are off — notably the CPU core — and Linux is in suspend-to-RAM state. Pressing the power button will
    cause the system to move to the ACTIVE state.
  • ACTIVE
    All rails are up and everything is running, e.g. running desktop Linux.

NOTE: The SLEEP state is not currently supported on Raspberry Pi 5.

So sleep state AKA suspend-to-RAM is coming to the Raspberry Pi 5. Just wait for the future firmware update.

I hope WOL (WakeOnLan) is also coming, rumors (Jeff Geerling) are there, not confirmed yet.

What is the official name of the new RPI 5 device: Raspberry Pi 5 or Raspberry Pi 5 Model B?

That is unclear. 🙂 .

According to mother Lady Raspberry Pi Herself Liz Upton it’s  Raspberry Pi  5

According to father engineer James it does include B in the name: it’s Raspberry Pi 5 Model B

According to the Raspberry Pi 5 itself it’s: Raspberry Pi 5 Model B Rev 1.0

Rev here stands for revision and gives an indication that there has been a small update/patch to the hardware. Of course this name is partly depending of the software/firmware and hardware/revision.

Can I use the same camera cables as for the Raspberry Pi 4?

No, the Raspberry Pi 5 needs another type of cable. Because the connectors are smaller, it uses higher-density pinout variant of the camera cable.

In fact it uses the same cables as a Raspberry Pi Zero (2). So if you have a couple of them, you’re OK.

Does the Raspberry Pi 5 need a new Power Supply?

No, you can run the Raspberry Pi with the trusty Raspberry Pi 4 power supply. It will downstream USB current to 600mA. However, the Raspberry Pi 5 can be more power hungry, and if you really need more power on the USB ports, you better use the new Raspberry Pi 5 power supply. It will more than double the output to 1.6A.

All things considered the new Power Supply is not a bad deal. It will cost you 12 bucks, but it does support PD, and you can even charge your Apple MacBook Pro laptop or your phone.

What about the RPIBOOT mode of the Raspberry Pi 5

If you connect a laptop to the Raspberry Pi 5 USB-C port, so you’re powering the Raspberry Pi5 from your laptop instead of a power supply (yes, that also works on the Raspberry Pi 4), and you press and hold the new power button before connecting the USB-C cable, the Raspberry Pi 5 will boot into USB boot mode; this way the host machine can upload new firmware into the Raspberry Pi 5.

Why does the Raspberry Pi 5 not have an external WiFi Antenna Connector?

Space, and it would be more expensive because you’ll need to cover approval-costs for compliance.

How do I enable USB-boot when I’m using a Raspberry Pi 4 15w power supply instead of the 27w Raspberry Pi 5 power supply?

It will show a warning, stop booting, and you’ll need to press the power button before is continues booting.

Or add this to  `/boot/firmware/config.txt`

usb_max_current_enable=1

See the docs.

2 Comments

The new Raspberry Pi 5 has arrived (in specs)

Saturday, September 30th, 2023

A new Raspberry Pi 5 is introduced, and contrary to earlier launches, the new device is not available yet for customers. It will be on the shelves around the 23rd of October.

This creates a period of time in which the new open-source software can be pushed into the open, and merged with existing repositories. When the boards are shipped in the end of October, the update free open source software is in place.

The new Pi is about twice as fast as the RPI4, memory bandwidth and latency have improved, the same for the I/O. For example WiFi speed is twice as fast, due to the new improved I/O, the WiFi chip itself is the same as in the Pi 4. SD-card speed is twice as fast.

Nearly all parts have been upgraded. A Real Time Clock is a new welcome addition. A fan socket. A power button has been added.

Key features include:

  • 2.4GHz quad-core 64-bit Arm Cortex-A76 CPU
  • VideoCore VII GPU, supporting OpenGLES 3.1, Vulkan 1.2
  • Dual 4Kp60 HDMI® display output
  • 4Kp60 HEVC decoder
  • Dual-band 802.11ac Wi-Fi®
  • Bluetooth 5.0 / Bluetooth Low Energy (BLE)
  • High-speed microSD card interface with SDR104 mode support
  • 2 × USB 3.0 ports, supporting simultaneous 5Gbps operation
  • 2 × USB 2.0 ports
  • Gigabit Ethernet, with PoE+ support (requires separate PoE+ HAT, coming soon)
  • 2 × 4-lane MIPI camera/display transceivers
  • PCIe 2.0 x1 interface for fast peripherals
  • Raspberry Pi standard 40-pin GPIO header
  • Real-time clock
  • Power button

SD-card transfer speed for Raspberry Pi’s

Let’s take a look at the new SD-card speed. A simple benchmark is hdparm for reading speed:

sudo hdparm -t --direct /dev/mmcblk0

So in this post we compare some benchmarks of the new Raspberry Pi 5 and earlier models.

Explaining Computers is getting this speed for a SD-card in the new RaspberryPi 5 (RPI5):

Raspberry Pi 5 SD-card transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 258 MB in 3.01 seconds = 85.69 MB/sec

Raspberry Pi 4 SD-card transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 258 MB in 3.01 seconds = 41.15 MB/sec

Raspberry Pi 400 SD-card transfer speed

We did our own test with a Raspberry Pi 400 and actually we achieved a similar speed:

/dev/mmcblk0:
Timing O_DIRECT disk reads: 126 MB in 3.02 seconds = 41.76 MB/sec

A Raspberry Pi 4 or 400 also doubled the SD-card speed compared to older models, so let’s test a RPI 2:

Raspberry Pi 2 SD-card transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 66 MB in 3.08 seconds = 21.41 MB/sec

Raspberry Pi Zero SD-card transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 64 MB in 3.04 seconds = 21.02 MB/sec

Raspberry Pi Zero 2 SD-card transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 62 MB in 3.00 seconds = 20.65 MB/sec

SD-card RPI5 speed has quadrupled since the RPI2

An yes, the SD-Card speed has quadrupled moving from an original RPI to the new RPI5.

That is not bad.

We also tested the Compute Model 4 with eMMC:

Raspberry Compute Model 4 eMMC transfer speed

/dev/mmcblk0:
Timing O_DIRECT disk reads: 244 MB in 3.00 seconds = 81.22 MB/sec

So the new RPI5 is reading faster from an SD-card then the CM4 is reading from eMMC!

That is a surprise, and AFAICS, this is all related to the much improved I/O at the new RPI5.

Remember, WiFi is twice as fast, and it still has the same WiFi hardware.

USB speeds is now 5GB each on the USB ports, in the RPI4 5GB was shared.

So it seems the new Raspberry Pi 5 is a nice upgrade for just 5 dollars, a new Raspberry Pi 5 4GB/8GB is just 5 dollars more expensive than the Raspberry 4.

SD benchmark transfer speed various Raspberry Pi models

sudo hdparm -t --direct /dev/mmcblk0
Model SD card Speed
RPI 5 (Expl. Comp.) 85.69 MB/sec
CM 4 (eMMC) 81.22 MB/sec
RPI 400 41.76 MB/sec
RPI 4 41.15 MB/sec
RPI 2 21.41 MB/sec
RPI Zero 2 20.65 MB/sec
RPI Zero 21.02 MB/sec

Greetings.

No Comments

Improving accessibility in Ubuntu for the visually impaired with a narrow field of vision

Thursday, August 24th, 2023

For a visually impaired person with a very narrow field of vision it can be difficult to locate the mouse on the screen.

Imagine someone with glaucoma, they are looking through a straw, so they have to scan the screen from left top to right bottom (or sometimes even a sentence character by character).

So what you want sometimes is to move the mouse to the center of the screen or some other easy to spot location.

Historically you could use xdotool for that, but xdotool doesn’t work with Wayland,  and in Wayland there is no out-of-the-box tool to do it.

There a a few options as an alternative:

  • wtype
  • ydotool
  • dotool

wtype is available in the deb repository, so it can be installed with

sudo apt install wtype

BUT

it doesn’t work with Gnome.

`Compositor does not support the virtual keyboard protocol`

I’m not sure if that’s a lacking Gnome feature that will be resolved sooner or later, but IMHO it makes wtype useless for the common Ubuntu user.

Second is ydotool, but that is quite a hassle to install, although there are detailed instructions, so I decided to give the alternative dotool a try.

Follow the instructions (Clone the repo and run install).

Next I created a small bash script


#!/usr/bin/bash
echo "mouseto .5 .5" | dotool

Then simple add a custom shortcut to your script with absolute path and you’re done.

Open Settings -> Keyboard

Choose View and Customize shortcuts -> Custom Shortcuts

 

And add your shortcut.

 

That is all. Now you can easily center the mouse with pressing CTRL SUPER Z.

Remember SUPER is the windows key, normally next to the left CTRL key.

Actually the script will center on the total desktop, so when you use two monitors with extended desktop it won’t center on your screen. 😉

No Comments

Permitting a device to join Zigbee2MQTT in Home Assistant temporarily

Wednesday, June 28th, 2023

The config setting for letting a new device join the Zigbee network is found in Zigbee2MQTT”s configuration.yaml

For security reasons it’s important that permit_join: is set to falseOtherwise rogue devices are able to join allowing them to send and receive Zigbee traffic.

When you want to add a new device editing this setting manually in the config file is a hassle.

Luckily you can issue this CLI command from any connected computer on the LAN to open the network temporarily:

mosquitto_pub -h <hostname> -t zigbee2mqtt/bridge/request/permit_join -m ‘{“value”: true, “time”: 20}’

This will open the network for 20 seconds, enough time to add your device, and when the 20 seconds have passed the network is secure again.

Just keep an eye that no additional rogue devices are added.

No Comments

Using an external AOC touchscreen on Ubuntu

Wednesday, March 1st, 2023

TL;DR

Using an external portable AOC 16T2 monitor as a secondary screen works well on a Ubuntu laptop, but it needs a bit of tweaking.

xinput map-to-output 14 HDMI-A-0

Connecting a touchscreen to an Ubuntu Laptop

One of the first things you’ll do when connecting an USB device, getting info about the device. Is it recognized? Issue an lsusb before and after connecting the device and watch the difference. In this case:

Check connected USB-devices in Linux

lsusb
Bus 001 Device 011: ID 1fd2:9004 Melfas LGDisplay Incell Touch

So Ubuntu does recognize the AOC 16T2 monitor as a touch-device.

For that of course an USB-C (3.0) display cable is necessary, touch information is not transferred over an HDMI cable, in that case you’ll need another USB-C cable, a USB-C 2.0 version is sufficiant.

Another check if the screen is recognized as a touchscreen, issue the xinput command, before and after

Check input devices in Linux

xinput
Melfas LGDisplay Incell Touch id=14 [slave pointer (2)]

Check connected screens in Linux

To check screen use xrandr.

xrandr
HDMI-A-0 connected

Using a touchscreen on Ubuntu, and using a touchpad at the same time causes some confusion. At the moment you use the touchscreen your mouse disappears. That does make some sense, otherwise you feel urged to move the mouse, which is of course not needed on a touchscreen.

Tip: enable locate pointer when using touchscreen

Enable the locate pointer settting in the accessibilty settings, helps you to find you’re invisible mouse. Press CTRL and you can find your mouse-position again.

Once you’re used to that, an external touchscreen works rather strange out of the box, when you’re using join display, extended desktop as a default for attaching an external monitor, which is wanted in most cases.

Strange default in Ubuntu using secondary touchscreen.

Visual the desktop is extended, but for touch-input it is not. SO the visual-desktop is different than the (touch) input-desktop. That means when you click on the second monitor, the gesture is interpreted like you touch on the first monitor.

 

 

And I tried but this cannot be solved by changing the order of screens in the display-setting, moving the external monitor to the left.

To get it working you’ll need to issue a command in the terminal.

Making a external touchscreen working in Ubuntu

To map the touch.input-desktop to the visual-desktop:

xinput map-to-output 14 HDMI-A-0

This will map the touch-desktop to the secondary AOC touchscreen.

You do wonder why this is not the default in Ubuntu. I’m not sure, maybe it was in earlier days.

But this is not working in Wayland

And there is a bigger problem. This solution works only in X11 window server, not in the new Wayland environment, which is the default nowadays in nearly all modern Linux desktop, including Ubuntu 22.04 LTS.

As it seems xinput does not find your touchscreen annymore, so no mapping can be done.

Wayland does recognize the touchscreen, there is no option yet to map  it to the right screen.

That is plain stupid a pity.

So that means you have to logout/login and switch to X11 to use your external touchscreen.

Hopefully this will fixed soon.