This is a Linux implementation of a control software for the Dialoc ID Sapphire EM Staff Station, similar to StaffWorkstation4Linux for the older 3M devices.
It is designed to automatically activate or deactive EM tags in books after a barcode is scanned. A standard USB (keyboard-like) barcode scanner is necessary for this script to operate. The decision if the EM tag is activated or deactivated is done by checking the window title of the circulation software. A QT tray bar icon shows the current operation mode.
The device is recognized as serial port over USB. If you have multiple USB serial devices attached, you may want to create unique device files as the adapters may be recognized in different order on every boot:
# this rule makes your Sapphire with serial=12345678 always available as /dev/sapphire (find your serial be reading `dmesg -w` when connecting the device)
# /etc/udev/rules.d/50-sapphire.rules:
SUBSYSTEMS=="usb", KERNEL=="ttyACM*", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2435", ATTRS{serial}=="12345678", SYMLINK+="sapphire"
Disable serial-getty for exclusive serial port access and add your user to the dialout group for non-root access.
sudo systemctl mask serial-getty@ttyAMA0.service
sudo systemctl mask serial-getty@serial0.service
usermod -aG dialout <linuxuser>
reboot
- Install packages:
apt install python3-serial python3-evdev python3-pyqt6
- Create a config file
~/.config/sapphire4linux.ini:
[sapphire]
port = /dev/sapphire
baud = 115200
keywordcheckout = Ausleihe
keywordcheckin = Rückgabe
checkoutcmd = Set arrow: 200\rD
checkincmd = Set arrow: 200\rA
finishcmd = Set arrow: 0
initcmd = Unit on\rDisable On/Off key\rHost mode\rBeep on error\rRed on error
endcmd = Unit off
[scanner]
device = /dev/input/by-id/usb-Optoelectronics_Co.__Ltd._USB_Code_Reader-event-kbd
initcmd/endcmd can contain arbitrary commands separated by \r (see "Commands.txt" for all available commands).
- Start the application im terminal for testing:
./sapphire.py
Scan a barcode and check if de/activating works.
- Add it into your autostart
~/.config/autostart/sapphire.desktop:
[Desktop Entry]
Type=Application
Exec=/opt/sapphire.py
X-GNOME-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name=Sapphire4Linux
X-GNOME-Autostart-Delay=0
You can start the script with the --shell parameter to get a serial shell for sending arbitrary commands to the device and see the response live.