• contactus@avvero.com
  • +61 2 9060 2210
Search
AVVERO Solutions
AVVERO SolutionsAVVERO Solutions
MENUMENU
  • Home
  • Products
        • Industrial router with interfaces expanded
        • Routers & Gateways
          • IoT/Smart Gateways
          • Industrial Ethernet Routers
          • Vehicle Routers
          • EN50155 Railway Routers
        • Antennas
          • Cellular / Mobile Antennas
          • WiFi Antennas
          • Vehicle Antennas
        • Switches
          • 10 port Ethernet switch
        • Cables & Accessories
          • Antenna Cables
          • Antenna Arrestors
          • M12 Cable
        • Industrial Power
          • AC/DC Power Supply
          • DC/DC Power Backup
        • Software
          • Device Management
  • Solutions
        • Industry
          • Advertising
          • Mining
          • Railway
          • Telecommunications
        • Hardware
          • Custom Enclosures
        • Network Operator
          • LTE-Advanced Network
        • Technology
          • Dedicated Bearer
          • Mobile IP
          • Multiple PDN
          • Network Redundancy
          • Network Time Protocol
          • VPN
          • Zero-Touch Deployment
  • About
  • Support
        • Knowledge BaseBusiness and technical white papers, tutorials, tech tips, and more.
        • Technical NewsTechnology and industry trends, and best practices.
        • Submit RMARequest for a replacement and Returns Material Authorization (RMA)
  • Contact
MENUMENU
  • Home
  • Products
        • Industrial router with interfaces expanded
        • Routers & Gateways
          • IoT/Smart Gateways
          • Industrial Ethernet Routers
          • Vehicle Routers
          • EN50155 Railway Routers
        • Antennas
          • Cellular / Mobile Antennas
          • WiFi Antennas
          • Vehicle Antennas
        • Switches
          • 10 port Ethernet switch
        • Cables & Accessories
          • Antenna Cables
          • Antenna Arrestors
          • M12 Cable
        • Industrial Power
          • AC/DC Power Supply
          • DC/DC Power Backup
        • Software
          • Device Management
  • Solutions
        • Industry
          • Advertising
          • Mining
          • Railway
          • Telecommunications
        • Hardware
          • Custom Enclosures
        • Network Operator
          • LTE-Advanced Network
        • Technology
          • Dedicated Bearer
          • Mobile IP
          • Multiple PDN
          • Network Redundancy
          • Network Time Protocol
          • VPN
          • Zero-Touch Deployment
  • About
  • Support
        • Knowledge BaseBusiness and technical white papers, tutorials, tech tips, and more.
        • Technical NewsTechnology and industry trends, and best practices.
        • Submit RMARequest for a replacement and Returns Material Authorization (RMA)
  • Contact

Access to the digital I/Os via Modbus TCP

  • Home
  • Access to the digital I/Os via Modbus TCP

NetModule

  • Enable advanced logging on the Mobile interface

SDK

  • Access to the digital I/Os via Modbus TCP

Firmware

  • How to upgrade Firmware on my u-blox TOBY-L280 module

Howto

  • Enable SSH root access
  • System firmware update (CLI)
  • Home
  • Support
  • SDK
  • Access to the digital I/Os via Modbus TCP

Access to the digital I/Os via Modbus TCP

This document provides a sample configuration on how to configure the digital inputs on the router to mirror the digital relay outputs on a remote router.

Initial Setup

Save a copy of the script-dio-mirror for both the local and remote

Local Router

PORT the UDP port of the remote router
REMOTE the remote router IP address
FREQ the frequency in seconds to send updates to the remote router

/* 
 * Copyright (C) 2019 AVVERO
 */

PORT = 6666;
REMOTE = "172.30.6.110";
FREQ = 1;

sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock < 0) {
    nb_syslog("Unable to open socket\n");
    exit(1);
}

ret = bind(sock, PORT, "");
if(ret == -1) {
    nb_syslog("Unable to bind to port: %d\n", PORT);
    close(sock);
    exit(1);
}

nb_syslog("Sending messages on port %d\n", PORT);

for(;;)
{
    sleep(FREQ);
    MSG = sprintf("in1=%d in2=%d out1=%d out2=%d",
         nb_dio_get("in1"),
         nb_dio_get("in2"),
         nb_dio_get("out1"),
         nb_dio_get("out2"));

    if (sendto(sock, MSG, REMOTE, PORT) != strlen(MSG))
        nb_syslog("ERROR: UDP GPIO message failed");	
}

Remote Router

PORT the UDP port of the remote router

  /* 
   * Copyright (C) 2019 AVVERO
   */

  PORT = 6666;

  sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if (sock < 0) {
      nb_syslog("Unable to open socket\n");
      exit(1);
  }

  ret = bind(sock, PORT, "");
  if(ret == -1) {
      nb_syslog("Unable to bind to port: %d\n", PORT);
      close(sock);
      exit(1);
  }

  nb_syslog("Listening for messages on port %d\n", PORT);

  while (1) {
      msg = recvfrom(sock);
      if (msg != "") {
    ret = (int) strstr(msg, "in1");
    state  = (int) substr(msg, (ret+4), 1);
    cin1 = nb_dio_get("out1");
      if (state != cin1) {
              nb_dio_set("out1", state);
              nb_syslog("Digital Relay = %s",state);
    }
    ret = (int) strstr(msg, "in2");
    state  = (int) substr(msg, (ret+4), 1);
      cin2 = nb_dio_get("out2");
      if (state != cin2) {
              nb_dio_set("out2", state);
              nb_syslog("Digital Relay = %s",state);
      }
      }
}
  close(sock);
  exit(0);
Share This Article :
  • Twitter
  • LinkedIn
Still stuck? How can we help?

How can we help?

AVVERO Solutions © Copyright 2019. All Rights Reserved.
Tell us about your network's unique requirements

[wpforms id=”2600″]