Can't use /dev/extcomm/0 ports
tomas_hora administrators last edited by
@dsurname Can you try it on our latest UniPian Neuron OS? Everything is preinstalled so you just try to run the python code...
Where i can download it?
Can i use raspbian stretch lite instead?
Btw i installed evok 2.0.7 and when i run python script i received same error:
Traceback (most recent call last): File "testmodbus.py", line 12, in <module> value = client.read_input_registers(256,4, unit=0x01) File "/home/pi/.local/lib/python3.5/site-packages/pymodbus/client/common.py", line 125, in read_input_registers return self.execute(request) File "/home/pi/.local/lib/python3.5/site-packages/pymodbus/client/sync.py", line 106, in execute raise ConnectionException("Failed to connect[%s]" % (self.__str__())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusSerialClient(rtu baud)]
I think is still enable to communicate with and I don't know the reason behind
Yes, you can use the Raspbian Stretch Lite and install the Evok by yourself, it will work.
In your case, I would test the port on lower level - without any Modbus library. Just use a minicom to open the port with desired settings and enter random characters and watch if the TX LED on your Neuron lights up and possibly the RX LED on your Modbus device lights up (if it has any).
I'm sorry but i'm very novice, can you show me a guide or something else to do that?
Does modbus only access with tcp? I can't figured out how to connect with /dev/extcomm ports...
Martin Kudláček last edited by Martin Kudláček
@dsurname I'm sorry, but explaining how to acquire and use basic linux tools for debugging is outside of the scope of our support. There are plenty of tutorials on the internet and you know everything you need to test it:
- serial port device: /dev/extcomm/0/1
- speed, data bits, parity and stop bits: for testing just use 9600, 8, N, 1
Open the connection with these settings in minicom, write some random data and you should see blinking of TX LEDs on Neuron and possibly on the connected devices.
If that works, you can move forward.
When i run: minicom -b 9600 -o -D /dev/extcomm/0/1 nothing happends.
When i run: minicom -b 9600 -o -D /dev/extcomm/0/0 opens a console but i cant write anything but the Tx leds blinking!
When i press Ctrl-A Z and quit without reset somehow when i run my node.js and try to connect with /dev/extcomm/0/0 something now happends, still can't receive data from thermostats but now the Tx led blinking when i try to call the slave.
I don't know what happened but is better than before.
I don't know is this will help but the led 1.2 of digital outputs is always on now.
Ok, many things to explain.
- On M103, you have only one RS485 port, therefor you have only one RS485 serial device in /dev. You have two directories in /dev/extcomm: "0" and "1". Directory "0" contains links to all serial ports on your unit. In your M103, you have only /dev/extcomm/0/0. The directory "1" contains link to serial port on so-called group 1. In your M103, you have only /dev/extcomm/1/0.
Long story short, on M103, use only the /dev/extcomm/0/0.
Using /dev/extcomm/0/1 is nonsense and the minicom probably exited with:
minicom: cannot open /dev/extcomm/0/1: No such file or directory
- Once you run minicom, it will set the serial port device to certain mode. If you run minicom -b 9600 -D /dev/extcomm/0/0, the /dev/extcomm/0/0 will be configured to speed 9600bps, 8 data bits, no parity, 1 stop bit. And the serial port device will stay in this mode even when you exit the minicom. When you restart the PLC, the settings will be lost.
Your result (the TX LED blinking after you ran the minicom) shows, that there is some problem in your program, not the HW. Maybe you don't use the Modbus library in a correct way. Or maybe you use it correctly, but you use wrong serial port settings. Remember, you have to use the same settings as you have on all devices on your RS485 bus.
Ok i have some questions now.
First, how can i make persistence settings and not lost them when i restart PLC?
Second, i don't understand well this part: "Or maybe you use it correctly, but you use wrong serial port settings. Remember, you have to use the same settings as you have on all devices on your RS485 bus." In my configuration on the node js server i use 9600bps, 8 databits no parity and 1 stop bit. You intend the speed that thermostats accept?
This is the serial configuration of thermostats:
300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400
nessuna, pari o dispari
It's seems the same. Regarding modbus library is the same i used in a raspberry pi, when i change into unipi neuron i've change configuration using /dev/extcomm/0/0 instead of /dev/ttyMAM0
I not sure if i cabled correctly the A and B
You don't have to make it persistent. The software you are using will set this up for you each time you run it and leave it as-is when it finishes. It's like this: When you started a computer, the serial port was unconfigured. When you ran the minicom, it configured the port to the parameters you set in minicom. When the minicom exited, the serial port stayed in that configuration. If you would run another program with different settings, it would reconfigure the serial port again to new configuration. When this program exits, the serial port will stay in the new settings.
I think here lies the root cause of your problem. There is no autoconfiguration of parameters of the serial devices on a bus. All devices need to use exactly the same settings and you need to set them before starting the communication. The Neuron supports e.g. baud rates 9600,19200 and 115200 (actually more, this is just an example!). Your sensors also supports 9600, 19200. But if you want to set speed to 19200, you need to set it on Neuron and on the sensor as well. You cannot set the desired speed only on Neuron (in your Python script or Evok), because the other devices will not automagically pick this up.
Typically, the Modbus devices has ability to communicate via different speeds. By default, they use 9600bps. To use another speed, you need to set the device accordingly. Some have physical settings, like DIP switches on our extension units. But most of them you can reconfigure by writing into their Modbus registers.
Take for example energy meter Inepro PRO1-Mod. On page 9, of the manual, you can find it can use speeds 300, 600, 1200, 2400, 4800 and 9600bps with 9600bps being the default. To change the speed, you need to set the register 4004 according to the Modbus register map on page 25. To set the register, you need working communication. So if you want to set the speed to 1200bps, you first need to use the 9600, write data to the register and then reconfigure the connection on Neuron to 1200bps.
Hope this shed some light on the issue,
Baud rate of thermostats was 38400 so i modify my script. Still i'm not enable to read from them, but when i try to read from device id n.3 something is written in minicom console:
Little update: Everything, finally, work now!!!
But when i restart unipi, everything will be reseted, and I need to reconfigure serial port on minicom, configure permissions on /dev/extcomm and so on. Have you a solution for this problem?
I'm glad it's working for you, although I don't think it's working as it would be expected. You definitely shouldn't have to reconfigure the port or anything after the reboot. The Python library you use should do this for you. Do you have a running Evok which uses the same serial port by any chance?
I don't know why all my settings reseted after reboot, i don't think i have evok that use te same port
#!!! Do not use '#' for comments !!! [MAIN] config_version = 2.5 ; Configuration file version, DO NOT CHANGE! use_schema_verification = False ; Enabling this will deny any requests that do not m$ log_level = ERROR ; Minimum severity of messages to be logged;$ log_file = /var/log/evok.log ; Log file to use; will be cleared on boot port = 8080 ; !!! Internal API port - on$ webhook_enabled = False ; Enables webhook notification - see e.g. ht$ webhook_address = http://127.0.0.1:80 ; Put your server endpoint address here (e.g. http://123.123$ webhook_device_mask = ["input","wd"] ; List of device types to notify on (written as a JSON list)$ webhook_complex_events = False ; EVOK will send POST requests with the same data as$ wifi_control_enabled = False ; !!! REQUIRES THE UNIPIAP WIFI CONTROLLER TO BE INS$ soap_server_enabled = False ; Enables the simple SOAP server; use only i$ soap_server_port = 8081 ; !!! IF SOAP SERVER IS ENABLED, THIS PORT N$ [NEURON_1] global_id = 1 ; Mandatory, REQUIRED TO BE UNIQUE allow_register_access = False ; Optional, False default scan_frequency = 10 ; Optional, 10 default scan_enabled = True ; Optional, True default ; Below you can find examples for connecting devices over UART; first example is a Neuron extension $ ; Devices sharing a port use the port settings of the first device on that port (baud rate, parity, $ ; !!!Note that device_name has to match a filename in the /etc/hw_definitions directory!!! See /etc/$ ;[EXTENSION_1] global_id = 2 ; Mandatory, REQUIRED TO BE UNIQUE device_name = xM103 ; Mandatory modbus_uart_port = /dev/extcomm/0/0 ; Mandatory ;neuron_uart_circuit = 1_01 ; Optional, allows associating extensions wi$ ;allow_register_access = True ; Optional, False default, is mandatory with third-p$ ;address = 1 ; Optional, 1 default ;scan_frequency = 10 ; Optional, 10 default ;scan_enabled = True ; Optional, True default ; Note that the following settings will be inherited by other devices sharing the same port, i.e. /d$ baud_rate = 38400 ; Optional, NEEDS UNIPI IMAGE TO WOR$ parity = N ; Optional, NEEDS UNIPI IMAG$ stop_bits = 1 ; Optional, NEEDS UNIPI IMAGE TO WOR$ ;[EXTENSION_2] ;global_id = 3 ; Mandatory, REQUIRED TO BE UNIQUE ;device_name = CUSTOM MODBUS DEVICE ; Mandatory ;modbus_uart_port = /dev/extcomm/0/0 ; Mandatory ;neuron_uart_circuit = 1_01 ; Optional, allows associating extensions wi$ ;allow_register_access = True ; Mandatory with third-party devices ;address = 1 ; Optional, 15 default ;scan_enabled = True ; Optional, True default [OWBUS_1] owbus = /dev/i2c-1 --i2c=/dev/i2c-1:ALL ; Scanned bus (--i2c=/dev/i2c-1:ALL or local$ interval = 3 ; [s] Default sensor reading scan_interval = 300 ; [s] How often is scanning done ;Example of 1W-4R/4DI extension module, 1W-8R is almost the same, only with inputs instead of relays ; ; - Map a new 1Wire sensor with the appropriate address, type and interval ; - The syntax can be either SENSOR or 1WDEVICE ; - Setting the correct reading interval is crucial to achieve ideal performance; the default interv$ ; ;[1WDEVICE_2] ;bus = 1 ;address = 29F39A17000000BC ;type = DS2408 ;interval = 1 ; ;[1WRELAY_10] ;sensor = 2 ;pin = 0 ; ;[1WRELAY_11] ;sensor = 2 ;pin = 1 ; ;[1WRELAY_12] ;sensor = 2 ;pin = 2 ; ;[1WRELAY_13] ;sensor = 2 ;pin = 3 ; ;[1WINPUT_20] ;sensor = 2 ;pin = 4 ; ;[1WINPUT_21] ;sensor = 2 ;pin = 5 ; ;[1WINPUT_22] ;sensor = 2 ;pin = 6 ; ;[1WINPUT_22] ;sensor = 2 ;pin = 6 ; ;[1WINPUT_23] ;sensor = 2 ;pin = 7
This is my evok file
the config file is utterly wrong. If you don't use any extension, you need to comment out all the lines of the [EXTENSION_1] block, not just the [EXTENSION_1] line. The syntax of this config file is based on the INI file. That means the active lines of the config where assigned to the [NEURON_1] block, thus resulting in unexpectable behaviour.
;[EXTENSION_1] global_id = 2 ; Mandatory, REQUIRED TO BE UNIQUE device_name = xM103 ; Mandatory modbus_uart_port = /dev/extcomm/0/0 ; Mandatory ;neuron_uart_circuit = 1_01 ; Optional, allows associating extensions wi$ ;allow_register_access = True ; Optional, False default, is mandatory with third-p$ ;address = 1 ; Optional, 1 default ;scan_frequency = 10 ; Optional, 10 default ;scan_enabled = True ; Optional, True default ; Note that the following settings will be inherited by other devices sharing the same port, i.e. /d$ baud_rate = 38400 ; Optional, NEEDS UNIPI IMAGE TO WOR$ parity = N ; Optional, NEEDS UNIPI IMAG$ stop_bits = 1 ; Optional, NEEDS UNIPI IMAGE TO WOR$