Our client was replacing a Windows-based point of sale system (POS) with Odoo. They discovered that Odoo did not support their existing checkout weighing scales (Avery Berkel FX120).
The client has stores across the UK, with multiple checkouts (and scales) in each store. It was not practical to change every checkout scale to a model that was supported by Odoo, so we were asked to develop an integration.
The problem with web applications
The Odoo POS interface is accessed from a web browser, such as Google Chrome or Firefox. For security reasons, web applications can only use interfaces and APIs provided by the browser. A web application cannot directly connect to local hardware devices (such as the checkout scale, which is connected to the point of sale terminal using an RS-232 serial cable).
A draft standard to access RS-232 devices from a browser (the Web Serial API) has been proposed, but at the time of writing it is not available for production use.
Web applications are very good at using web APIs and protocols; HTTP, JSON, REST.
So we designed a piece of middleware software (a hardware proxy microservice) to run on the POS machine and connect to the Avery Berkel FX120 checkout scale using RS-232. The software converts the serial protocol into a web API (JSON/REST) which is usable by the Odoo POS application.
The Odoo POSbox, now known as the Iot Box, uses a similar approach but does not support this particular model of scale.
With a design in place, we began developing the solution. Things don't always go according to plan though, and we did encounter some challenges along the way.
Decoding the FX120 protocol
Avery Berkel supply an SDK (Software Development Kit) for the FX120. However, this SDK only supports the Microsoft Windows operating system. The POS terminal runs Linux, so the SDK was not suitable. Therefore we had to take a lower-level approach and directly use the serial protocol, without a developer-friendly API.
The research was difficult and actually took longer than the development. The documentation we had was incomplete, so we ended up reverse-engineering the interface to discover the serial parameters and control codes to use.
Handling disconnection / re-connection of the scales
In a busy retail environment, it is easy for cables to be knocked, unplugged, power can go on and off, etc. So the solution must be robust enough to handle these events.
We discovered that if the scale gets unplugged and plugged back in, the operating system may assign a different port number to the device (we're using USB to serial adapters rather than fixed RS-232 ports).
The middleware therefore needed to search for the scales rather than being configured to use a fixed port number. We added a feature to scan each serial port in turn and send the scale initialisation command "
[[[A". The first port to get a successful response is used until it is disconnected, then the scan repeats.
The integration proved to be a success, enabling our client to proceed with their project.
Checkout operators can use the scales reliably from the Odoo POS, with weights appearing automatically in real-time.