Sunday, 9 February 2020

Raspberry Pi screen blanking

I have a Raspberry Pi 4b running Raspbian 4.

After 10 minutes the screen blanks an it is very hard to get it to return: even plugging in a keyboard and mouse and using them doesn't restore the display. Here are some of my findings:

"xset s activate" recreates the problem.

X11 is a client/server Windows Manager.
Raspbian 4 is running Pixel, a derivative of LXDE.

You can see the default display manager with:

cat /etc/X11/default-display-manager
/usr/sbin/lightdm

"sudo service lightdm restart" doesn't fix it.

Accessing the X11 tools differs if you use SSH out of the box from the local terminal connected directly to the Pi. For example I was getting errors such as xset:  unable to open display ""

Also:
echo $DISPLAY
returns :0.0 on the local terminal

but it returns a blank line on SSH unless you turn on X11 forwarding on the Putty console, then it displays:
locahost:10.0

X11 also has security controls.
"xhost +" disables the controls and allows everyone to access it.

References
https://raspberrypi.stackexchange.com/questions/2059/disable-screen-blanking-in-x-windows-on-raspbian




Friday, 10 January 2020

Can't install Minecraft on Twitch

I had a weird problem where whenever I tried to Install Minecraft on Twitch the screen would flash quickly then it would return you back.

I fixed it by changing the install location from my user profile folder (my username had a dot in it) to C:\Temp and then it seemed to work. Even more strangely the folder seem to revert back to the user profile folder.

Saturday, 28 December 2019

Setting up a Ring doorbell Pro on existing wiring for a Friedland 214

This was the process I performed for setting up a Ring Doorbell Pro in conjunction with my existing Friedland 214 doorbell.

The Ring Pro is designed for the US market where their doorbells operate at higher AC voltages. In the UK the standard household operates with lower AC voltages (around 8V AC) and so the Ring Pro in the UK comes with a power converter kit. You get a transformer and a solenoid bypass kit (which is effectively a 50W resistor).

My house was installed with a Friedland 752 transformer and and Friedland 214 door chime. I had both a front door and a back door push button wired up.

The first thing I had to do was figure out the wiring. I isolated the transformer, took the cover off the door chime and compared the wiring to an old diagram I found on the Internet. Note that inside the door chime there is a label and an arrow pointing "Top". Use this to align the chime correctly (mine was installed upside down with Top pointing downwards!). The diagram isn't very clear, but there are actually 3 wires connected to terminal 0 (one half of the AC transformer source and then one connection out to each of the two buttons).


By disconnecting the wires in turn and using a multimeter I found that the front door bell made the connection between terminal 2 and one of the wires screwed into terminal 0.

TerminalDescription
0Multiple wires:
A. Common transformer connection,
B. To Front push button,
C. To Back push button
1Return from Back push button
2Return from Front push button
3Transformer connection

Thus the wires screwed into terminals 2 and 3 were disconnected and pushed into the bypass unit. This puts the resistor in series with the Ring Pro, across the AC output.

To house the transformer I purchased a Wylex ESE2 IP40 2-Module Unpopulated DIN Enclosure from Screwfix (it cost less than £5).

I removed the old Friedland transformer and installed the new Ring transformer inside the Wylex enclosure. I wired up the mains connection and the 24V output.


Monday, 25 November 2019

Tuning ASP.NET

Here are a range of articles for tuning and ASP.NET server:

Performing an await on an async operation does not use a new thread (unless the implementation explicitly starts one). It is possible to write an write to disk asynchronously without using a new worker thread. This article explains why in detail.

Task.Run, TaskFactory.StartNew and ThreadPool.QueueUserWorkItem will use a worker thread.

Contention, poor performance on ASP.NET
ASP.NET Core best practices
Tuning ASP.NET Core and avoiding large memory allocations
ASP.NET Thread usage
Tuning IIS 10
How the garbage collector causes random slowness

IO

IO Completion Threads in more detail
IO Completion ports
Programming IOCP
IOCP and ASP.NET

Memory Management

Pooling memory buffers to avoid keep allocating memory on every request
Memory management and garbage collection
Using ArrayPool

Saturday, 23 November 2019

IO at a low level

This article describes the low level interactions that make up the async process when writing to disk.

Tuesday, 19 November 2019

Chaos testing Azure Service Bus with Toxiproxy

Toxiproxy

Toxiproxy runs as a docker container.

On Docker for Windows, run it in bridge networking (the default). In this the containers are isolated and so to access the port from the host it must be published. Run the container with:
docker run -it -p 8474:8474 -p 443:443 -p 5671:5671 -p 5672:5672 shopify/toxiproxy

This exposes port 8474 (the HTTP API), 443 for HTTPS and ports 5671 and 5672 for proxying Azure Service Bus on AMQP.

You can configure the proxy either by using the client SDK or by using the shell.
To attach the shell:
Docker exec -it <container ID> /bin/sh


To create a proxy for AMQP for ASB, first determine the IP address of the service.
NSLlookup <FQDN of ASB service>


In the shell type:
./toxiproxy-cli create amqp --listen 0.0.0.0:5671 --upstream <IP address of ASB service>:5671


To add upstream and downstream latency:
./toxiproxy-cli toxic add -n downlatency -t latency -a latency=8000 -d amqp

./toxiproxy-cli toxic add -n uplatency -t latency -a latency=8000 -u amqp

Tips

If you need to test any network connectivity you can use
docker run --rm -it praqma/network-multitool bash