Wednesday, 11 November 2026

Quick-and-Dirty TFTP Server

It is easy and frequently handy to spin up an impromptu webserver using Python's http.server module:-

$ python -m http.server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

But what if you want a similarly-impromptu TFTP server? It is almost as easy. It requires the tftpy module (installable with pip) a few lines of code:-

#!/usr/bin/env python3 import os import sys import tftpy # Serves/saves files in the directory where the script is executed root_dir = os.getcwd() print(f"[*] Starting temporary TFTP server in {root_dir}") print("[*] Listening on 0.0.0.0:69 (UDP)... Press Ctrl+C to stop.") server = tftpy.TftpServer(root_dir) try: # Set to '0.0.0.0' to listen on all interfaces server.listen('0.0.0.0', 69) except PermissionError: print("\n[!] Error: Binding to UDP port 69 requires root privileges.") print(" Please run again using: sudo python3 tftpd.py") sys.exit(1) except KeyboardInterrupt: print("\n[*] Stopping TFTP server.")

Then...

$ sudo python server.py [*] Starting temporary TFTP server in /home/pi/tftpy [*] Listening on 0.0.0.0:69 (UDP)... Press Ctrl+C to stop.

The sudo is only required if you need to listen on port 69/udp: if you can use a non-default port, you can run as a regular user.

Monday, 1 June 2026

ABS Sensor Testing

My son's car (2016 Peugeot 208) quite suddenly threw up some alarming-looking warnings recently about ABS, ESP and tyre-pressure monitoring not working. Reading the error-codes from the ECU memory threw up DTC C1331, indicating a fault with the right-hand side ABS sensor:-

 
For reasons that needn't detain us here, I wound out swapping out both front sensors - presumtively one good and one bad.  
 
What is someone with an oscilloscope and some time on their hands supposed to do?
 
I had already determined that the sensor was a hall-effect sensor that couldn't be tested with a multimeter. It was an "active" sensor that required power to operate.  The sensor part number (for the benefit of future generations searching for this information) is PA66-GF26.  It has a two-pin connector on it.
 
 
I struggled to find any good information about how this sensor should be connected up and what the output of it should look like (and indeed how the output of this active sensor would be communicated to the ABS Control Unit, considering that it needs power and only has two pins.  It looks like pin 1 takes power via a resistor (that is internal to the ABS module) and pin 2 is ground:-
 
 
 
The meter in the diagram shows where I hooked up a multimeter (initially) and an oscilloscope (later).  
 
The outcome is interesting.  I had assumed I would see a simple binary "on" or "off" depending on the presence of a magnetic field. That's not what I got at all. Instead, the sensor sends an 18KHz square wave (varying from about +2V to +8.5V) on the + line when there is a magnetic field present.  When there is no magnetic field present, the line just sits at +5V.  There are also periodic (every 2ms) "gaps" in the 18KHz signal, presumably so the ECU can distinguish between a real signal and just any old 18KHz noise.
 
Here are the oscilloscope traces captured with a magnet held close to the sensor:-
 

 The horizontal and vertical cursors show what's going on.  The vertical cursors show the signal on pin 1 being varied from +2.1V to +8.4V (which can only happen is there is a fairly high output impedence on the input to pin 1: I took a complete shot in the dark and used a 1K resistor between the 12V supply and that pin).  The horizontal cursors show the 2ms interval between "gaps" in the 18KHz signal, presumably to allow the ABS module to distinguish the signal from random noise (I'm guessing).
 


It's not a symmetrical square wave: the duty cycles is about 81%.
 
 Now I just need to think of something useful to do with the good sensor I took out of the car 🙂