gpio.
gpio.ipCore gpio.ipCore: Manual Copyright © 2015 taskit GmbH All rights to this documentation and to the product(s) described herein are reserved by taskit GmbH. This document was written with care, but errors cannot be excluded. Neither the company named above nor the seller assumes legal liability for mistakes, resulting operational errors or the consequences thereof. Trademarks, company names and product names may be protected by law.
gpio.ipCore Table of Contents 1. Overview ...................................................................................................................... 1 2. Commissioning ............................................................................................................ 2 2.1. RS485 ................................................................................................................ 2 2.2. USB .....................................................................................
gpio.ipCore List of Figures 4.1. Internal structure .....................................................................................................
gpio.ipCore List of Tables 2.1. 4.1. 5.1. 7.1. 7.2. 7.3. Default login information ......................................................................................... 2 Extensions to the LUA language on gpio.ipCore ...................................................... 7 MBTCP configuration ............................................................................................. 10 Electrical charachteristics ......................................................................................
Overview 1. Overview The gpio.ipcore forms the interface of the GPIO system in an IP network. Along with its function as a gateway between several GPIO Modbus devices and network applications on the basis of HTTP-REST protocols, the ipCore offers a flexible script interface which allows to monitor and control the Modbus hardware connected. Both together turn the device into an independent IO controller on which it is easy to implement processes thanks to simple programmability.
Commissioning 2. Commissioning Power is supplied via a 5V USB unit which is connected to micro USB port X14 (between the two DSUBs). The ipCore can provide supply for modules at the RS485 bus. Here, the maximum current that can be supplied via the power supply unit must be taken into account. After deduction of the own consumption of max. 1W@5V, 1800mA will remain in a 2A power supply unit for the IO cards connected. 2.1.
Commissioning Run the command "passwd" to set a new password for root. It asks the user to enter the old and the new password. Afterwards - before any change is done - you need to repeat the new password. All following SSH login attempts are checked against the new password. This does not change the default password for the REST interface! See Chapter 6, Restinio for details about that interface.
REST interface 3. REST interface The gpio.ipCore is accessed by HTTP GET, PUT or POST commands. The URL used either directly describes a Modbus resource (http://ipcore.local/gpio/...) or a key in the database (http://ipcore.local/shared/...). Data is transmitted in JSON format. 3.1. Example 1: Access a card at the RS485 Modbus Let's assume several gpio.net cards at the bus. Address 5 is a gpio.relay card.
Scripting 4. Scripting The behaviour of the gpio.ipCore can be automated through scripts. In the process, the database (Redis), and Modbus and the REST servers form uniform interfaces. Supported scripting languages are Lua, Python and JavaScript. Figure 4.1, “Internal structure” shows the interaction of the components involved. [[RS485] RS485] … … [[USB1] USB1] … … [[USB2] USB2] … … „ RS485“ /et c/m bt cp.
Scripting Python, Lua or NodeJS scripts are saved in directory “/var/ipcore/”. It is recommended to create a separate subdirectory for each script. cd /var/ipcore mkdir myscript cd myscript vim myscript.py chmod +x myscript.py The following scripts are examples of this: 4.1. LUA The following script searches for a gpio.AI module in all buses available and continuously records measurements issued by the standard output. #! /usr/bin/lem /etc/mbtcp.conf --[[ 1. Look for a gpio.AI module on all busses 2.
Scripting if ret == 0 then -- output data as mV for i = 1, #v, 1 do io.write(string.format("%7.2f end io.write("\r") io.flush() else print("ERROR: " .. ret) end ", v[i]*4096/65535)) -- sleep 1 second lem.sleep_msec(1000) end The Lua interpreter has been expanded by various functions for easy access to the Modbus hardware. Table 4.1, “Extensions to the LUA language on gpio.ipCore” provides information on the functions added by taskit GmbH. Function definition Signature Description name = lem.
Scripting Function definition Signature Description bus_list = tml.get_busses() nil -> table Returns a list of available Modbus server connections as table of strings. Those strings are used as bus parameter in all tml.* commands. Table 4.1. Extensions to the LUA language on gpio.ipCore 4.2. Python In this example, a digital input and a relay of the gpio.relay card is connected to the internal database. These can then be used via the REST interface on URL “http:// ipcore.
Scripting The script is now executed promptly and after each start of the system. Should it crash for any reason, it will be restarted. Here, there is a pause of one second to prevent a system from being blocked due to an erroneous script. The script can be stopped via “svc –d / service/myscript” and be restarted via “svc –u /service/myscript”.
Modbus server (MBTCP) 5. Modbus server (MBTCP) For each of the ipCore's serial ports - including the two USB hosts - an instance of the Modbus TCP server (MBTCP) can be launched. The server manages access to the devices that are attached to its related serial port. It configures the hardware, queques requests and finally submits the results to their originators. MBTCP provides a standard Modbus TCP and an ASCII connection for debugging and simple programs that do not need the Modbus TCP stack.
Restinio 6. Restinio Restinio is an optional service that provides the REST interfaces to Modbus and the Redis database. It is launched by default and can be stopped or restarted just like user defined scripts using the svc command. The link to its run script resides in "/service/restinio". During normal operation, Restinio does background scans of the connected Modbus devices. Thus, the REST interface offers a plug'n'play mechanism.
Technical data 7. Technical data Specification Value Unit Power supply 5 V Power consumption <700 Operating temperature -30 .. +85 a mW ab °C The buzzer is limited to -20 .. +70 °C but unused. b SD card socket is limited to -25 .. +85 °C. Table 7.1. Electrical charachteristics 7.1. Modbus port MBTCP system uses this port as configured in "/etc/mbtcp.conf" section [RS485].