Package: trimarlib-newland
trimarlib-newlandPython library for interfacing Newland scanners.Getting startedThese instructions will get you a copy of the project on your local machine for development and testing purposes.
SeeDeploymentfor notes on how to deploy the project on a live system.PrerequisitesThe build process requires some basic development tools:make- GNU Make program, either for *nix or Windows system, used to execute build and test targetsgit- used not only to clone the repository, but also in auto-versioning (seeVersioning)python3Two standard Python packages are used for build and installation steps:setuptoolswheelThe library depends onpyserialpackage as well - it is used as a transport layer with the devices.
This dependecy is defined insetup.pyand is satisfied automatically at installation time.Building and releasingInvokingmake all(default target) prepares archives for distribution. It is done in two steps:query Git repository for tags (git describecommand) to determine current version and generateversion.pyfile,invoke Python interpreter passingsetup.pyscript to prepare source and wheel distributions.The Python interpreter invoked by theMakefiledefaults topython- it is possible to override it
passing aPYTHONvariable to the command, e.g.make all PYTHON=python3.The release process is automated and based on GitLab CI/CD environment - each commit triggers a build job
which attempts to make and install built packages (no testing implemented yet, requires an available hardware
platform). If the commit is tagged the built wheel distribution is passed to the deployment stage and
the runner attempts to upload the package to the repository specified in project settings.TestingTest source files are located innewlandlib/testsdirectory, they are named after the device and
functionality being tested. Testing is based onunittestPython built-in package.TheMakefiledefines three test targets:unit-tests,integration-testsandtests(invokes both
unit and integration tests).Unit testsunit-testsare fairly fast and do not require any device to be attached to the machine, they test
utility methods. They may be invoked manually one-by-one (e.g.python -m newlandlib.tests.test_fm100_utils)
or by theMakefile(i.e.make unit-tests).Integration testsintegration-testsareveryslow due to number of tests involved (full testing of FM100 device
takes ca. 3 hours) and they require the device to be attached to the machine running the code. They may be
invoked one-by-one (similarly to unit tests, e.g.python -m newlandlib.tests.test_fm100_commands) or
in batch by theMakefile(i.e.make integration-tests).DeploymentThe library is not intended to be used in a standalone configuration - the primary purpose is to be used
by higher-level applications, which should define it as a dependency. However it is perfectly correct
to install it manually usingpip.VersioningThe project is versioned using a simple pattern based on repository tagging feature. SeeMakefilefor implementation details, for versions available seetags on this repository.UsageSee docstrings for API documentation.Example of device initialization using auto-discovery feature:fromnewlandlibimportFM100ports=FM100.discover()dev=FM100(ports[0])dev.configure()defcallback(sender,*,data,codeid=None,aimid=None):print('sender={}, data={}, codeid={}, aimid={}'.format(sender,data,codeid,aimid))dev.callback=callbackdev.start()Thecallbackmethod will be invoked with each scanned barcode.LicenseThis software is licensed under the MIT License - seeLICENSE.Related documentsThis software is based upon the following documents from Newland:FM100 Integration Guide(v1.2.1, 22/02/2017)FM420 Integration Guide(v1.1.4, 07/08/2014)FM430 User Guide(v1.2.1, 19/07/2018)Programming Guide Based on Newland Unified Commands Set(v1.0.0, 12/02/2018)Serial Programming Command Manual(v1.3.0, 15/11/2016)