Blog ·

What the first tests changed

The first week on real hardware produced a list of fixes. None of them is spectacular, but each one is a case where the station would otherwise have done something wrong without telling you.

The scale

  • No calibration without a zero. Calibrating needs a zero first; the station now refuses a calibration until the empty scale has been zeroed. That is the error from the last post: a calibration without a zero gave believable but wrong weights.
  • Zero at start. A load cell drifts a little between power cycles. When the station starts with an empty scale, the first stable reading close to the stored zero becomes the new zero. A larger weight counts as a spool on the scale, and the stored zero stays.
  • Whole grams. The load cell delivers fractions of a gram that mean nothing for a spool. Weights are now shown, stored and compared in whole grams.
  • A stuck data line. When the HX711 data line stayed at “ready”, the scale task never had to wait and kept the processor busy. On a single-core chip that would starve everything else, the web server included. The scale task now always gives the other tasks their turn.

Spoolman

  • A price with six decimals. A spool created from the station had a price of 12.979999 instead of 12.98, a classic floating point rounding. Fixed.
  • One spool per read. A retry after a slow response could have created the same spool twice. A read now creates at most one spool; a retry continues from the step that failed.
  • Memory limits. The classic ESP32 has no PSRAM, so every list request to Spoolman carries a limit, and the station halves the limit when a response does not fit.
  • Who has this tag? Linking a tag that already belongs to another spool used to end with a plain conflict error. The station now shows which spool holds the tag, so you can decide whether to move it.

Tags and OctoPrint

  • Verified writes. After writing a TigerTag the station reads it back and compares the whole data area with what it meant to write.
  • The OctoPrint API key is write-only: the web interface never shows it again, and the key is erased when the OctoPrint address changes without a new key, so it is never sent to a server it was not meant for.

Robustness

Everything that comes from a tag or from the network is treated as untrusted. One example: the JSON parser now has a nesting limit, so a malformed response cannot exhaust the stack.

Next: a second, cleaner stand.


Questions or ideas? Join the discussion on GitHub. Get updates by e-mail.