Project Evolution: From Fake Libraries to Virtual Silicon
Developing embedded projects usually requires all physical hardware, which leads to messy wiring and slow prototyping. While the first version of this project focused on “Fake Libraries,” this improved iteration introduces a Remote Register Mapping model.
By intercepting hardware access at the register level, this version allows you to:
- Run the same production firmware while injecting data directly into the hardware interfaces.
- Experience a Zero-Friction workflow where not a single line of your sensor logic needs to change.
- Use your PC as a “Virtual Silicon” to simulate complex hardware states with ease.
Core Concept: Register Synchronization
The major improvement in this version is the Register Synchronization model. We no longer replace your drivers; we “shadow” the data they use in real-time.
- The Interception: Your MCU maintains a local map of registers that stays in sync with a PC-side GUI via Serial.
- The Injection: The PC GUI acts as the “Fake Hardware,” responding with user-defined values (Analog, Digital, etc.).
- The Result: Your production libraries read from these registers. Since the library handles the mapping, your logic remains 100% identical to the final version.
Example Usage (Improved Implementation)
#include <FakeDrivers.h> // The improved bridge library
#include <RealSensorLib.h> // Your actual, untouched production library
// 1. Initialize the fake connection for the target register address
FakeMapRegister fake({0x48, 0x49});
// 2. Your standard library - no modifications needed
RealSensorLib sensor(0x48);
void setup() {
Serial.begin(115200);
sensor.begin(); // Standard initialization
}
void loop() {
// A. Sync: Fetch latest register values from PC GUI (The Injection)
fake.GetRegisterMapFromPc();
// B. Logic: Remains identical to production.
// The 'sensor' reads data that has been injected via Serial.
float currentTemp = sensor.readFloat();
if (currentTemp > 35.0) {
// Logic Verification: Does the system react to this injected value?
}
// C. Sync: Send any updated MCU states back to PC (The Monitoring)
fake.SendRegisterMapToPc();
delay(500);
}
Key Improvements & Benefits
- Zero-Friction DX: No need to rewrite mocks or learn new APIs for every sensor.
- Logic & State Machine Verification: Test “impossible” hardware failures without a single wire.