Manual
Manual
1. Overview
❏ Client applications send commands to local or remote server through the API.
● Communication is done over HTTP or File System.
● The transmitted data is structured according to the definitions.
● APIs for sending commands or files are auto-generated according to the
definitions.
● Command's request and response are fully documented.
● Possibility to control multiple fiscal devices in the local network.
Notes:
- More details can be seen in the provided Demos
- Detailed information about using the libraries can be found in 4.Libraries
- Details about configuration of File Server, usage and examples can be found in 5. File server
3. Package Content
3.1. Protocol_description_XX_yyMMddHHmm.pdf
The document is fully-described communication protocol of TREMOL fiscal devices,
working in fiscal printer mode. In the document’s name are encoded:
● The Country - XX
● The timestamp of the last revision (VERSION) of the protocol. It is the same as the
value of VersionDefinitions field, property or method in the generated libraries.
● (yy - year, MM - month, dd - day, HH - hour, mm -minute)
3.2. ZFPLabServer
Server (driver), which translates and executes the requests from Demo or Customer app
to the fiscal device, and translates back the responses from the fiscal device to the app. The
translation is based on server definitions, which are also auto-generated by the protocol. By
default it is working on TCP port 4444. One server can serve multiple clients and devices. The
communication with the device can be done by Serial, Bluetooth or TCP port.
● Although the various language APIs include all supported commands, they can
be viewed and directly executed at http://localhost:4444 .
● Log can be obtained from the Log tab (Windows with GUI) or at
http://localhost:4444/log
● Only a single instance of the server can run in the system on the same port.
When a new instance starts, it shuts down the previous one.
● To change the default server port an additional file HttpServerSettings.xml should be
created in the ZfpLabServer executable directory with the following content:
❏ Installation
● The file should be marked as executable on the target Distribution OS:
sudo chmod u+x zfplabserver
● In case the communication is not done over LAN or WIFI, setup serial port
(USB) settings:
■ To get the serial ports and change permissions use:
dmesg | grep -i tty
sudo chmod 0777 /dev/ttyACM0
■ In some cases it may be required to change the following settings of
serial/usb port and baud rate for the serial port:
stty -F /dev/ttyS0 -inlcr 115200
stty -F /dev/ttyS0 -opost -onlcr 115200
stty -F /dev/ttyS0 -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 115200
● Start the executable. It expects the XML folder with the definitions to be in the
same directory.
● (Optional) To run the server in background without interruptions, it can be
started in nohup (No Hangups) mode: “nohup ./zfplabserver &“
Nohup mode can also log the full server activity in a chosen file by changing the
output stream of the server to that file:
nohup ./zfplabserver >log.txt &
3.2.3 ZFPLabServer (Android)
Android application which shares the same functionality as it’s Windows and Linux
versions. The server works on Android version 4.1 (Jelly Bean) up to the latest and has features
like:
● Working as a background service. The server does not need any interactions
● Automatic service startup after device reboot, shutdown, RAM clear or
application stop
● Automatic Bluetooth socket release after 60 seconds of device inactivity
● Automatic reconnection to the fiscal device after device wakeup,
Bluetooth/Wifi restart or any other case of a broken connection
● Integrated Log in the server UI in case of diagnostic needs
● Integrated API for direct commands to the fiscal device
3.2.3.1 Installation
❏ Bluetooth connection
● Establishing a connection to the device requires both devices to be paired
● After successful pairing, the fiscal device’s Bluetooth name should be set as:
“fp.ServerSetAndroidBluetoothDeviceSettings(deviceName=”ZK123456”)”
or
"fp.ServerSetDeviceSerialPortSettings(Com=”ZK123456”,Baud=115200)”
❏ WiFi Connection
● Both devices should be connected to the same WiFi network
● IP Address, Port and the ZFP Password of the fiscal device should be set
● Use settings command: fp.ServerSetDeviceTcpSettings()
3.3. Libs
The folder contains auto-generated libraries by the protocol for common programming
languages. The libraries provide the developers easy access to fiscal device functions and save
them the effort to read and understand the protocol.
More details about supported languages can be found in 4. Libraries
3.3.1 FileServerCommands
The folder contains all available, supported protocol-based commands in xml format,
which can be executed separately or combined in one file by ZfpLabServer, after filling in the
values of command parameters if required.
3.4. Demos
The folder contains demo applications in different programming languages, based on the
auto-generated libraries. The demos demonstrate the usage of the most common fiscal
device operations and intercepting the exceptions which can be caused by the device or the
ZFPLabServer.
The folder also contains file server examples, describing some common fiscal receipts
scenarios.
3.5. TOOLS
3.5.1 ZFPLabSetup.exe
Standalone tool, which maintains the overall functionality of the protocol and
provides the user access to all commands and possibility to execute, test and examine them.
3.5.2 Report
Report tool, which can be used for reporting problems, bugs, questions or to. The tool
collects automatically information about Windows, .Net framework, ZFPLabServer, Definition
version, Communication Log and sends an email to [email protected].
3.6 ChangeLog.txt
The file contains the changes in the communication protocol, grouped by package
version. These changes are also listed in VERSIONS section of Protocol_description.pdf
4. Libraries
○ The commands are executed synchronously, each of them blocking until the
fiscal device performs the operation or returns response data.
4.2. C# / Xamarin
Create new C# project, go to Solution Explorer in MS Visual Studio, right click on
References and select Add Reference:
Note:
- FP.cs file is generated by a tool. Changes to this file may cause incorrect behavior and will be lost, if
the code is regenerated.
Example C# code snippet with receipt related commands:
Note:
- Exception handling details see in 4.11 Exception Handling
- ZfpLabServer supports Dll Mode where no installation is required and does not need to be added as
a reference. Setting Dll Mode should be done on application startup with the fp.SetDllMode()
command.
- More detailed demonstration of Library APIs can be found in the demo application in
DEMOS/C#/ZFPDemo folder
4.3. Visual Basic
Create new VB project, go to Solution Explorer in MS Visual Studio, right click on
project name (e.g. VisualBasic_Demo) and select Add Reference:
Note:
- FP.vb file is generated by a tool. Changes to this file may cause incorrect behavior and will be lost, if
the code is regenerated.
Example Visual Basic code snippet with receipt related commands:
Note:
- Exception handling details see in 4.11 Exception Handling
- More detailed demonstration of Library APIs can be found in the demo application in
DEMOS/VB/ZFPDemo folder
4.4. Java
Create new Java project, go to Projects panel, right click on Libraries and select Add
JAR/Folder:
Note:
- Exception handling details see in 4.11 Exception Handling
- More detailed demonstration of Library APIs can be found in the demo application in
DEMOS/Java/ZFPDemo folder
4.5. Android
Create new Android project, go to Project panel, switch folder structure from Android
to Project:
Copy FPcore.jar from Libs\Android, search for the app/libs folder and paste it.
Notes:
- Exception handling details see in 4.11 Exception Handling
- When setting “ServerAddress” property, it should be device IP, where ZFPLabServer is installed
on.
- All FP methods should be executed in another thread, because of the usage of network operations.
- More detailed demonstration of Library APIs can be found in the demo application in
DEMOS/Android/ZFPDemo folder.
4.6. Delphi
Create new project, copy from Libs\Delphi Tremol.FP.pas and Tremol.FP_Core.pas files to
project folder. Go to Project manager, right click on project name (e.g. Delphi_Demo) select
Add:
Note:
- Тo use Tremol.FP.pas and Tremol.FP_Core.pas install the Indy9 package
- Exception handling details see in 4.11 Exception Handling
- More detailed demonstration of Library APIs can be found in the demo application in
DEMOS/Delphi/ZFPDemo folder
4.7. C++
Create new project, copy from Libs\CPP FP.cpp, FP.h, FPcore.dll and FPcore.lib files to
project folder. Go to Project manager, right click on project name and select Properties:
Note:
- Linux is currently not supported.
- Exception handling details see in 4.11 Exception Handling
- FP.cpp and FP.h files are generated by a tool. Changing the files may cause incorrect behavior and
will be lost, if the code is regenerated.
- More detailed demonstration of Library APIs can be found in the demo application in DEMOS/CPP
folder.
4.8. JavaScript
Create new project, copy folder Libs\JS to project folder (e.g. JavaScript_Demo):
Add the script files to main HTML between the <head> tags:
Note:
- Exception handling details see in 4.11 Exception Handling
- FP.js and FP.d.ts files are generated by a tool. Changing the files may cause incorrect behavior and
will be lost, if the code is regenerated.
- More detailed demonstration of Library APIs can be found in the demo application in DEMOS/JS
folder.
4.9. Python
Create new project, copy folder Libs\PY to project folder (e.g. Python_Demo):
Example Python code snippet with receipt related commands:
Note:
- Exception handling details see in 4.11 Exception Handling
- FP.py and FP_core.py files are generated by a tool. Changing the files may cause incorrect behavior
and will be lost, if the code is regenerated.
- FP.py and FP_core.py are compatible with Python 2.x and Python 3.x
- More detailed demonstration of Library APIs can be found in the demo application in DEMOS/PY
folder.
4.10. PHP
Create new project, copy folder Libs\PHP to project folder (e.g. PHP_Demo):
Note:
- Exception handling details see in 4.11 Exception Handling
- FP.php and FP_core.php files are generated by a tool. Changing the files may cause incorrect
behavior and will be lost, if the code is regenerated.
- More detailed demonstration of Library APIs can be found in the demo application in DEMOS/PHP
folder.
4.11. Exception Handling
If an error occurs, the server (driver) returns error object (in most cases, extends base exception
of the corresponding programming language) and in addition contains - error type, error
message and two status bytes (STE1, STE2) for detailed error description.
○ Error type - contains error code, indicating the type of error. Some of the most
important codes are:
➢ 9 - ServMismatchBetweenDefinitionAndFPResult - The current library
version and the fiscal device firmware are not matching.
➢ 104 - ServerDefsMismatch - The current library version and server definitions
version do not match.
➢ 101 - ServerConnectionError - Connection between client application and
server is not established.
➢ 30 - ServSockConnectionFailed - Connection between server and fiscal device
is not established.
➢ 40 - FPException - Error occurred in the fiscal device when executing the last
command.
○ Status bytes (STE1, STE2) - two bytes representing more detailed information, when
40 - FPException has occurred. STE1 - provides information about the error in the
fiscal device, STE2 - command error code.
STE1 STE2
0x30 OK 0x30 OK
0x31 Out of paper, printer failure 0x31 Invalid command
0x32 Registers overflow 0x32 Illegal command
0x33 Clock failure or incorrect date&time 0x33 Z daily report is not zero
0x34 Opened fiscal receipt 0x34 Syntax error
0x35 Payment residue account 0x35 Input registers overflow
0x36 Opened non-fiscal receipt 0x36 Zero input registers
0x37 Registered payment but receipt is not closed 0x37 Unavailable transaction for correction
0x38 Fiscal memory failure 0x38 Insufficient amount on hand
0x39 Incorrect password 0x3A No access
0x3A Missing external display
0x3B 24hours block – missing Z report
0x3C Overheated printer thermal head.
0x3D Interrupt power supply in fiscal receipt
0x3E Overflow EJ
0x3F Insufficient conditions
○ Error message - short message, describing detailed information about the cause of the
error.
Note:
- More error types information and exception handling details can be found in any of the provided
demos.
4.12. Development/Testing without using auto-generated library
If a library for specific language is not provided, fiscal device operations can be
performed by sending HTTP GET request to ZFPLabServer. The server might be running
locally or remotely.
API docs and test environment can be found at the following url location:
http://localhost:4444
Response format:
● Successful execution with no data returned:
Notes:
- All commands can be executed from a browser.
- The full list of commands and their definition may be retrieved from http://localhost:4444
- Тhe same usage rules and error checks apply.
- If the command has no parameters the brackets may be omitted.
- Commands and parameters are not case sensitive.
5. File server
5.1. Configuration
After ZFPLabServer is installed (installation details can be found in 3.2), the installation
folder contains “FILE IN” and “FILE OUT“ folders, which are used as communication input
and output. Default paths can be changed from the Server UI - Control Panel tab:
If the server is running in headless mode (without GUI) or OS is Linux, a file with path
settings -”FileServerSettings.xml” should be created next to the executable with format:
● “_FindDevice.xml” can be used to automatically scan all available COM ports (virtual
USB included), stops at the first detected device and returns port number and baud rate
values. The newly found port can automatically be used for the subsequent connections
to the Fiscal Device if the command is executed with parameter “usefound = 1”.
Note:
- Executing “_Settings.xml” forces the file server to re-establish the connection to the fiscal device, it
is advisable for TCP connections the file to be sent only once.
- “_FindDevice.xml” is not for frequent usage. It can cause delay
issues as a result of scanning multiple virtual COM ports.
5.2.2. Simple fiscal receipt
"FiscReceipt.xml" contains three different commands to issue fiscal receipt:
● Opening fiscal receipt by entering operator number and password values.
● Selling article with predefined name, VAT and price.
● Closing the receipt with cash payment.
Note:
- In the example below there are non-compulsory fields which can be omitted if they
do not have values - quantity, discount/addition in percent (DiscAddP)
In case of any unexpected error/behavior regarding the fiscal device or libraries, a report can be
made with the report tool from folder Tools. The tool automatically collects information about
Windows version, installed .Net Framework versions, connection settings and ZFPlab server
log. The log contains low-level communication data, file server version, ZFPlab server and
definition versions. This information will help us to analyze and resolve the issue faster.
To send a report enter Sender Email (which we will reply to), Subject and Description of the
issue:
For direct contact, send an email to: [email protected] with attached log (from Log tab in
ZFPlab server UI or at http://localhost:4444/log) and OS information.