Modbus Configurator: Protocol switching utility

Software for easy switching between protocols in our devices. Mainly between Spinel and ModBus RTU. Apart from switching, this little utility can also search and set-up communication parameters of Papouch devices. 

Tip: Below are also Python scripts for protocol switching.

Features and functions

  • Easy switching between protocols Spinel and ModBus RTU
  • Easy changing device's address
  • Communication parameters setup
  • Supports RS232/485/422, USB and Ethernet connections.
  • Searching function: Tries all commuication parameters on all available COM ports to find your device.

Modbus Configurator

Main window after the connection is established.

How to switch Modbus RTU and Spinel protocols using Python?

The scripts below first read the name and version from the device, then enable the configuration, and finally switch to the desired protocol. The scripts are designed for Python3 or higher.

In both cases, you must first adjust the serial port path and communication speed according to your device. Our devices with serial port have a default communication speed 9600 Bd, devices with USB or Ethernet have a default speed 115200 Bd. You can easily find the path to the serial port using, for example this command: python3 -m serial.tools.list_ports -v The examples are for devices with a default address of 0x31.

Script for switching from Spinel to Modbus:

# If you get error message "ImportError: no module named serial", pySerial module is not installed.
# Install the module as follows (for Debian/Ubuntu): 
# sudo apt install python3-serial
import serial

# Edit the following lines according to your communication interface
com_port = serial.Serial(port='/dev/ttyUSB1', baudrate=115200, timeout=.5)
# com_port = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=.5)

if com_port.isOpen():
# show Spinel device info
  #com_port.write('*B1?\r'.encode('utf-8'))                 # in ASCII format 66
  com_port.write(b'\x2a\x61\x00\x05\xfe\x02\xf3\x7c\x0d')   # in binary format 97
  response = com_port.readline()
  print (response)

# enable configuration on device with address \x31
  com_port.write(b'\x2a\x61\x00\x05\x31\x02\xe4\x58\x0d')
  response = com_port.readline()
  print ('Response to cfg. enable: ' + response.hex())

# switch device with address \x31 to Modbus RTU
  if response.hex() == '2a6100053102003c0d':
    print ('Configuration enabled')
    com_port.write(b'\x2a\x61\x00\x06\x31\x02\xed\x02\x4c\x0d')
    response = com_port.readline()
    print ('Response to protocol switch: ' + response.hex())
    if response.hex() == '2a6100053102003c0d':
      print ('Device switched to Modbus RTU')
    else:
      print ('Communication protocol could not be changed!')
  else:
    print ('Enable configuration failed!')

  com_port.close()

else:
  print ('Communication port cannot be opened!')

Script for switching from Modbus to Spinel:

# If you get error message "ImportError: no module named serial", pySerial module is not installed.
# Install the module as follows (for Debian/Ubuntu): 
# sudo apt install python3-serial
import serial

# Edit the following lines according to your communication interface
com_port = serial.Serial(port='/dev/ttyUSB1', baudrate=115200, timeout=.5)
# com_port = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=.5)

if com_port.isOpen():
# show device info
  com_port.write(b'\x31\x11\xd4\x2c')
  response = com_port.readline()
  print (response)

# enable configuration on device with address \x31
  #com_port.write(b'\x31\x10\x00\x00\x00\x01\x02\x00\xFF\xb2\x11')    # multi write
  com_port.write(b'\x31\x06\x00\x00\x00\xff\xcc\x7a')                 # single write
  response = com_port.readline()
  print ('Response to cfg. enable: ' + response.hex())

# switch device with address \x31 to Modbus RTU and set baudrate to 115 200 Bd
  if response.hex() == '3106000000ffcc7a':
    print ('Configuration enabled')
    com_port.write(b'\x31\x10\x00\x02\x00\x04\x08\x00\x0A\x00\x00\x00\x0a\x00\x01\x34\x6b')
    response = com_port.readline()
    print ('Response to protocol switch: ' + response.hex())
    if response.hex() == '31100002000465fa':
      print ('Device switched to Spinel')
    else:
      print ('Communication protocol could not be changed!')
  else:
    print ('Enable configuration failed!')

  com_port.close()

else:
  print ('Communication port cannot be opened!')

Downloads:

sw-modbus-configurator.zipModbus Configurator

Software designed for switching communication protocols in our devices, primarily between Spinel and Modbus RTU.

File size: 637 kB

Date: 08-21-2018

Download

Created1/21/2011
We value your privacy
This website stores cookies that help it to work properly. By using our services, you agree to their use.
Allow everythingDetailed settings