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.
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:
01 |
# If you get error message "ImportError: no module named serial", pySerial module is not installed. |
02 |
# Install the module as follows (for Debian/Ubuntu): |
03 |
# sudo apt install python3-serial |
04 |
import serial |
05 |
06 |
# Edit the following lines according to your communication interface |
07 |
com_port = serial.Serial(port = '/dev/ttyUSB1' , baudrate = 115200 , timeout = . 5 ) |
08 |
# com_port = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=.5) |
09 |
10 |
if com_port.isOpen(): |
11 |
# show Spinel device info |
12 |
#com_port.write('*B1?\r'.encode('utf-8')) # in ASCII format 66 |
13 |
com_port.write(b '\x2a\x61\x00\x05\xfe\x02\xf3\x7c\x0d' ) # in binary format 97 |
14 |
response = com_port.readline() |
15 |
print (response) |
16 |
17 |
# enable configuration on device with address \x31 |
18 |
com_port.write(b '\x2a\x61\x00\x05\x31\x02\xe4\x58\x0d' ) |
19 |
response = com_port.readline() |
20 |
print ( 'Response to cfg. enable: ' + response. hex ()) |
21 |
22 |
# switch device with address \x31 to Modbus RTU |
23 |
if response. hex () = = '2a6100053102003c0d' : |
24 |
print ( 'Configuration enabled' ) |
25 |
com_port.write(b '\x2a\x61\x00\x06\x31\x02\xed\x02\x4c\x0d' ) |
26 |
response = com_port.readline() |
27 |
print ( 'Response to protocol switch: ' + response. hex ()) |
28 |
if response. hex () = = '2a6100053102003c0d' : |
29 |
print ( 'Device switched to Modbus RTU' ) |
30 |
else : |
31 |
print ( 'Communication protocol could not be changed!' ) |
32 |
else : |
33 |
print ( 'Enable configuration failed!' ) |
34 |
35 |
com_port.close() |
36 |
37 |
else : |
38 |
print ( 'Communication port cannot be opened!' ) |
Script for switching from Modbus to Spinel:
01 |
# If you get error message "ImportError: no module named serial", pySerial module is not installed. |
02 |
# Install the module as follows (for Debian/Ubuntu): |
03 |
# sudo apt install python3-serial |
04 |
import serial |
05 |
06 |
# Edit the following lines according to your communication interface |
07 |
com_port = serial.Serial(port = '/dev/ttyUSB1' , baudrate = 115200 , timeout = . 5 ) |
08 |
# com_port = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=.5) |
09 |
10 |
if com_port.isOpen(): |
11 |
# show device info |
12 |
com_port.write(b '\x31\x11\xd4\x2c' ) |
13 |
response = com_port.readline() |
14 |
print (response) |
15 |
16 |
# enable configuration on device with address \x31 |
17 |
#com_port.write(b'\x31\x10\x00\x00\x00\x01\x02\x00\xFF\xb2\x11') # multi write |
18 |
com_port.write(b '\x31\x06\x00\x00\x00\xff\xcc\x7a' ) # single write |
19 |
response = com_port.readline() |
20 |
print ( 'Response to cfg. enable: ' + response. hex ()) |
21 |
22 |
# switch device with address \x31 to Modbus RTU and set baudrate to 115 200 Bd |
23 |
if response. hex () = = '3106000000ffcc7a' : |
24 |
print ( 'Configuration enabled' ) |
25 |
com_port.write(b '\x31\x10\x00\x02\x00\x04\x08\x00\x0A\x00\x00\x00\x0a\x00\x01\x34\x6b' ) |
26 |
response = com_port.readline() |
27 |
print ( 'Response to protocol switch: ' + response. hex ()) |
28 |
if response. hex () = = '31100002000465fa' : |
29 |
print ( 'Device switched to Spinel' ) |
30 |
else : |
31 |
print ( 'Communication protocol could not be changed!' ) |
32 |
else : |
33 |
print ( 'Enable configuration failed!' ) |
34 |
35 |
com_port.close() |
36 |
37 |
else : |
38 |
print ( 'Communication port cannot be opened!' ) |
Downloads:
Modbus Configurator
Software designed for switching communication protocols in our devices, primarily between Spinel and Modbus RTU.
File size: 637 kB
Date: 08-21-2018
Reviews
There are no reviews yet.