The connector is a small Go program on an ordinary office PC. It reads biometric attendance terminals on the office network and sends every punch to an HR and attendance platform in the cloud. It spoke four brands. Then an office installed a fifth.
The terminal was set up, the office PC was paired, and the platform showed the machine as "never connected". Support had saved it as the wrong brand. When the brand was fixed, it still read nothing. When the address was fixed, the terminal answered and then refused every download with "code 3".
I spent a day on site with the office's network and a laptop. By the evening the connector had read the terminal's whole log, about 16,000 records, using only read requests; punches arrived every minute; ten days of history were in with no duplicates; and a signed release with the fix was on the public download page.
This post is the overview: what the connector is, what the network looked like, and the five things that were wrong. The series after it goes deep on each part:
- A fifth protocol in one site visit (this post)
- The whole day: from a Check button to live punches, in order
- How the connector reads six kinds of terminal
- Two bytes to the right: decoding an attendance terminal on site
- When your simulator agrees with your bugs
- Assumptions one terminal made: an audit for the next one
- Setup screens that tell the truth
- Shipping a signed connector release in an afternoon
- Reading a clock you cannot touch
- The connector field handbook: every command, and why
- The connector command sheet: every command, ready to copy
What the connector is
The cloud cannot reach an attendance terminal. It sits on an office network behind one router, often two. So a program on a PC that is already in the office fetches the punches: it reads each terminal over the LAN, keeps the punches on disk, and sends them out over HTTPS. It opens nothing towards the internet. The architecture post has the whole design; the parts that matter here are three:
- A reader per protocol. Every brand sits behind one small Go interface: is it there, give me punches since a time, give me the people. The readers post covers the four that existed.
- A machine list from the platform. The PC asks the platform which terminals it should read, at which address and port, every few minutes.
- A machine link. For terminals stuck on a factory address in another range, the PC can add a second address of its own on a small private range and reach them there. Reaching a machine you cannot route to explains why. It is the right tool for that case and it was the wrong one here.
The network on the day
The office was one flat LAN. The PC and the terminal were both on it. The terminal listened on TCP port 5005, its factory setting, and had no communication password.
Saved link address: the PC dials 10.20.30.2:5005 every minute. Nothing lives there, so every read ends in a timeout, and the card says the PC is online but the machine is not.
Two things were wrong before the protocol came into it:
- The terminal had been saved as the wrong brand. The platform knew four brands, so the first setup picked the nearest one. That brand reads on a different port with a different protocol, and nothing on this terminal spoke it.
- The PC dialled a link address. Setup for that brand had also created a machine link: a /28 on the PC and an address for the terminal inside it. The terminal never moved there. The PC kept trying it first, every minute, and every read ended in a timeout.
Fixing the address by hand got the PC talking to the terminal. That is where the real problem started.
Five things that were wrong
| What | What it looked like | What fixed it | Where |
|---|---|---|---|
| The download request had its fields two bytes early | Every read refused with "code 3", or accepted with zero bytes | Read-only probing on site; the public write-up's layout | Part 4 |
| This model stores 20-byte records, not 12, and packs the year differently | Would have read garbled punches dated in the year 505 | Three long runs in the log and one test punch | Part 4 |
| The simulator agreed with our guesses | Tests green, terminal refusing | Rebuild the simulator from captured bytes | Part 5 |
| A slow-retry rule hid the fix | The new version looked broken for five minutes | Retry at once after an update or an address change | Part 6 |
| Getting the fix onto one PC fast, and onto every PC properly | People waiting on site | A signed release, and a same-code install over the LAN | Part 8 |
And one that was not wrong yet: the terminal's clock. Nobody could set it without standing in front of it, and the protocol's command for setting it is not public. Part 9 reads it from the outside instead.
Three rules that held all day
- Read requests only. Every byte sent to the terminal was one of three requests that only read: hello, count, give me a block. The probe programs refused to send anything else. Some terminals in this family clear their log on the wrong command, and this one held about a year of the office's attendance.
- No guessing at unknown commands. When the download failed I varied the arguments of a known read. I did not try new command bytes. When a fix needed a command nobody had documented, setting the clock, it waited.
- Every fix leaves one test, and the test is checked by taking the fix out. If the test still passes with the fix removed, it is not a test. Part 5 is about how that rule held and still was not enough.
What the people setting it up see now
The protocol fix made the terminal readable. The day also showed every place the setup screens had made it hard. Those changed too:
- One screen to add a terminal the office PC found. The PC already knows its address, port and network ID. HR types a name and picks a branch.
- No serial number required. This terminal cannot send its serial over the network, so the platform knows it by its network ID instead, and two such terminals on one PC cannot be mixed up.
- No phantom link address for this kind of terminal, ever.
- Change address sits first in the machine's menu and opens in the side pane, with the same address check as adding a machine.
- The status says what is happening. "Reading it for the first time", "the machine answers but won't hand over its punches", or "nothing answers at this address", in place of a bare "never connected".
- "Test the connection" says what the PC last saw from the terminal, not only that the PC is online. On the day it said the PC was reading the machine while the machine had never been read.
- A device number per terminal, so a second terminal set to device 2 on the same PC works.
The numbers
| Records in the terminal's log | about 16,000 |
| Time to read all of them over the LAN | about 20 seconds |
| Requests sent that could change the terminal | 0 |
| Wait from installing the fix to the first punch read | about a minute, after the retry fix |
| History brought in afterwards | ten days, no punch stored twice |
| New interactive figures in this series | 10 |
The rest of the series is the detail. If you only read one, read part 4: it is the protocol work, byte by byte.