User Manual for Nanotec models including: NanoLib Smart Motion Control, NanoLib, Smart Motion Control, Motion Control, Control

NanoLib User Manual Python

NanoLib Python User Manual 1.3.0 (pdf, 547 KB)

NanoLib Software Integration of Controllers /Drives | Nanotec


File Info : application/pdf, 49 Pages, 546.89KB

PDF preview unavailable. Download the PDF instead.

NanoLib-Python User Manual V1.3.0 ?1726723665
User Manual NanoLib
Python

Valid with product version 1.2.0

User Manual Version: 1.3.0

Contents
Contents
1 Document aim and conventions.................................................................. 4
2 Before you start............................................................................................. 5
2.1 System and hardware requirements...........................................................................................................5 2.2 Intended use and audience........................................................................................................................ 5 2.3 Scope of delivery and warranty..................................................................................................................5
3 The NanoLib architecture..............................................................................7
3.1 User interface..............................................................................................................................................7 3.2 NanoLib core...............................................................................................................................................7 3.3 Communication libraries............................................................................................................................. 7
4 Getting started................................................................................................8
4.1 Prepare your system.................................................................................................................................. 8 4.2 Install the Ixxat adapter driver for Windows...............................................................................................8 4.3 Install the Peak adapter driver for Windows.............................................................................................. 8 4.4 Install the Ixxat adapter driver for Linux.....................................................................................................8 4.5 Install the Peak adapter driver for Linux.................................................................................................... 9 4.6 Connect your hardware.............................................................................................................................. 9 4.7 Load NanoLib..............................................................................................................................................9
5 Windows Setup............................................................................................ 10
6 Linux Setup.................................................................................................. 11
7 Classes / functions reference.....................................................................12
7.1 NanoLibAccessor...................................................................................................................................... 12 7.2 BusHardwareId..........................................................................................................................................21 7.3 BusHardwareOptions................................................................................................................................ 23 7.4 BusHwOptionsDefault............................................................................................................................... 24 7.5 CanBaudRate............................................................................................................................................24 7.6 CanBus......................................................................................................................................................24 7.7 CanOpenNmtService................................................................................................................................ 24 7.8 CanOpenNmtState.................................................................................................................................... 24 7.9 EtherCATBus struct.................................................................................................................................. 25 7.10 EtherCATState struct.............................................................................................................................. 25 7.11 Ixxat.........................................................................................................................................................26 7.12 IxxatAdapterBusNumber......................................................................................................................... 26 7.13 Peak........................................................................................................................................................ 26 7.14 PeakAdapterBusNumber.........................................................................................................................26 7.15 DeviceHandle.......................................................................................................................................... 26 7.16 DeviceId.................................................................................................................................................. 27 7.17 LogLevelConverter.................................................................................................................................. 28 7.18 ObjectDictionary...................................................................................................................................... 28 7.19 ObjectEntry..............................................................................................................................................29 7.20 ObjectSubEntry....................................................................................................................................... 31

Contents
7.21 OdIndex...................................................................................................................................................32 7.22 OdIndexVector........................................................................................................................................ 33 7.23 OdLibrary.................................................................................................................................................33 7.24 OdTypesHelper....................................................................................................................................... 34 7.25 RESTfulBus struct...................................................................................................................................35 7.26 ProfinetDCP............................................................................................................................................ 35 7.27 ProfinetDevice struct............................................................................................................................... 37 7.28 Result classes.........................................................................................................................................37
7.28.1 ResultVoid.....................................................................................................................................38 7.28.2 ResultInt........................................................................................................................................ 38 7.28.3 ResultString...................................................................................................................................38 7.28.4 ResultArrayByte............................................................................................................................ 38 7.28.5 ResultArrayInt............................................................................................................................... 38 7.28.6 ResultBusHwIds............................................................................................................................ 39 7.28.7 ResultDeviceId.............................................................................................................................. 39 7.28.8 ResultDeviceIds............................................................................................................................ 39 7.28.9 ResultDeviceHandle......................................................................................................................39 7.28.10 ResultObjectDictionary................................................................................................................39 7.28.11 ResultConnectionState................................................................................................................40 7.28.12 ResultObjectEntry....................................................................................................................... 40 7.28.13 ResultObjectSubEntry................................................................................................................. 40 7.28.14 ResultProfinetDevices................................................................................................................. 40 7.28.15 ResultSampleDataArray..............................................................................................................41 7.28.16 ResultSamplerState.................................................................................................................... 41 7.29 NlcErrorCode...........................................................................................................................................41 7.30 NlcCallback............................................................................................................................................. 42 7.31 NlcDataTransferCallback........................................................................................................................ 42 7.32 NlcScanBusCallback............................................................................................................................... 42 7.33 NlcLoggingCallback.................................................................................................................................42 7.34 SamplerInterface..................................................................................................................................... 43 7.35 SamplerConfiguration struct....................................................................................................................44 7.36 SamplerNotify..........................................................................................................................................45 7.37 SampleData struct.................................................................................................................................. 45 7.38 SampledValue struct............................................................................................................................... 45 7.39 SamplerTrigger struct............................................................................................................................. 45 7.40 Serial struct............................................................................................................................................. 45 7.41 SerialBaudRate struct............................................................................................................................. 46 7.42 SerialParity struct....................................................................................................................................46
8 Licenses........................................................................................................ 47
9 Imprint, contact, versions........................................................................... 48

1 Document aim and conventions
1 Document aim and conventions
This document describes the setup and use of the NanoLib library and contains a reference to all classes and functions for programming your own control software for Nanotec controllers. We use the following typefaces: Underlined text marks a cross reference or hyperlink.  Example 1: For exact instructions on the NanoLibAccessor, see Setup.  Example 2: Install the Ixxat driver and connect the CAN-to-USB adapter. Italic text means: This is a named object, a menu path / item, a tab / file name or (if necessary) a foreignlanguage expression.  Example 1: Select File > New > Blank Document. Open the Tool tab and select Comment.  Example 2: This document divides users (= Nutzer; usuario; utente; utilisateur; utente etc.) from:
- Third-party user (= Drittnutzer; tercero usuario; terceiro utente; tiers utilisateur; terzo utente etc.). - End user (= Endnutzer; usuario final; utente final; utilisateur final; utente finale etc.). Courier marks code blocks or programming commands.  Example 1: Via Bash, call sudo make install to copy shared objects; then call ldconfig.  Example 2: Use the following NanoLibAccessor function to change the logging level in NanoLib:
// ***** C++ variant *****
void setLoggingLevel(LogLevel level);
Bold text emphasizes individual words of critical importance. Alternatively, bracketed exclamation marks emphasize the critical(!) importance.  Example 1: Protect yourself, others and your equipment. Follow our general safety notes that are gener-
ally applicable to all Nanotec products.  Example 2: For your own protection, also follow specific safety notes that apply to this specific product. The verb to co-click means a click via secondary mouse key to open a context menu etc.  Example 1: Co-click on the file, select Rename, and rename the file.  Example 2: To check the properties, co-click on the file and select Properties.

Version: doc 1.3.0 / NanoLib 1.2.0

4

2 Before you start

2 Before you start
Before you start using NanoLib, do prepare your PC and inform yourself about the intended use and the library limitations.
2.1 System and hardware requirements
NOTICE Malfunction from 32-bit operation! Use, and consistently maintain, a 64-bit system. Follow valid OEM instructions.

NanoLib 1.2.0 supports all Nanotec products with CANopen, Modbus RTU (also USB on virtual com port), Modbus TCP, EtherCat, and Profinet. For older NanoLibs: See changelog in the imprint. At your risk only: legacy-system use. Note: Follow valid OEM instructions to set the latency as low as possible if you face problems when using an FTDI-based USB adapter.

Requirements (64-bit system mandatory) Windows 10 or 11 w/ Visual Studio

Language, fieldbus adapters, cables Python 3.7 to 3.12

 CANopen: Ixxat VCI driver (optional)  EtherCat module / Profinet DCP: Npcap or WinPcap  RESTful module: Npcap, WinPcap, or admin permission to
communicate w/ Ethernet bootloaders
Linux w/ Ubuntu 18 to 24 (all x64 and arm64)
 Kernel headers and libpopt-dev packet  Profinet DCP: CAP_NET_ADMIN and CAP_NET_RAW abili-
ties  CANopen: Ixxat ECI driver or Peak PCAN-USB adapter  EtherCat: CAP_NET_ADMIN, CAP_NET_RAW and
CAP_SYS_NICE abilities  RESTful: CAP_NET_ADMIN ability to communicate w/ Eth-
ernet bootloaders (also recommended: CAP_NET_RAW)

 EtherCAT: Ethernet cable  VCP / USB hub: now uniform USB  USB mass storage: USB cable  REST: Ethernet cable  CANopen: Ixxat USB-to-CAN V2; Na-
notec ZK-USB-CAN-1. No Ixxat support for Ubuntu on arm64
 Modbus RTU: Nanotec ZK-USB-RS485-1 or equivalent adapter; USB cable on virtual com port (VCP)
 Modbus TCP: Ethernet cable as per product datasheet

2.2 Intended use and audience
NanoLib is a program library and software component for the operation of, and communication with, Nanotec controllers in a wide range of industrial applications ­ and for duly skilled programmers only.
Due to real-time incapable hardware (PC) and operating system, NanoLib is not for use in applications that need synchronous multi-axis movement or are generally time-sensitive.
In no case may you integrate NanoLib as a safety component into a product or system. On delivery to end users, you must add corresponding warning notices and instructions for safe use and safe operation to each product with a Nanotec-manufactured component. You must pass all Nanotec-issued warning notices right to the end user.

2.3 Scope of delivery and warranty
NanoLib comes as a *.zip folder from our download website for either EMEA / APAC or AMERICA. Duly store and unzip your download before setup. The NanoLib package contains:

 Interface classes as source code (API)

 Core functions as library in binary format: _nanolib_python.pyd

Version: doc 1.3.0 / NanoLib 1.2.0

5

2 Before you start

 Libraries that facilitate communication: nanolibm_  Example code: nanolib_example.py and *_

[yourfieldbus].dll etc.

helper.py

For scope of warranty, please observe a) our terms and conditions for either EMEA / APAC or AMERICA and b) all license terms. Note: Nanotec is not liable for faulty or undue quality, handling, installation, operation, use, and maintenance of third-party equipment! For due safety, always follow valid OEM instructions.

Version: doc 1.3.0 / NanoLib 1.2.0

6

3 The NanoLib architecture

3 The NanoLib architecture

NanoLib's modular software structure lets you arrange freely customizable motor controller / fieldbus functions around a strictly pre-built core. NanoLib contains the following modules:

User interface (API)

NanoLib core

Interface and helper classes which Libraries which

Communication libraries Fieldbus-specific libraries which

 access you to your controller's  implement the API functionality  do interface between NanoLib

OD (object dictionary)

 interact with bus libraries.

core and bus hardware.

 base on the NanoLib core func-

tionalities.

3.1 User interface
The user interface consists of header interface files you can use to access the controller parameters. The user interface classes as described in the Classes / functions reference allow you to:  Connect to both the hardware (fieldbus adapter) and the controller device.  Access the OD of the device, to read/write the controller parameters.
3.2 NanoLib core
The NanoLib core comes with the library nanolib_python.pyd. It implements the user interface functionality and is responsible for:  Loading and managing the communication libraries.  Providing the user interface functionalities in the NanoLibAccessor. This communication entry point de-
fines a set of operations you can execute on the NanoLib core and communication libraries.
3.3 Communication libraries
In addition to nanotec.services.nanolib.dll (useful for your optional Plug & Drive Studio), NanoLib offers the following communication libraries:

 nanolibm_canopen.dll  nanolibm_modbus.dll

 nanolibm_ethercat.dll  nanolibm_restful-api.dll

 nanolibm_usbmmsc.dll  nanolibm_profinet.dll

All libraries lay a hardware abstraction layer between core and controller. The core loads them at startup from the designated project folder and uses them to establish communication with the controller by corresponding protocol.

Version: doc 1.3.0 / NanoLib 1.2.0

7

4 Getting started
4 Getting started
Read how to set up NanoLib for your operating system duly and how to connect hardware as needed.
4.1 Prepare your system
Before installing the adapter drivers, do prepare your PC along the operating system first. To prepare the PC along your Windows OS, install Python 3.7 to 3.12 from their Website. To install make and gcc by Linux Bash, call sudo apt install build-essentials. Do then enable CAP_NET_ADMIN, CAP_NET_RAW, and CAP_SYS_NICE capabilities for the application that uses NanoLib: 1. Call sudo setcap 'cap_net_admin,cap_net_raw,cap_sys_nice+eip' <application_
name>. 2. Only then, install your adapter drivers.
4.2 Install the Ixxat adapter driver for Windows
Only after due driver installation, you may use Ixxat's USB-to-CAN V2 adapter. Read the USB drives' product manual, to learn if / how to activate the virtual comport (VCP). 1. Download and install Ixxat's VCI 4 driver for Windows from www.ixxat.com. 2. Connect Ixxat's USB-to-CAN V2 compact adapter to the PC via USB. 3. By Device Manager: Check if both driver and adapter are duly installed/recognized.
4.3 Install the Peak adapter driver for Windows
Only after due driver installation, you may use Peak's PCAN-USB adapter. Read the USB drives' product manual, to learn if / how to activate the virtual comport (VCP). 1. Download and install the Windows device driver setup (= installation package w/ device drivers, tools, and
APIs) from http://www.peak-system.com. 2. Connect Peak's PCAN-USB adapter to the PC via USB. 3. By Device Manager: Check if both driver and adapter are duly installed/recognized.
4.4 Install the Ixxat adapter driver for Linux
Only after due driver installation, you may use Ixxat's USB-to-CAN V2 adapter. Note: Other supported adapters need your permissions by sudo chmod +777/dev/ttyACM* (* device number). Read the USB drives' product manual, to learn if / how to activate the virtual comport (VCP). 1. Install the software needed for the ECI driver and demo application:
sudo apt-get update apt-get install libusb-1.0-0-dev libusb-0.1-4 libc6 libstdc++6 libgcc1 buildessential
2. Download the ECI-for-Linux driver from www.ixxat.com. Unzip it via:
unzip eci_driver_linux_amd64.zip
3. Install the driver via:
cd /EciLinux_amd/src/KernelModule sudo make install-usb
4. Check for successful driver installation by compiling and starting the demo application:
cd /EciLinux_amd/src/EciDemos/ sudo make cd /EciLinux_amd/bin/release/ ./LinuxEciDemo

Version: doc 1.3.0 / NanoLib 1.2.0

8

4 Getting started
4.5 Install the Peak adapter driver for Linux
Only after due driver installation, you may use Peak's PCAN-USB adapter. Note: Other supported adapters need your permissions by sudo chmod +777/dev/ttyACM* (* device number). Read the USB drives' product manual, to learn if / how to activate the virtual comport (VCP). 1. Check if your Linux has kernel headers: ls /usr/src/linux-headers-`uname -r`. If not, install
them: sudo apt-get install linux-headers-`uname -r` 2. Only now, install the libpopt-dev packet: sudo apt-get install libpopt-dev 3. Download the needed driver package (peak-linux-driver-xxx.tar.gz) from www.peak-system.com. 4. To unpack it, use: tar xzf peak-linux-driver-xxx.tar.gz 5. In the unpacked folder: Compile and install the drivers, PCAN base library, etc.: make all
sudo make install 6. To check the function, plug the PCAN-USB adapter in.
a) Check the kernel module:
lsmod | grep pcan b) ... and the shared library:
ls -l /usr/lib/libpcan*
Note: If USB3 problems occur, use a USB2 port.
4.6 Connect your hardware
To be able to run a NanoLib project, connect a compatible Nanotec controller to the PC using your adapter. 1. By a suitable cable, connect your adapter to the controller. 2. Connect the adapter to the PC according to the adapter data sheet. 3. Power on the controller using a suitable power supply. 4. If needed, change the Nanotec controller's communication settings as instructed in its product manual.
4.7 Load NanoLib
For a first start with quick-and-easy basics, you may (but must not) use our example project. 1. Depending on your region: Download NanoLib from our website for either EMEA / APAC or AMERICA. 2. Unzip the package's files / folders and do select one option:  Windows Setup.  Linux Setup.

Version: doc 1.3.0 / NanoLib 1.2.0

9

5 Windows Setup
5 Windows Setup
A 64-bit system is mandatory to set up NanoLib with Python in Windows. Note:To avert conflict with similarnamed products, Python's pip package is called nanotec_nanolib_win.
1. Install Python  3.7 from www.python.org/. 2. Nanotec advises to use a virtual environment before installing nanoteclib, to open a CMD, and to set a
virtual environment as foillows:
mkdir test_project cd test_project python -m venv .env .env\Scripts\activate.bat
 On setup success, the CMD shows an (.env) prefix, say, (.env) C:\test_project> 3. Use the wheel package to install nanoteclib by pip3 install wheel. 4. In the console: Type pip install [Drive:\Path...\Zip-Filename] and press Enter. 5. Wait for the shell to produce a success report ending on Successfully installed nanotec_nano-
lib_win-N.N.N, with N.N.N. telling the NanoLib version. 6. To check if the installation has worked, open a command line or powershell, if you haven't already. 7. Type python and press Enter to open Python's shell and see something like this:
Python <> Type "help", "copyright", "credits" or "license" for more information. >>>
8. In Python: Type import nanotec_nanolib and press Enter. If no error shows, the installation did work.
9. You can now leave Python by typing exit() and press Enter.
Running the example project
With NanoLib duly loaded, the example project shows you through NanoLib usage with a Nanotec controller. Note: For each step, comments in the provided example code explain the functions used. The example project consists of:
 nanolib_example.py (main program)  nanolib_helper.py (helper class for wrapping the NanoLib accessor)  nanolib_sampler_example.py (optional example for sampler use)  nanolib_profinet_example.py (optional example for PROFINET devices) In a command line or powershell: Use python <PATH_TO_EXAMPLE_FOLDER>\nanotec_example.py to run the nanotec_example.py file. The example demonstrates the typical workflow for handling a controller:
1. Check the PC for connected hardware (adapters) and list them. 2. Establish connection to an adapter. 3. Scan the bus for connected controller devices. 4. Connect to a device. 5. Read/write from/to the controller's object dictionary (examples provided in the code). 6. Close the connection first to the device, then to the adapter.
An example to demonstrate the logging function is in the NanolibLoggingCallbackExample folder. You can find more examples, with some motion commands for various operation modes, in the Knowledge Base at nanotec.com.

Version: doc 1.3.0 / NanoLib 1.2.0

10

6 Linux Setup
6 Linux Setup
For a NanoLib setup with Python in Linux, please note that Python's pip package is called nanotec_nanolib_linux to avert conflict with similar-named products.
1. Install Python  3.7 from www.python.org/. 2. Nanotec recommends using pip and virtual environment. In a bash: Use sudo apt install
python3-pip python3-venv -y to install both. 3. Before installing nanoteclib, you better set a virtual environment as follows:
mkdir test_project cd test_project python3 -m venv .env source ./.env/bin/activate
 On setup success, the bash shows an (.env) prefix, say, (.env) username@hostname:~/test_project$. 4. Use the wheel package to install nanoteclib by pip3 install wheel. 5. In the console: Type pip3 install PATH_TO_NANOTEC_LIB_TAR_GZ/
nanolib_python_linux_N.N.N.tar.gz. 6. Wait for the shell to produce a success report ending on Successfully installed nanolib_py-
thon_linux-N.N.N, with N.N.N. telling the NanoLib version. 7. To check if the installation has worked, open a bash, if you haven't already. 8. Type python3 and press Enter to open Python's shell and see something like this:
Python <> Type "help", "copyright", "credits" or "license" for more information. >>>
9. In Python: Type import nanotec_nanolib and press Enter. If no error shows, the installation did work.
10.You can now leave Python by typing exit() and press Enter.
Running the example project
With NanoLib duly loaded, the example project shows you through NanoLib usage with a Nanotec controller. Note: For each step, comments in the provided example code explain the functions used. The example project consists of:
 nanolib_example.py (main program)  nanolib_helper.py (helper class for wrapping the NanoLib accessor)  nanolib_sampler_example.py (optional example for sampler use)  nanolib_profinet_example.py (optional example for PROFINET devices) In a bash: Use python3 <PATH_TO_EXAMPLE_FOLDER>\nanotec_example.py to run the file nanotec_example.py. The example demonstrates the typical workflow for handling a controller:
1. Check the PC for connected hardware (adapters) and list them. 2. Establish connection to an adapter. 3. Scan the bus for connected controller devices. 4. Connect to a device. 5. Read/write from/to the controller's object dictionary (examples provided in the code). 6. Close the connection first to the device, then to the adapter.
An example to demonstrate the logging function is in the NanolibLoggingCallbackExample folder. You can find more examples, with some motion commands for various operation modes, in the Knowledge Base at nanotec.com.

Version: doc 1.3.0 / NanoLib 1.2.0

11

7 Classes / functions reference

7 Classes / functions reference

Find here a list of NanoLib's user interface classes and their member functions. The typical description of a function includes a short introduction, the function definition and a parameter / return list:

ExampleFunction () Tells you briefly what the function does.
Parameters param_a param_b
Returns ResultVoid

Additional comment if needed. Additional comment if needed.

7.1 NanoLibAccessor

Interface class used as entry point to the NanoLib. A typical workflow looks like this:
1. Start by scanning for hardware with NanoLibAccessor.listAvailableBusHardware (). 2. Set the communication settings with BusHardwareOptions (). 3. Open the hardware connection with NanoLibAccessor.openBusHardwareWithProtocol (). 4. Scan the bus for connected devices with NanoLibAccessor.scanDevices (). 5. Add a device with NanoLibAccessor.addDevice (). 6. Connect to the device with NanoLibAccessor.connectDevice (). 7. After finishing the operation, disconnect the device with NanoLibAccessor.disconnectDevice (). 8. Remove the device with NanoLibAccessor.removeDevice (). 9. Close the hardware connection with NanoLibAccessor.closeBusHardware ().
NanoLibAccessor has the following public member functions:

listAvailableBusHardware () Use this function to list available fieldbus hardware.
listAvailableBusHardware (self)

Returns ResultBusHwIds

Delivers a fieldbus ID array.

openBusHardwareWithProtocol () Use this function to connect bus hardware.
openBusHardwareWithProtocol (self, busHwId, busHwOpt)

Parameters busHwId busHwOpt
Returns ResultVoid

Specifies the fieldbus to open. Specifies fieldbus opening options. Confirms that a void function has run.

isBusHardwareOpen () Use this function to check if your fieldbus hardware connection is open.
isBusHardwareOpen (self, busHardwareId)

Parameters BusHardwareId Returns true
false

Specifies each fieldbus to open. Hardware is open. Hardware is closed.

Version: doc 1.3.0 / NanoLib 1.2.0

12

7 Classes / functions reference

getProtocolSpecificAccessor () Use this function to get the protocol-specific accessor object.
getProtocolSpecificAccessor (self, busHwId)

Parameters busHwId Returns ResultVoid

Specifies the fieldbus to get the accessor for. Confirms that a void function has run.

getProfinetDCP () Use this function to return a reference to Profinet DCP interface.
getProfinetDCP (self)

Returns ProfinetDCP

getSamplerInterface () Use this function to get a reference to the sampler interface.
getSamplerInterface (self)

Returns SamplerInterface

Refers to the sampler interface class.

setBusState () Use this function to set the bus-protocol-specific state.
setBusState (self, busHwId, state)

Parameters busHwId state
Returns ResultVoid

Specifies the fieldbus to open. Assigns a bus-specific state as a string value. Confirms that a void function has run.

scanDevices () Use this function to scan for devices in the network.
scanDevices (self, busHwId, callback)

Parameters busHwId callback
Returns ResultDeviceIds IOError

Specifies the fieldbus to scan. NlcScanBusCallback progress tracer. Delivers a device ID array. Informs that a device is not found.

addDevice () Use this function to add a bus device described by deviceId to NanoLib's internal device list, and to return deviceHandle for it.
addDevice (self, deviceId)

Parameters deviceId Returns ResultDeviceHandle

Specifies the device to add to the list. Delivers a device handle.

Version: doc 1.3.0 / NanoLib 1.2.0

13

7 Classes / functions reference

connectDevice () Use this function to connect a device by deviceHandle.
connectDevice (self, deviceHandle)

Parameters deviceHandle Returns ResultVoid
IOError

Specifies what bus device NanoLib connects to. Confirms that a void function has run. Informs that a device is not found.

getDeviceName () Use this function to get a device's name by deviceHandle.
getDeviceName (self, deviceHandle)

Parameters deviceHandle Returns ResultString

Specifies what bus device NanoLib gets the name for. Delivers device names as a string.

getDeviceProductCode () Use this function to get a device's product code by deviceHandle.
getDeviceProductCode (self, deviceHandle)

Parameters deviceHandle Returns ResultInt

Specifies what bus device NanoLib gets the product code for. Delivers product codes as an integer.

getDeviceVendorId () Use this function to get the device vendor ID by deviceHandle.
getDeviceVendorId (self, deviceHandle)

Parameters deviceHandle Returns ResultInt
ResourceUnavailable

Specifies what bus device NanoLib gets the vendor ID for. Delivers vendor ID's as an integer. Informs that no data is found.

getDeviceId () Use this function to get a specific device's ID from the NanoLib internal list.
getDeviceId (self)

Parameters deviceHandle Returns ResultDeviceId

Specifies what bus device NanoLib gets the device ID for. Delivers a device ID.

getDeviceIds () Use this function to get all devices' ID from the NanoLib internal list.
getDeviceIds (self)

Returns ResultDeviceIds

Delivers a device ID list.

Version: doc 1.3.0 / NanoLib 1.2.0

14

7 Classes / functions reference

getDeviceUid () Use this function to get a device's unique ID (96 bit / 12 bytes) by deviceHandle.
getDeviceUid (self)

Parameters deviceHandle Returns ResultArrayByte
ResourceUnavailable

Specifies what bus device NanoLib gets the unique ID for. Delivers unique ID's as a byte array. Informs that no data is found.

getDeviceSerialNumber () Use this function to get a device's serial number by deviceHandle.
getDeviceSerialNumber (self)

Parameters deviceHandle Returns ResultString
ResourceUnavailable

Specifies what bus device NanoLib gets the serial number for. Delivers serial numbers as a string. Informs that no data is found.

getDeviceHardwareGroup () Use this function to get a bus device's hardware group by deviceHandle.
getDeviceHardwareGroup (self, deviceHandle)

Parameters deviceHandle Returns ResultInt

Specifies what bus device NanoLib gets the hardware group for.
Delivers hardware groups as an integer.

getDeviceHardwareVersion () Use this function to get a bus device's hardware version by deviceHandle.
getDeviceHardwareVersion (self, deviceHandle)

Parameters deviceHandle

Returns

ResultString ResourceUnavailable

Specifies what bus device NanoLib gets the hardware version for. Delivers device names as a string. Informs that no data is found.

getDeviceFirmwareBuildId () Use this function to get a bus device's firmware build ID by deviceHandle.
getDeviceFirmwareBuildId (self, deviceHandle)

Parameters deviceHandle Returns ResultString

Specifies what bus device NanoLib gets the firmware build ID for.
Delivers device names as a string.

getDeviceBootloaderVersion () Use this function to get a bus device's bootloader version by deviceHandle.
getDeviceBootloaderVersion (self, deviceHandle)

Version: doc 1.3.0 / NanoLib 1.2.0

15

7 Classes / functions reference

Parameters deviceHandle

Returns

ResultInt ResourceUnavailable

Specifies what bus device NanoLib gets the bootloader version for. Delivers bootloader versions as an integer. Informs that no data is found.

getDeviceBootloaderBuildId () Use this function to get a bus device's bootloader build ID by deviceHandle.
getDeviceBootloaderBuildId (self, deviceHandle)

Parameters deviceHandle Returns ResultString

Specifies what bus device NanoLib gets the bootloader build ID for.
Delivers device names as a string.

rebootDevice () Use this function to reboot the device by deviceHandle.
rebootDevice (self, deviceHandle)

Parameters deviceHandle Returns ResultVoid

Specifies the fieldbus to reboot. Confirms that a void function has run.

getDeviceState () Use this function to get the device-protocol-specific state.
getDeviceState (self, deviceHandle)

Parameters deviceHandle Returns ResultString

Specifies what bus device NanoLib gets the state for. Delivers device names as a string.

setDeviceState () Use this function to set the device-protocol-specific state.
setDeviceState (self, deviceHandle, state):

Parameters deviceHandle state
Returns ResultVoid

Specifies what bus device NanoLib sets the state for. Assigns a bus-specific state as a string value. Confirms that a void function has run.

getConnectionState () Use this function to get a specific device's last known connection state by deviceHandle (= Disconnected, Connected, ConnectedBootloader)
getConnectionState (self, deviceHandle)

Parameters deviceHandle Returns ResultConnectionState

Specifies what bus device NanoLib gets the connection state for.
Delivers a connection state (= Disconnected, Connected, ConnectedBootloader).

Version: doc 1.3.0 / NanoLib 1.2.0

16

7 Classes / functions reference

checkConnectionState () Only if the last known state was not Disconnected: Use this function to check and possibly update a specific device's connection state by deviceHandle and by testing several mode-specific operations.
checkConnectionState (self, deviceHandle)

Parameters deviceHandle Returns ResultConnectionState

Specifies what bus device NanoLib checks the connection state for.
Delivers a connection state (= not Disconnected).

assignObjectDictionary () Use this manual function to assign an object dictionary (OD) to deviceHandle on your own.
assignObjectDictionary (self, deviceHandle, objectDictionary)

Parameters deviceHandle objectDictionary
Returns ResultObjectDictionary

Specifies what bus device NanoLib assigns the OD to. Shows the properties of an object dictionary.

autoAssignObjectDictionary () Use this automatism to let NanoLib assign an object dictionary (OD) to deviceHandle. On finding and loading a suitable OD, NanoLib automatically assigns it to the device. Note: If a compatible OD is already loaded in the object library, NanoLib will automatically use it without scanning the submitted directory.
autoAssignObjectDictionary (self, deviceHandle, dictionariesLocationPath)

Parameters deviceHandle

Returns

dictionariesLocationPath ResultObjectDictionary

Specifies for which bus device NanoLib shall automatically scan for suitable OD's. Specifies the path to the OD directory. Shows the properties of an object dictionary.

getAssignedObjectDictionary () Use this function to get the object dictionary assigned to a device by deviceHandle.
getAssignedObjectDictionary (self, deviceHandle)

Parameters deviceHandle Returns ResultObjectDictionary

Specifies what bus device NanoLib gets the assigned OD for. Shows the properties of an object dictionary.

getObjectDictionaryLibrary () This function returns an OdLibrary reference.
getObjectDictionaryLibrary (self)

Returns OdLibrary&

Opens the entire OD library and its object dictionaries.

setLoggingLevel () Use this function to set the needed log detailing (and log file size). Default level is Info.
setLoggingLevel (self, level)

Version: doc 1.3.0 / NanoLib 1.2.0

17

7 Classes / functions reference

Parameters level

The following log detailings are possible:

0 = Trace 1 = Debug 2 = Info 3 = Warn 4 = Error 5 = Critical 6 = Off

Lowest level (largest log file); logs any feasible detail, plus software start / stop. Logs debug information (= interim results, content sent or received, etc.) Default level; logs informational messages. Logs problems that did occur but won't stop the current algorithm. Logs just severe trouble that did stop the algorithm. Highest level (smallest log file); turns logging off; no further log at all. No logging at all.

setLoggingCallback () Use this function to set a logging callback pointer and log module (= library) for that callback (not for the logger itself).
setLoggingCallback(self, callback, logModule)

Parameters *callback logModule

Sets a callback pointer. Tunes the callback (not logger!) to your library.

0 = NanolibCore 1 = NanolibCANopen 2 = NanolibModbus 3 = NanolibEtherCAT 4 = NanolibRest 5 = NanolibUSB

Activates a callback for NanoLib's core only. Activates a CANopen-only callback. Activates a Modbus-only callback. Activates an EtherCAT-only callback. Activates a REST-only callback. Activates a USB-only callback.

unsetLoggingCallback () Use this function to cancel a logging callback pointer.
unsetLoggingCallback (self)

readNumber () Use this function to read a numeric value from the object dictionary.
readNumber (self, deviceHandle, odIndex)

Parameters deviceHandle odIndex
Returns ResultInt

Specifies what bus device NanoLib reads from. Specifies the (sub-) index to read from. Delivers an uninterpreted numeric value (can be signed, unsigned, fix16.16 bit values).

readNumberArray () Use this function to read numeric arrays from the object dictionary.
readNumberArray (self, deviceHandle, index)

Parameters deviceHandle index
Returns ResultArrayInt

Specifies what bus device NanoLib reads from. Array object index. Delivers an integer array.

Version: doc 1.3.0 / NanoLib 1.2.0

18

7 Classes / functions reference

readBytes () Use this function to read arbitrary bytes (domain object data) from the object dictionary.
readBytes (self, odIndex)

Parameters deviceHandle odIndex
Returns ResultArrayByte

Specifies what bus device NanoLib reads from. Specifies the (sub-) index to read from. Delivers a byte array.

readString () Use this function to read strings from the object directory.
readString (self)

Parameters deviceHandle odIndex
Returns ResultString

Specifies what bus device NanoLib reads from. Specifies the (sub-) index to read from. Delivers device names as a string.

writeNumber () Use this function to write numeric values to the object directory.
writeNumber (self, deviceHandle, value, odIndex, bitLength)

Parameters deviceHandle value odIndex bitLength
Returns ResultVoid

Specifies what bus device NanoLib writes to. The uninterpreted value (can be signed, unsigned, fix 16.16). Specifies the (sub-) index to read from. Length in bit. Confirms that a void function has run.

writeBytes () Use this function to write arbitrary bytes (domain object data) to the object directory.
writeBytes (self, deviceHandle, data, odIndex)

Parameters deviceHandle data odIndex
Returns ResultVoid

Specifies what bus device NanoLib writes to. Byte vector / array. Specifies the (sub-) index to read from. Confirms that a void function has run.

uploadFirmware () Use this function to update your controller firmware.
uploadFirmware (self, deviceHandle, fwData, callback)

Parameters deviceHandle fwData NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib updates. Array containing firmware data. A data progress tracer. Confirms that a void function has run.

Version: doc 1.3.0 / NanoLib 1.2.0

19

7 Classes / functions reference

uploadFirmwareFromFile () Use this function to update your controller firmware by uploading its file.
uploadFirmwareFromFile (self, deviceHandle, absoluteFilePath, callback)

Parameters deviceHandle absoluteFilePath NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib updates. Path to file containing firmware data (string). A data progress tracer. Confirms that a void function has run.

uploadBootloader () Use this function to update your controller bootloader.
uploadBootloader (self, deviceHandle, btData, callback)

Parameters deviceHandle btData NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib updates. Array containing bootloader data. A data progress tracer. Confirms that a void function has run.

uploadBootloaderFromFile () Use this function to update your controller bootloader by uploading its file.
uploadBootloaderFromFile (self, deviceHandle, bootloaderAbsoluteFilePath, callback)

Parameters deviceHandle bootloaderAbsoluteFilePath NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib updates. Path to file containing bootloader data (string). A data progress tracer. Confirms that a void function has run.

uploadBootloaderFirmware () Use this function to update your controller bootloader and firmware.
uploadBootloaderFirmware (self, deviceHandle, btData, fwData, callback)

Parameters deviceHandle btData fwData NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib updates. Array containing bootloader data. Array containing firmware data. A data progress tracer. Confirms that a void function has run.

uploadBootloaderFirmwareFromFile () Use this function to update your controller bootloader and firmware by uploading the files.
uploadBootloaderFirmwareFromFile (self, deviceHandle, bootloaderAbsoluteFilePath, absoluteFilePath, callback)

Parameters deviceHandle bootloaderAbsoluteFilePath absoluteFilePath

Specifies what bus device NanoLib updates. Path to file containing bootloader data (string). Path to file containing firmware data (uint8_t).

Version: doc 1.3.0 / NanoLib 1.2.0

20

7 Classes / functions reference

Returns

NlcDataTransferCallback ResultVoid

A data progress tracer. Confirms that a void function has run.

uploadNanoJ () Use this public function to updload the NanoJ program to your controller.
uploadNanoJ (self, deviceHandle, vmmData, callback)

Parameters deviceHandle vmmData NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib uploads to. Array containing NanoJ data. A data progress tracer. Confirms that a void function has run.

uploadNanoJFromFile () Use this public function to updload the NanoJ program to your controller by uploading the file.
uploadNanoJFromFile (self, deviceHandle, absoluteFilePath, callback)

Parameters deviceHandle absoluteFilePath NlcDataTransferCallback
Returns ResultVoid

Specifies what bus device NanoLib uploads to. Path to file containing NanoJ data (string). A data progress tracer. Confirms that a void function has run.

disconnectDevice () Use this function to disconnect your device by deviceHandle.
disconnectDevice (self, deviceHandle)

Parameters deviceHandle Returns ResultVoid

Specifies what bus device NanoLib disconnects from. Confirms that a void function has run.

removeDevice () Use this function to remove your device from NanoLib's internal device list.
removeDevice (self, deviceHandle)

Parameters deviceHandle Returns ResultVoid

Specifies what bus device NanoLib delists. Confirms that a void function has run.

closeBusHardware () Use this function to disconnect from your fieldbus hardware.
closeBusHardware (self, busHwId)

Parameters busHwId Returns ResultVoid

Specifies the fieldbus to disconnect from. Confirms that a void function has run.

7.2 BusHardwareId

Use this class to identify a bus hardware one-to-one or to distinguish different bus hardware from each other. This class (without setter functions to be immutable from creation on) also holds information on:

Version: doc 1.3.0 / NanoLib 1.2.0

21

7 Classes / functions reference

 Hardware (= adapter name, network adapter etc.)  Protocol to use (= Modbus TCP, CANopen etc.)
 Bus hardware specifier (= serial port name, MAC  Friendly name address etc.)

Parameters
Parameters busHardware_ protocol_ hardwareSpecifier_ extraHardwareSpecifier_ name_

Hardware type (= ZK-USB-CAN-1 etc.). Bus communication protocol (= CANopen etc.). The specifier of a hardware (= COM3 etc.). The extra specifier of the hardware (say, USB location info). A friendly name (= AdapterName (Port) etc. ).

equals () Compares a new bus hardware ID to existing ones.
equals (self, other)

Parameters other Returns true
false

Another object of the same class. If both are equal in all values. If the values differ.

getBusHardware () Reads out the bus hardware string.
getBusHardware (self)

Returns string

getHardwareSpecifier () Reads out the bus hardware's specifier string (= network name etc.).
getHardwareSpecifier (self)

Returns string

getExtraHardwareSpecifier () Reads out the bus extra hardware's specifier string (= MAC address etc.).
getExtraHardwareSpecifier (self)

Returns string

getName () Reads out the bus hardware's friendly name.
getName (self)

Returns string

Version: doc 1.3.0 / NanoLib 1.2.0

22

7 Classes / functions reference

getProtocol () Reads out the bus protocol string.
getProtocol (self)

Returns string

toString () Returns the bus hardware ID as a string.
toString (self)

Returns string
7.3 BusHardwareOptions
Find in this class, in a key-value list of strings, all options needed to open a bus hardware and to construct a new bus hardware option object.

addOption () Creates additional keys and values.
addOption (self, key, value)

Parameters key value

Example: BAUD_RATE_OPTIONS_NAME, see bus_hw_options_ defaults
Example: BAUD_RATE_1000K, see bus_hw_options_defaults

equals () Compares the BusHardwareOptions to existing ones.
equals (self, other)void addOption (String key, String value) {NanolibJNI.BusHardwareOptions_addOption (swigCPtr, this, key, value);}

Parameters other Returns true
false

Another object of the same class. If the other object has all of the exact same options. If the other object has different keys or values.

getOptions () Reads out all added key-value pairs.
getOptions (self)

Returns string map

toString () Returns all keys / values as a string.
toString (self)

Returns string

Version: doc 1.3.0 / NanoLib 1.2.0

23

7 Classes / functions reference

7.4 BusHwOptionsDefault

This default configuration options class has the following public attributes:

const CanBus const Serial const RESTfulBus const EtherCATBus

canBus = CanBus () serial = Serial () restfulBus = RESTfulBus() ethercatBus = EtherCATBus()

7.5 CanBaudRate

Struct that contains CAN bus baudrates in the following public attributes:

string string string string string string string string string string

BAUD_RATE_1000K = "1000k" BAUD_RATE_800K = "800k" BAUD_RATE_500K = "500k" BAUD_RATE_250K = "250k" BAUD_RATE_125K = "125k" BAUD_RATE_100K = "100k" BAUD_RATE_50K = "50k" BAUD_RATE_20K = "20k" BAUD_RATE_10K = "10k" BAUD_RATE_5K = "5k"

7.6 CanBus

Default configuration options class with the following public attributes:

string const CanBaudRate const Ixxat

BAUD_RATE_OPTIONS_NAME = "can adapter baud rate" baudRate = CanBaudRate () ixxat = Ixxat ()

7.7 CanOpenNmtService

For the NMT service, this struct contains the CANopen NMT states as string values in the following public attributes:

string string string string string

START = "START" STOP = "STOP" PRE_OPERATIONAL = "PRE_OPERATIONAL" RESET = "RESET" RESET_COMMUNICATION = "RESET_COMMUNICATION"

7.8 CanOpenNmtState

This struct contains the CANopen NMT states as string values in the following public attributes:

string string string string string

STOPPED = "STOPPED" PRE_OPERATIONAL = "PRE_OPERATIONAL" OPERATIONAL = "OPERATIONAL" INITIALIZATION = "INITIALIZATION" UNKNOWN = "UNKNOWN"

Version: doc 1.3.0 / NanoLib 1.2.0

24

7 Classes / functions reference

7.9 EtherCATBus struct

This struct contains the EtherCAT communication configuration options in the following public attributes:

string NETWORK_FIRMWARE_STATE_OPTION_NAME Network state treated as firmware mode. Acceptable

= "Network Firmware State"

values (default = PRE_OPERATIONAL):

 EtherCATState::PRE_OPERATIONAL  EtherCATState::SAFE_OPERATIONAL  EtherCATState::OPERATIONAL

string DEFAULT_NETWORK_FIRMWARE_STATE = "PRE_OPERATIONAL"

string EXCLUSIVE_LOCK_TIMEOUT_OPTION_NAME Timeout in milliseconds to acquire exclusive lock on

= "Shared Lock Timeout"

the network (default = 500 ms).

const unsigned int DEFAULT_EXCLUSIVE_LOCK_ TIMEOUT = "500"

string SHARED_LOCK_TIMEOUT_OPTION_NAME = Timeout in milliseconds to acquire shared lock on

"Shared Lock Timeout"

the network (default = 250 ms).

const unsigned int DEFAULT_SHARED_LOCK_TIMEOUT = "250"

string READ_TIMEOUT_OPTION_NAME = "Read Timeout"

Timeout in milliseconds for a read operation (default = 700 ms).

const unsigned int DEFAULT_READ_TIMEOUT = "700"

string WRITE_TIMEOUT_OPTION_NAME = "Write Timeout"

Timeout in milliseconds for a write operation (default = 200 ms).

const unsigned int DEFAULT_WRITE_TIMEOUT = "200"

string READ_WRITE_ATTEMPTS_OPTION_NAME = Maximum read or write attempts (non-zero values

"Read/Write Attempts"

only; default = 5).

const unsigned int DEFAULT_READ_WRITE_ATTEMPTS = "5"

string CHANGE_NETWORK_STATE_ATTEMPTS_OPTION_NAME = "Change Network State Attempts"

Maximum number of attempts to alter the network state (non-zero values only; default = 10).

const unsigned int DEFAULT_CHANGE_NETWORK_ STATE_ATTEMPTS = "10"

string PDO_IO_ENABLED_OPTION_NAME = "PDO IO Enables or disables PDO processing for digital in- /

Enabled"

outputs ("True" or "False" only; default = "True").

string DEFAULT_PDO_IO_ENABLED = "True"

7.10 EtherCATState struct

This struct contains the EtherCAT slave / network states as string values in the following public attributes. Note: Default state at power on is PRE_OPERATIONAL; NanoLib can provide no reliable "OPERATIONAL" state in a non-realtime operating system:

string string string string string string

NONE = "NONE" INIT = "INIT" PRE_OPERATIONAL = "PRE_OPERATIONAL" BOOT = "BOOT" SAFE_OPERATIONAL = "SAFE_OPERATIONAL" OPERATIONAL = "OPERATIONAL"

Version: doc 1.3.0 / NanoLib 1.2.0

25

7 Classes / functions reference

7.11 Ixxat

This struct holds all information for the Ixxat usb-to-can in the following public attributes:

string

ADAPTER_BUS_NUMBER_OPTIONS_NAME = "ixxat adapter bus number"

const IxxatAdapterBusNumber adapterBusNumber = IxxatAdapterBusNumber ()

7.12 IxxatAdapterBusNumber

This struct holds the bus number for the Ixxat usb-to-can in the following public attributes:

string string string string

BUS_NUMBER_0_DEFAULT = "0" BUS_NUMBER_1 = "1" BUS_NUMBER_2 = "2" BUS_NUMBER_3 = "3"

7.13 Peak

This struct holds all information for the Peak usb-to-can in the following public attributes:

string

ADAPTER_BUS_NUMBER_OPTIONS_NAME = "peak adapter bus number"

const PeakAdapterBusNumber adapterBusNumber = PeakAdapterBusNumber ()

7.14 PeakAdapterBusNumber

This struct holds the bus number for the Peak usb-to-can in the following public attributes:

string string string string string string string string string string string string string string string string

BUS_NUMBER_1_DEFAULT = std::to_string (PCAN_USBBUS1) BUS_NUMBER_2 = std::to_string (PCAN_USBBUS2) BUS_NUMBER_3 = std::to_string (PCAN_USBBUS3) BUS_NUMBER_4 = std::to_string (PCAN_USBBUS4) BUS_NUMBER_5 = std::to_string (PCAN_USBBUS5) BUS_NUMBER_6 = std::to_string (PCAN_USBBUS6) BUS_NUMBER_7 = std::to_string (PCAN_USBBUS7) BUS_NUMBER_8 = std::to_string (PCAN_USBBUS8) BUS_NUMBER_9 = std::to_string (PCAN_USBBUS9) BUS_NUMBER_10 = std::to_string (PCAN_USBBUS10) BUS_NUMBER_11 = std::to_string (PCAN_USBBUS11) BUS_NUMBER_12 = std::to_string (PCAN_USBBUS12) BUS_NUMBER_13 = std::to_string (PCAN_USBBUS13) BUS_NUMBER_14 = std::to_string (PCAN_USBBUS14) BUS_NUMBER_15 = std::to_string (PCAN_USBBUS15) BUS_NUMBER_16 = std::to_string (PCAN_USBBUS16)

7.15 DeviceHandle
This class represents a handle for controlling a device on a bus and has the following public member functions.

Version: doc 1.3.0 / NanoLib 1.2.0

26

7 Classes / functions reference

DeviceHandle ()
equals () Compares itself to a given device handle.
equals (self, other)

toString () Returns a string representation of the device handle.
toString (self)

7.16 DeviceId
Use this class (not immutable from creation on) to identify and distinguish devices on a bus:

 Hardware adapter identifier

 Device identifier

 Description

The meaning of device ID / description values depends on the bus. For example, a CAN bus may use the integer ID.

Parameters
Parameters busHardwareId_ deviceId_ description_ extraId_ extraStringId_

Identifier of the bus. An index; subject to bus (= CANopen node ID etc.). A description (may be empty); subject to bus. An additional ID (may be empty); meaning depends on bus. Additional string ID (may be empty); meaning depends on bus.

equals () Compares new to existing objects.
equals (self, other)
Returns boolean

getBusHardwareId () Reads out the bus hardware ID.
getBusHardwareId (self)
Returns BusHardwareId

getDescription () Reads out the device description (maybe unused).
getDescription (self)
Returns string

Version: doc 1.3.0 / NanoLib 1.2.0

27

7 Classes / functions reference

getDeviceId () Reads out the device ID (maybe unused).
getDeviceId (self)
Returns unsigned int

toString () Returns the object as a string.
toString (self)
Returns string

getExtraId () Reads out the extra ID of the device (may be unused).
getExtraId (self)

Returns vector extraId_

A vector of the additional extra ID's (may be empty); meaning depends on the bus.

getExtraStringId () Reads out the extra string ID of the device (may be unused).
getExtraStringId (self)

Returns string

The additional string ID (may be empty); meaning depends on the bus.

7.17 LogLevelConverter
This class returns your log level as a string. toString (logLevel)

7.18 ObjectDictionary
This class represents an object dictionary of a controller and has the following public member functions:

getDeviceHandle () getDeviceHandle (self) Returns ResultDeviceHandle

getObject () getObject (self, OdIndex) Returns ResultObjectSubEntry

Version: doc 1.3.0 / NanoLib 1.2.0

28

7 Classes / functions reference

getObjectEntry () getObjectEntry (self, index)

Returns ResultObjectEntry

Informs on an object's properties.

getXmlFileName () Returns ResultString

Returns the XML file name as a string.

readNumber () readNumber (self, OdIndex)

Returns ResultInt

readNumberArray () readNumberArray (self, index)

Returns ResultArrayInt

readString () readString (self, OdIndex)

Returns ResultString

readBytes () readBytes (self, OdIndex)

Returns ResultArrayByte

writeNumber () writeNumber (self, OdIndex, value)

Returns ResultVoid

writeBytes () writeBytes (self, OdIndex, data)

Returns ResultVoid Related Links OdIndex
7.19 ObjectEntry
This class represents an object entry of the object dictionary and has the following public member functions:

Version: doc 1.3.0 / NanoLib 1.2.0

29

7 Classes / functions reference

getName () Reads out the name of the object as a string.
getName (self)

getPrivate () Checks if the object is private.
getPrivate (self)

getIndex () Reads out the address of the object index.
getIndex (self)

getDataType () Reads out the data type of the object.
getDataType (self)

getObjectCode () Reads out the object code:

Null Deftype Defstruct Var Array Record

0x00 0x05 0x06 0x07 0x08 0x09

getObjectCode (self)

getObjectSaveable () Checks if the object is saveable and it's category (see product manual for more details): APPLICATION, COMMUNICATION, DRIVE, MISC_CONFIG, MODBUS_RTU, NO, TUNING, CUSTOMER, ETHERNET, CANOPEN, VERIFY1020, UNKNOWN_SAVEABLE_TYPE
getObjectSaveable (self)

getMaxSubIndex () Reads out the number of subindices supported by this object.
getMaxSubIndex (self)

getSubEntry () getSubEntry (self, subIndex)
See also ObjectSubEntry.

Version: doc 1.3.0 / NanoLib 1.2.0

30

7 Classes / functions reference

7.20 ObjectSubEntry
This class represents an object sub-entry (subindex) of the object dictionary and has the following public member functions:
getName () Reads out the name of the object as a string.
getName (self)

getSubIndex () Reads out the address of the subindex.
getSubIndex (self)

getDataType () Reads out the data type of the object.
getDataType (self)

getSdoAccess () Checks if the subindex is accessible via SDO:

ReadOnly

1

WriteOnly

2

ReadWrite

3

NoAccess

0

getSdoAccess (self)

getPdoAccess () Checks if the subindex is accessible/mappable via PDO:

Tx

1

Rx

2

TxRx

3

No

0

getPdoAccess (self)

getBitLength () Checks the subindex length.
getBitLength (self)

getDefaultValueAsNumeric () Reads out the default value of the subindex for numeric data types.
getDefaultValueAsNumeric(self, key)

Version: doc 1.3.0 / NanoLib 1.2.0

31

7 Classes / functions reference
getDefaultValueAsString () Reads out the default value of the subindex for string data types.
getDefaultValueAsString (self, key)
getDefaultValues () Reads out the default values of the subindex.
getDefaultValues (self)
readNumber () Reads out the numeric actual value of the subindex.
readNumber (self)
readString () Reads out the string actual value of the subindex.
readString (self)
readBytes () Reads out the actual value of the subindex in bytes.
readBytes (self)
writeNumber () Writes a numeric value in the subindex.
writeNumber (self, value)
writeBytes () Writes a value in the subindex in bytes.
writeBytes (self, data)
7.21 OdIndex
Use this class (immutable from creation on) to wrap and locate object directory indices / sub-indices. A device's OD has up to 65535 (0xFFFF) rows and 255 (0xFF) columns; with gaps between the discontinuous rows. See the CANopen standard and your product manual for more detail. getIndex () Reads out the index (from 0x0000 to 0xFFFF).
getIndex (self)

Version: doc 1.3.0 / NanoLib 1.2.0

32

7 Classes / functions reference

getSubindex () Reads out the sub-index (from 0x00 to 0xFF)
getSubIndex (self)

toString () Returns the index and subindex as a string. The string default 0xIIII:0xSS reads as follows:

 I = index from 0x0000 to 0xFFFF

 S = sub-index from 0x00 to 0xFF

std::string nlc::OdIndex::toString () const

toString (self)

Returns 0xIIII:0xSS

Default string representation

7.22 OdIndexVector
Helping class that creates a vector of OdIndex objects, to build an object dictionary.
7.23 OdLibrary
Use this programming interface to create instances of the ObjectDictionary class from XML. By assignObjectDictionary, you can then bind each instance to a specific device due to a uniquely created identifier. ObjectDictionary instances thus created are stored in the OdLibrary object to be accessed by index. The ODLibrary class loads ObjectDictionary items from file or array, stores them, and has the following public member functions:

getObjectDictionaryCount () getObjectDictionaryCount (self)

getObjectDictionary () getObjectDictionary (self, odIndex) Returns ResultObjectDictionary
addObjectDictionaryFromFile () addObjectDictionaryFromFile (self, absoluteXmlFilePath) Returns ResultObjectDictionary
addObjectDictionary () virtual ResultObjectDictionary addObjectDictionary (std::vector <uint8_t> const & odXmlData, const std::string &xmlFilePath = std::string ())
addObjectDictionary (self, odXmlData) Returns ResultObjectDictionary

Version: doc 1.3.0 / NanoLib 1.2.0

33

7 Classes / functions reference

7.24 OdTypesHelper
In addition to the following public member functions, this class contains custom data types. Note: To check your custom data types, open Nanolib.py and look for ObjectEntryDataType_ prefixes.

uintToObjectCode () Converts unsigned integers to object code:

Null Deftype Defstruct Var Array Record

0x00 0x05 0x06 0x07 0x08 0x09

uintToObjectCode (objectCode)

isNumericDataType () Informs if a data type is numeric or not.
isNumericDataType (dataType)

isDefstructIndex () Informs if an object is a definition structure index or not.
isDefstructIndex (typeNum)

isDeftypeIndex () Informs if an object is a definition type index or not.
isDeftypeIndex (typeNum)

isComplexDataType () Informs if a data type is complex or not.
isComplexDataType (dataType)

uintToObjectEntryDataType () Converts unsigned integers to OD data type.
uintToObjectEntryDataType (objectDataType)

objectEntryDataTypeToString () Converts OD data type to string.
objectEntryDataTypeToString (odDataType)

Version: doc 1.3.0 / NanoLib 1.2.0

34

7 Classes / functions reference

stringToObjectEntryDatatype () Converts string to OD data type if possible. Otherwise, returns UNKNOWN_DATATYPE.
stringToObjectEntryDatatype (dataTypeString)

objectEntryDataTypeBitLength () Informs on bit length of an object entry data type.
objectEntryDataTypeBitLength (dataType)

7.25 RESTfulBus struct

This struct contains the communication configuration options for the RESTful interface (over Ethernet). It contains the following public attributes:

const std::string const unsigned long const std::string const unsigned long const std::string const unsigned long

CONNECT_TIMEOUT_OPTION_NAME = "RESTful Connect Timeout" DEFAULT_CONNECT_TIMEOUT = 200 REQUEST_TIMEOUT_OPTION_NAME = "RESTful Request Timeout" DEFAULT_REQUEST_TIMEOUT = 200 RESPONSE_TIMEOUT_OPTION_NAME = "RESTful Response Timeout" DEFAULT_RESPONSE_TIMEOUT = 750

7.26 ProfinetDCP

Under Linux, the calling application needs CAP_NET_ADMIN and CAP_NET_RAW capabilities. To enable: sudo setcap 'cap_net_admin,cap_net_raw+eip' ./executable. In Windows, the ProfinetDCP interface uses WinPcap (tested with version 4.1.3) or Npcap (tested with versions 1.60 and 1.30). It thus searches the dynamically loaded wpcap.dll library in the following order (Note: no current Win10Pcap support):
1. Nanolib.dll directory 2. Windows system directory SystemRoot%\System32 3. Npcap installation directory SystemRoot%\System32\Npcap 4. Environment path
This class represents a Profinet DCP interface and has the following public member functions:

getScanTimeout () Informs on a device scan timeout (default = 2000 ms).
getScanTimeout (self)

setScanTimeout () Sets a device scan timeout (default = 2000 ms).
setScanTimeout (self, timeoutMsec)

getResponseTimeout () Informs on a device response timeout for setup, reset and blink operations (default = 1000 ms).
getResponseTimeout (self)

Version: doc 1.3.0 / NanoLib 1.2.0

35

7 Classes / functions reference

setResponseTimeout () Informs on a device response timeout for setup, reset and blink operations (default = 1000 ms).
setResponseTimeout (self, timeoutMsec)

isServiceAvailable () Use this function to check Profinet DCP service availability.  Network adapter validity / availability  Windows: WinPcap / Npcap availability  Linux: CAP_NET_ADMIN / CAP_NET_RAW capabilities
isServiceAvailable (self, busHardwareId)

Parameters BusHardwareId Returns true
false

Hardware ID of Profinet DCP service to check. Service is available. Service is unavailable.

scanProfinetDevices () Use this function to scan the hardware bus for the presence of Profinet devices.
scanProfinetDevices (self, busHardwareId)

Parameters BusHardwareId Returns ResultProfinetDevices

Specifies each fieldbus to open. Hardware is open.

setupProfinetDevice () Establishes the following device settings:

 Device name

 IP address

 Network mask

 Default gateway

setupProfinetDevice (self, busHardwareId, profinetDevice, savePermanent)

resetProfinetDevice () Stops the device and resets it to factory defaults.
resetProfinetDevice (self, busHardwareId, profinetDevice)

blinkProfinetDevice () Commands the Profinet device to start blinking its Profinet LED.
blinkProfinetDevice (self, busHardwareId, profinetDevice)

validateProfinetDeviceIp () Use this function to check device's IP address.
validateProfinetDeviceIp (self, busHardwareId, profinetDevice)

Parameters BusHardwareId ProfinetDevice

Specifies the hardware ID to check. Specifies the Profinet device to validate.

Version: doc 1.3.0 / NanoLib 1.2.0

36

7 Classes / functions reference

Returns ResultVoid

7.27 ProfinetDevice struct

The Profinet device data have the following public attributes:

std::string std::string std::array< uint8_t, 6 > uint32_t uint32_t uint32_t

deviceName deviceVendor macAddress ipAddress netMask defaultGateway

The MAC address is provided as array in format macAddress = {xx, xx, xx, xx, xx, xx}; whereas IP address, network mask and gateway are all interpreted as big endian hex numbers, such as:

IP address: 192.168.0.2 Network mask: 255.255.0.0 Gateway: 192.168.0.1

0xC0A80002 0xFFFF0000 0xC0A80001

7.28 Result classes

Use the "optional" return values of these classes to check if a function call had success or not, and also locate the fail reasons. On success, the hasError () function returns false. By getResult (), you can read out the result value as per type (ResultInt etc.). If a call fails, you read out the reason by getError ().

Protected attributes

string NlcErrorCode uint32_t

errorString errorCode exErrorCode

Also, this class has the following public member functions:

hasError () Reads out a function call's success.
hasError (self)

Returns

true false

Failed call. Use getError () to read out the value. Sucessful call. Use getResult () to read out the value.

getError () Reads out the reason if a function call fails.
getError (self)

Returns const string

getErrorCode () Read the NlcErrorCode.
getErrorCode (self)

Version: doc 1.3.0 / NanoLib 1.2.0

37

7 Classes / functions reference
getExErrorCode () uint32_t getExErrorCode () const
getExErrorCode (self)
7.28.1 ResultVoid
NanoLib sends you an instance of this class if the function returns void. The class inherits the public functions and protected attributes from the result class
7.28.2 ResultInt
NanoLib sends you an instance of this class if the function returns an integer. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Returns the integer result if a function call had success.
getResult (self)
Returns
7.28.3 ResultString
NanoLib sends you an instance of this class if the function returns a string. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the string result if a function call had success.
getResult (self)
Returns const string
7.28.4 ResultArrayByte
NanoLib sends you an instance of this class if the function returns a byte array. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the byte vector if a function call had success.
getResult (self)
Returns const vector<uint8_t>
7.28.5 ResultArrayInt
NanoLib sends you an instance of this class if the function returns an integer array. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the integer vector if a function call had success.
getResult (self)
Returns const vector<uint64_t>

Version: doc 1.3.0 / NanoLib 1.2.0

38

7 Classes / functions reference
7.28.6 ResultBusHwIds
NanoLib sends you an instance of this class if the function returns a bus hardware ID array. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the bus-hardware-ID vector if a function call had success.
getResult (self)
Parameters const vector<BusHardwareId>
7.28.7 ResultDeviceId
NanoLib sends you an instance of this class if the function returns a device ID. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the device ID vector if a function call had success.
getResult (self)
Returns const vector<DeviceId>
7.28.8 ResultDeviceIds
NanoLib sends you an instance of this class if the function returns a device ID array. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Returns the device ID vector if a function call had success.
getResult (self)
Returns const vector<DeviceId>
7.28.9 ResultDeviceHandle
NanoLib sends you an instance of this class if the function returns the value of a device handle. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the device handle if a function call had success.
getResult (self)
Returns DeviceHandle
7.28.10 ResultObjectDictionary
NanoLib sends you an instance of this class if the function returns the content of an object dictionary. The class inherits the public functions / protected attributes from the result class and has the following public member functions:

Version: doc 1.3.0 / NanoLib 1.2.0

39

7 Classes / functions reference

getResult () Reads out the device ID vector if a function call had success.
getResult (self)

Returns

const vector<ObjectDictionary>

7.28.11 ResultConnectionState
NanoLib sends you an instance of this class if the function returns a device-connection-state info. The class inherits the public functions / protected attributes from the result class and has the following public member functions:

getResult () Reads out the device handle if a function call had success.
getResult (self)

Returns DeviceConnectionStateInfo Connected / Disconnected / ConnectedBootloader
7.28.12 ResultObjectEntry
NanoLib sends you an instance of this class if the function returns an object entry. The class inherits the public functions / protected attributes from the result class and has the following public member functions:

getResult () Returns the device ID vector if a function call had success.
getResult (self)

Returns const ObjectEntry

7.28.13 ResultObjectSubEntry
NanoLib sends you an instance of this class if the function returns an object sub-entry. The class inherits the public functions / protected attributes from the result class and has the following public member functions:

getResult () Returns the device ID vector if a function call had success.
getResult (self)

Returns const ObjectSubEntry
7.28.14 ResultProfinetDevices
NanoLib sends you an instance of this class if the function returns a Profinet device. The class inherits the public functions / protected attributes from the result class and has the following public member functions:

getResult () Reads out the Profinet device vector if a function call had success.
getResult (self)

Version: doc 1.3.0 / NanoLib 1.2.0

40

7 Classes / functions reference

7.28.15 ResultSampleDataArray
NanoLib sends you an instance of this class if the function returns a sample data array. The class inherits the public functions / protected attributes from the result class and has the following public member functions:
getResult () Reads out the data array if a function call had success.
getResult (self)

7.28.16 ResultSamplerState
NanoLib sends you an instance of this class if the function returns a sampler state.This class inherits the public functions / protected attributes from the result class and has the following public member functions:

getResult () Reads out the sampler state vector if a function call had success.
getResult (self)

Returns SamplerState>

Unconfigured / Configured / Ready / Running / Completed / Failed / Cancelled

7.29 NlcErrorCode

If something goes wrong, the result classes report one of the error codes listed in this enumeration.

Error code Success GeneralError BusUnavailable CommunicationError ProtocolError
ODDoesNotExist ODInvalidAccess ODTypeMismatch OperationAborted OperationNotSupported InvalidOperation
InvalidArguments AccessDenied

C: Category  D: Description  R: Reason C: None. D: No error. R: The operation completed successfully.
C: Unspecified. D: Unspecified error. R: Failure that fits no other category.
C: Bus. D: Hardware bus not available. R: Bus inexistent, cut-off or defect.
C: Communication. D: Communication unreliable. R: Unexpected data, wrong CRC, frame or parity errors, etc.
C: Protocol. D: Protocol error. R: Response after unsupported protocol option, device report unsupported protocol, error in the protocol (say, SDO segment sync bit), etc. R: A response or device report to unsupported protocol (options) or to errors in protocol (say, SDO segment sync bit), etc. R: Unsupported protocol (options) or error in protocol (say, SDO segment sync bit), etc.
C: Object dictionary. D: OD address inexistent. R: No such address in the object dictionary.
C: Object dictionary. D: Access to OD address invalid. R: Attempt to write a read-only, or to read from a write-only, address.
C: Object dictionary. D: Type mismatch. R: Value unconverted to specified type, say, in an attempt to treat a string as a number.
C: Application. D: Process aborted. R: Process cut by application request. Returns only on operation interrupt by callback function, say, from bus-scanning.
C: Common. D: Process unsupported. R: No hardware bus / device support.
C: Common. D: Process incorrect in current context, or invalid with current argument. R: A reconnect attempt to already connected buses / devices. A disconnect attempt to already disconnected ones. A bootloader operation attempt in firmware mode or vice versa.
C: Common. D: Argument invalid. R: Wrong logic or syntax.
C: Common. D: Access is denied. R: Lack of rights or capabilities to perform the requested operation.

Version: doc 1.3.0 / NanoLib 1.2.0

41

7 Classes / functions reference

Error code ResourceNotFound
ResourceUnavailable OutOfMemory
TimeOutError

C: Category  D: Description  R: Reason C: Common. D: Specified item not found. R: Hardware bus, protocol, device, OD address on device, or file was not found.
C: Common. D: Specified item not found. R: busy, inexistent, cut-off or defect.
C: Common. D: Insufficient memory. R: Too little memory to process this command.
C: Common. D: Process timed out. R: Return after time-out expired. Timeout may be a device response time, a time to gain shared or exclusive resource access, or a time to switch the bus / device to a suitable state.

7.30 NlcCallback
This parent class for callbacks has the following public member function:

callback () callback (self)

Returns

ResultVoid

7.31 NlcDataTransferCallback
Use this callback class for data transfers (firmware update, NanoJ upload etc.). 1. For a firmware upload: Define a "co-class" extending this one with a custom callback method
implementation. 2. Use the "co-class's" instances in NanoLibAccessor.uploadFirmware () calls. The main class itself has the following public member function:

callback () callback (self)

Returns

ResultVoid

7.32 NlcScanBusCallback
Use this callback class for bus scanning. 1. Define a "co-class" extending this one with a custom callback method implementation. 2. Use the "co-class's" instances in NanoLibAccessor.scanDevices () calls. The main class itself has the following public member function.

callback () callback (self, info, devicesFound, data)

Returns ResultVoid

7.33 NlcLoggingCallback
Use this callback class for logging callbacks. 1. Define a class that extends this class with a custom callback method implementation

Version: doc 1.3.0 / NanoLib 1.2.0

42

7 Classes / functions reference

2. Use a pointer to its instances in order to set a callback by NanoLibAccessor > setLoggingCallback (...).
callback (self, payload_str, formatted_str, logger_name, log_level, time_since_epoch, thread_id)

callback (self, payload_str, formatted_str, logger_name, log_level, time_since_epoch, thread_id)

7.34 SamplerInterface
Use this class to configure, start and stop the sampler, or to get sampled data and fetch a sampler's status or last error. The class has the following public member functions.

configure () Configures a sampler.
configure(self, deviceHandle, samplerConfiguration)

Parameters [in] deviceHandle [in] samplerConfiguration
Returns ResultVoid

Specifies what device to configure the sampler for. Specifies the values of configuration attributes. Confirms that a void function has run.

getData () Gets the sampled data.
getData(self, deviceHandle)
Parameters [in] deviceHandle Returns ResultSampleDataArray

Specifies what device to get the data for.
Delivers the sampled data, which can be an empty array if samplerNotify is active on start.

getLastError () Gets a sampler's last error.
getLastError(self, deviceHandle)

Returns ResultVoid

Confirms that a void function has run.

getState () Gets a sampler's status.
getState(self, deviceHandle)
Returns ResultSamplerState

Delivers the sampler state.

start () Starts a sampler.
start(self, deviceHandle, samplerNotify, applicationData)

Parameters [in] deviceHandle

Specifies what device to start the sampler for.

Version: doc 1.3.0 / NanoLib 1.2.0

43

7 Classes / functions reference

[in] SamplerNotify [in] applicationData
Returns ResultVoid

Specifies what optional info to report (can be nullptr).
Option: Forwards application-related data (a user-defined 8-bit array of value / device ID / index, or a datetime, a variable's / function's pointer, etc.) to samplerNotify.
Confirms that a void function has run.

stop () Stops a sampler.
stop(self, deviceHandle)

Parameters [in] deviceHandle Returns ResultVoid

Specifies what device to stop the sampler for. Confirms that a void function has run.

7.35 SamplerConfiguration struct

This struct contains the data sampler's configuration options (static or not).

Public attributes

std::vector <OdIndex> trackedAddresses

Up to 12 OD addresses to be sampled.

uint32_t

version

A structure's version.

uint32_t

durationMilliseconds

Sampling duration in ms, from 1 to 65535

uint16_t

periodMilliseconds

Sampling period in ms.

uint16_t

numberOfSamples

Samples amount.

uint16_t

preTriggerNumberOfSamples

Samples pre-trigger amount.

bool

usingSoftwareImplementation

Use software implementation.

bool

usingNewFWSamplerImplementation Use FW implementation for devices with a

FW version v24xx or newer.

SamplerMode

mode

Normal, repetitive or continuous sampling.

SamplerTriggerCondition triggerCondition

Start trigger conditions: TC_FALSE = 0x00 TC_TRUE = 0x01 TC_SET = 0x10 TC_CLEAR = 0x11 TC_RISING_EDGE = 0x12 TC_FALLING_EDGE = 0x13 TC_BIT_TOGGLE = 0x14 TC_GREATER = 0x15 TC_GREATER_OR_EQUAL = 0x16 TC_LESS = 0x17 TC_LESS_OR_EQUAL = 0x18 TC_EQUAL = 0x19 TC_NOT_EQUAL = 0x1A TC_ONE_EDGE = 0x1B TC_MULTI_EDGE = 0x1C, OdIndex, triggerValue

SamplerTrigger

SamplerTrigger

A trigger to start a sampler?

Static public attributes
static constexpr size_t SAMPLER_CONFIGURATION_VERSION = 0x01000000 static constexpr size_t MAX_TRACKED_ADDRESSES = 12

Version: doc 1.3.0 / NanoLib 1.2.0

44

7 Classes / functions reference

7.36 SamplerNotify
Use this class to activate sampler notifications when you start a sampler. The class has the following public member function.

notify () Delivers a notification entry.
notify(self, lastError, samplerState, sampleDatas, applicationData)

Parameters [in] lastError [in] samplerState
[in] sampleDatas [in] applicationData

Reports the last error occurred while sampling. Reports the sampler status at notification time: Unconfigured / Configured / Ready / Running / Completed / Failed / Cancelled. Reports the sampled-data array. Reports application-specific data.

7.37 SampleData struct

This struct contains the sampled data.

uin64_t iterationNumber

Starts at 0 and only increases in repetitive mode.

std::vector<SampledValues> Contains he array of sampled values.

7.38 SampledValue struct

This struct contains the sampled values.

in64_t value uin64_t CollectTimeMsec

Contains the value of a tracked OD address.
Contains the collection time in milliseconds, relative to the sample beginning.

7.39 SamplerTrigger struct

This struct contains the trigger settings of the sampler.

SamplerTriggerCondition condition
OdIndex uin32_t value

The trigger condition:TC_FALSE = 0x00 TC_TRUE = 0x01 TC_SET = 0x10 TC_CLEAR = 0x11 TC_RISING_EDGE = 0x12 TC_FALLING_EDGE = 0x13 TC_BIT_TOGGLE = 0x14 TC_GREATER = 0x15 TC_GREATER_OR_EQUAL = 0x16 TC_LESS = 0x17 TC_LESS_OR_EQUAL = 0x18 TC_EQUAL = 0x19 TC_NOT_EQUAL = 0x1A TC_ONE_EDGE = 0x1B TC_MULTI_EDGE = 0x1C
The trigger's OdIndex (address).
Condition value or bit number (starting from bit zero).

7.40 Serial struct
Find here your serial communication options and the following public attributes:

Version: doc 1.3.0 / NanoLib 1.2.0

45

7 Classes / functions reference

:string SerialBaudRate string SerialParity

BAUD_RATE_OPTIONS_NAME = "serial baud rate" baudRate =SerialBaudRate struct PARITY_OPTIONS_NAME = "serial parity" parity = SerialParity struct

7.41 SerialBaudRate struct

Find here your serial communication baud rate and the following public attributes:

string string string string string string string string string string

BAUD_RATE_7200 = "7200" BAUD_RATE_9600 = "9600" BAUD_RATE_14400 = "14400" BAUD_RATE_19200 = "19200" BAUD_RATE_38400 = "38400" BAUD_RATE_56000 = "56000" BAUD_RATE_57600 = "57600" BAUD_RATE_115200 = "115200" BAUD_RATE_128000 = "128000" BAUD_RATE_256000 = "256000"

7.42 SerialParity struct

Find here your serial parity options and the following public attributes:

string string string string string

NONE = "none" ODD = "odd" EVEN = "even" MARK = "mark" SPACE = "space"

Version: doc 1.3.0 / NanoLib 1.2.0

46

8 Licenses

8 Licenses

NanoLib API interface and example source code are licensed by Nanotec Electronic GmbH & Co. KG under the Creative Commons Attribution 3.0 Unported License (CC BY). Library parts provided in binary format (core and fieldbus communication libraries) are licensed under the Creative Commons AttributionNoDerivatives 4.0 International License (CC BY ND).

Creative Commons
The following human-readable summary won't substitute the license(s) itself. You can find the respective license at creativecommons.org and linked below. You are free to:

CC BY 3.0
 Share: See right.  Adapt: Remix, transform, and build upon the
material for any purpose, even commercially.

CC BY-ND 4.0
 Share: Copy and redistribute the material in any medium or format.

The licensor cannot revoke the above freedoms as long as you obey the following license terms:

CC BY 3.0

CC BY-ND 4.0

 Attribution: You must give appropriate credit,  Attribution: See left. But: Provide a link to this

provide a link to the license, and indicate if

other license.

changes were made. You may do so in any

 No derivatives: If you remix, transform, or build

reasonable manner, but not in any way that sug-

upon the material, you may not distribute the

gests the licensor endorses you or your use.

modified material.

 No additional restrictions: You may not apply  No additional restrictions: See left. legal terms or technological measures that legally

restrict others from doing anything the license

permits.

Note: You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
Note: No warranties given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

Version: doc 1.3.0 / NanoLib 1.2.0

47

9 Imprint, contact, versions

9 Imprint, contact, versions

©2024 Nanotec Electronic GmbH & Co.KGKapellenstr.685622 FeldkirchenGermanyTel.+49(0) 89 900 686-0Fax+49(0)89 900 686-50info@nanotec.dewww.nanotec.comAll rights reserved. Error, omission, technical or content change possible without notice. Quoted brands/products are trademarks of their owners and to be treated as such. Original version.

Document 1.3.0 2024.09 1.2.3 2024.07 1.2.2 2024.05 1.2.1 2024.04 1.2.0 2024.02
1.1.1 2022.09 1.1.0 2022.08

+ Added  > Changed  # Fixed
+ NanoLib-CANopen: Support for Peak PCAN-USB adapter (IPEH-002021/002022).
> NanoLib Core: Changed logging callback interface (LogLevel replaced by LogModule). # NanoLib Logger: Separation between core and modules has been corrected. # Modbus TCP: Fixed firmware update for FW4. # EtherCAT: Fixed NanoJ program upload for Core5. # EtherCAT: Fixed firmware update for Core5.
# Modbus RTU: Fixed timing issues with low baud rates during firmware update. # RESTful: Fixed NanoJ program upload.
# NanoLib Modules Sampler: Correct reading of sampled boolean values.
+ Java 11 support for all platforms. + Python 3.11/3.12 support for all platforms. + New logging callback interface (see examples). + Callback sinks for NanoLib Logger. > Update logger to version 1.12.0. > NanoLib Modules Sampler: Support now for Nanotec controller firmware v24xx. > NanoLib Modules Sampler: Change in structure used for sampler configuration. > NanoLib Modules Sampler: Continuous mode is synonymous with endless; the trigger condition is checked once; the number of samples must be 0. > NanoLib Modules Sampler: Normal priority for the thread that collects data in firmware mode. > NanoLib Modules Sampler: Rewritten algorithm to detect transition between Ready & Running state. # NanoLib Core: No more Access Violation (0xC0000005) on closing 2 or more devices using the same bus hardware. # NanoLib Core: No more Segmentation Fault on attaching a PEAK adapter under Linux. # NanoLib Modules Sampler: Correct sampled-values reading in firmware mode. # NanoLib Modules Sampler: Correct configuration of 502X:04. # NanoLib Modules Sampler: Correct mixing of buffers with channels. # NanoLib-Canopen: Increased CAN timeouts for robustness and correct scanning at lower baudrates. # NanoLib-Modbus: VCP detection algorithm for special devices (USB-DA-IO).
+ EtherCAT support. # NanoLib-Modbus: scanDevice for ModbusTCP protocol returns an error when nonModbusTCP devices are present on the bus.
+ getDeviceHardwareGroup (). + getProfinetDCP (isServiceAvailable). + getProfinetDCP (validateProfinetDeviceIp). + autoAssignObjectDictionary (). + getXmlFileName (). + const std::string & xmlFilePath in addObjectDictionary (). + getSamplerInterface (). + rebootDevice (). + Error code ResourceUnavailable for getDeviceBootloaderVersion (), ~VendorId (), ~HardwareVersion (), ~SerialNumber, and ~Uid. > firmwareUploadFromFile now uploadFirmwareFromFile (). > firmwareUpload () now uploadFirmware (). > bootloaderUploadFromFile () now uploadBootloaderFromFile ().

Product 1.2.0 1.1.3
1.1.2 1.1.1 1.1.0
1.0.1 (B349) 1.0.0

Version: doc 1.3.0 / NanoLib 1.2.0

48

9 Imprint, contact, versions

Document
1.0.2 2022.03 1.0.1 2021.11 1.0.0 2021.06

+ Added  > Changed  # Fixed > bootloaderUpload () now uploadBootloader (). > bootloaderFirmwareUploadFromFile () to uploadBootloaderFirmwareFromFile (). > bootloaderFirmwareUpload () now uploadBootloaderFirmware (). > nanojUploadFromFile () now uploadNanoJFromFile (). > nanojUpload () now uploadNanoJ (). > objectDictionaryLibrary () now getObjectDictionaryLibrary (). > String_String_Map now StringStringMap. > NanoLib-Common: faster execution of listAvailableBusHardware and openBusHardwareWithProtocol with Ixxat adapter. > NanoLib-CANopen: default settings used (1000k baudrate, Ixxat bus number 0) if bus hardware options empty. > NanoLib-RESTful: admin permission obsolete for communication with Ethernet bootloaders under Windows if npcap / winpcap driver is available. # NanoLib-CANopen: bus hardware now opens crashless with empty options. # NanoLib-Common: openBusHardwareWithProtocol () with no memory leak now.
+ Python 3.10 / Linux ARM64 support. + USB mass storage / REST / Profinet DCP support. + checkConnectionState (). + getDeviceBootloaderVersion (). + ResultProfinetDevices. + NlcErrorCode (replaced NanotecExceptions). + NanoLib Modbus: VCP / USB hub unified to USB. # Modbus TCP scanning returns results. # Modbus TCP communication latency remains constant.
+ More ObjectEntryDataType (complex and profile-specific). + IOError return if connectDevice and scanDevices find none. + Only 100 ms nominal timeout for CanOpen / Modbus. + OdTypesHelper class.
Edition.

Product
0.8.0 0.7.1 0.7.0

Version: doc 1.3.0 / NanoLib 1.2.0

49



References

Apache FOP Version 2.1 DITA Open Toolkit