
A small quest about replacing a kitchen printer with orders at a restaurant on a display board of orders is a 24 "monitor with raspberryPi per evening. This is relevant for almost any erp system (all modern 1C systems in commercial equipment support receipt printers, similarly with other systems).
Remark
In restaurants and cafes, order printers (“brands” printers) are most often used for printing orders in the kitchen. These are small thermal printers (relatives of cash registers), but without fiscal drives, and they often have one button - a ribbon sweep. Previously, thermal printers were primarily connected to FrontOffice systems like a COM port, but about 10 years ago the situation changed, Ethernet support appeared in printers.
Experience
Printers that are encountered in the work of the manufacturers Shtrih-M, Posiflex, Sam4s, of the same type, use the RAW protocol (one-sided protocol) for printing. They have small web servers with print speed settings, port settings, encoding, additional functionality, and network settings. Some models have the ability to connect a barcode scanner for notifications of readiness of dishes (send the barcode to the network). The cost of the current day for budget models starts from 10 tr. and can reach up to 30 tr on Epson. Lifetime with intensive use from a couple of years. The main causes of failure are breakage of the paper cutter, grease (covers the printer outside and partly the mechanisms inside), failure of the thermal head, drying of the plastic of the rollers and gears, flooding of the printers with liquids. Repair and replacement of items from 50% of the cost of the printer, plus, of course, consumables - thermal paper.
')
Task
So, in coordination with the kitchen and the administration, instead of the next failed thermal printer, a monitor with a raspberry pi 3 B was installed with a 2 GB sd card.
The main task is not to make changes to the FrontOffice system, and for software does not differ from the receipt / order printer.ON waiters FrontOffice Shtrih-M, as the printer orders specified Shtrih-600. Earlier, when Russian printers were changing to Korean, it turned out that the code page in which the packets are transmitted is Windows-1251 port 9100.
Select and configure the OS
As a mini PC, the Raspberry Pi 3 Model B will be
deployed , and the
Raspbian Stretch Lite lightweight system will be
deployed there .
Let's do a little tuning: let's deliver the openbox window manager, the LightDM login manager to the system, set up autologin, hide the boot log.
Some analysis
Next, we build a simple socket server to find out how the information is encoded in the package and what is sent to the thermal printer there at all.
ON FrontOffice sends data in one package in which a pack of specials is flying. characters before and after the main part. Background information about the fonts and their size is encoded with characters that are not in the utf8 encoding. After each line there is a hyphen / r / n. It was possible to write a function that filters special characters, but we have one evening, but in the “brand” the beginning is very well separated by a line of asterisks, the end is minus by a line of characters. Add a crutch, discard the special characters at the beginning and end, decode it into utf8. In the console window, we get a check, as it is when printing on the “stamp” from the printer.
Future application architecture
Let's estimate a little application architecture.
- Socket server, constantly waiting reception.
- Web server.
- Viewer application - browser with fullscreen.
- A messaging system between a socket server and a web server.
Production
We will decide the first and the fourth points by adding the key-value storage with the socket-server, redis, written above, with an eye to future refinement (channels-subscriptions), reducing the sd-card wear on the way. And add a signal - a notification of the arrival of a new order, we will reproduce through hdmi on the monitor columns. Sound output is activated via raspi-config.
On the second point, we assign a web server to flask with auto-update every 15 seconds (while this is the easiest option), check socketio in the task list and maybe turn to celery or to redis. Let's look through all the available pairs of key - value and display on the page. By clicking on the “brand”, we will remove it from the redis and from the desktop, respectively.
Add jinja pattern
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="refresh" content="30"/> <title> </title> <link href="http://fonts.googleapis.com/css?family=Reenie+Beanie:regular" rel="stylesheet" type="text/css"> </head> <body> <ul> {% for key in di %} <li> <a href="/del/{{key}}"> {% for item in di[key].splitlines() %} <p>{{ item }}</p> {% endfor %} </a> </li> {% endfor %} </ul> </body> </html>
Stay 3 remained, let's make the most minimal browser without buttons of 13 lines.
import sys from PySide import QtCore, QtGui, QtWebKit class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.showFullScreen() self.web = QtWebKit.QWebView(self) self.web.load(QtCore.QUrl('http://127.0.0.1:5000')) self.setCentralWidget(self.web) app = QtGui.QApplication(sys.argv) main_window = MainWindow() main_window.show() sys.exit(app.exec_())
Next, you need to create services to run all the above written scripts.
Or in a quick way to register them in autostart file openbox.