When you plug an electric car into a charger, nothing happens for a moment. The charger isn't broken, it's doing a handshake. Before any real power flows, the charger (the EVSE , Electric Vehicle Supply Equipment) and the car agree over a single wire that it is safe to start.
That handshake is a classic state machine problem, and Rust handles it well. In this post I'll explain how the signalling works, show a firmware architecture that keeps the safety logic testable, and build the core in Rust.
Disclaimer: this is an educational example. Real chargers handle mains voltage and must be designed and certified to standards like IEC 61851 and UL 2594. Don't use this code as-is in a real product.
The control pilot signal
The connector has a signal wire called the Control Pilot (CP) . The charger puts a 1 kHz square wave on it, and the car pulls the voltage level down with a resistor network.…