frangoteam / FUXA

Web-based Process Visualization (SCADA/HMI/Dashboard) software
https://frangoteam.org
MIT License
2.67k stars 786 forks source link

modbus tcp, register not supported by device - query bug? #71

Closed cicci44 closed 2 years ago

cicci44 commented 4 years ago

device CPU look like this, readings are fine: bild but if i add 300025, int16.. i get no reading but this: bild however.. if i disable device CPU, and make a copy called TEST i get values like this: bild

im not sure if im doing wrong or if theres a hardware related issue... bild second picture bild

how can i make a second query to get the next serie of data if the query is too long?

unocelli commented 4 years ago

Hi, I tested with ModRSSim2 (modbus slave simulator) and I can't reproduce the problem, I think that is a problem with the hardware (slave) that you are using. (https://user-images.githubusercontent.com/48684550/90986053-6289e400-e580-11ea-9b2a-eb58ed98060b.PNG)

(https://user-images.githubusercontent.com/48684550/90986049-57cf4f00-e580-11ea-9b0a-22cdd6a33d0e.PNG)

cicci44 commented 4 years ago

ok. thanks for the hint, im not familiar with modbus tcp but will build simple test script soon to see if the hardware can handle two queries after each other from diffrent place in the register. The same hardware but older revision used modbus RTU and the test code seems to loop out queries after each other and when all is done, it publish the result, might just be so simple with this..

Maybe a feature to implantate if its true 👍

cicci44 commented 4 years ago

this code below works. It seems that hardware-side does not like to read all data in one sweep. After consulted around it seems to be common issue of some hardware manufacturers.. as i understand, i cant read over a "black hole" in the register. bild

Is it possible to add a feature to add multiple queries in next update? that would be great to try. 👍


#!/usr/bin/env python
# -*- coding: utf-8 -*-

```from pyModbusTCP.client import ModbusClient
import time
SERVER_HOST = "192.168.1.10"
SERVER_PORT = 502
c = ModbusClient()
# modbus server IP och port
c.host(SERVER_HOST)
c.port(SERVER_PORT)

while True:
    # etablera eller Äteretablera förbindelse..
        #connect or reconnect...
    if not c.is_open():
        if not c.open():
            print("unable to connect to "+SERVER_HOST+":"+str(SERVER_PORT))
        print ("connect or reconnecting..")
        #if function is available....
    # om funktion tillgÀnglig, lÀs register..
    if c.is_open():
        # start at address 0 and read to 13, store in query1
        # Börja pÄ address 0 och lÀs 13st.. lagra det i query1
        query1 = c.read_input_registers(0, 13)
        time.sleep(2)
        # lÀs ytterlig och lagra det i query2
        # read som more and store it in query2
        query2 = c.read_input_registers(22, 10)
        # if success display registers
        if query2:
                print ("query1")
                print ("reg ad #0 to 13: "+str(query1))
                print ("query2")
                print ("reg ad #22 to 32: "+str(query2))

    # sleep 2s before next polling
        #vÀnta..
    time.sleep(2)
unocelli commented 4 years ago

Hi, I understand...can you try my last committed code and tell me if will work? Thanks

cicci44 commented 4 years ago

Hi, I understand...can you try my last committed code and tell me if will work? Thanks

testing the last committed code, it seems to work 👍

however, seems to be another issue after 1-2min, but will make a new issue of that (not sure yet if the error is a issue) bild EDIT:Tried add/remove register, the modbustcp stop, gets readings again and works around 1minutes,30seconds until error code starts over. I think polling might be too close to each other. bild

unocelli commented 4 years ago

how many modbus Tags have you configured? If you change the polling interval DEVICE_POLLING_INTERVAL in 'server/runtime/devices/device.js' (for example to 5 seconds) what happens?

cicci44 commented 4 years ago

how many modbus Tags have you configured? If you change the polling interval DEVICE_POLLING_INTERVAL in 'server/runtime/devices/device.js' (for example to 5 seconds) what happens?

i got for the moment eight modbus tags but the error still there, tried raise to 10sec. bild

unocelli commented 4 years ago

Hi, I send you a 'modbus/index.js' file where I improved the error description and increment to 10 seconds the client request timeout client.setTimeout(10000);

index.zip

cicci44 commented 4 years ago

Hi, I send you a 'modbus/index.js' file where I improved the error description and increment to 10 seconds the client request timeout client.setTimeout(10000);

index.zip

"Timed out", tried raise deviceCloseTimeout in rundime/devices.devices.js to 5sec, didnt work. bild

unocelli commented 4 years ago

I suspect the problem is that the Promise.all function is too fast for the Device. what happens if you configure only one tag, (so that only one query is made per poll interval?

cicci44 commented 4 years ago

I suspect the problem is that the Promise.all function is too fast for the Device. what happens if you configure only one tag, (so that only one query is made per poll interval?

this was the settings bild this was the result bild however i just remember i made a change in FUXA/server/main.js back for a while when i had issues with connection to the GUI, that cannot make the issue?. bild

unocelli commented 4 years ago

I send you a test to see how the used 'modbus-serial' library and your hardware works with a simple query. modbus-serial_test.zip

npm install npm start

cicci44 commented 4 years ago

I send you a test to see how the used 'modbus-serial' library and your hardware works with a simple query. modbus-serial_test.zip

npm install npm start

seems ok for the moment but i needed to change 192.168.1.155 (raspberry address) to 192.168.1.153 (ftx), will let it run for a while and see if something happens bild

unocelli commented 4 years ago

Hi, maybe the problem is in the wait for the response of the device before continuing. I send you a new 'modbus/index.js' file where I changed the polling function:

this.polling = async function () { readVarsfnc.push(await _readMemory(...

index.zip

cicci44 commented 4 years ago

Hi, maybe the problem is in the wait for the response of the device before continuing. I send you a new 'modbus/index.js' file where I changed the polling function:

this.polling = async function () { readVarsfnc.push(await _readMemory(...

index.zip

this is the result now bild

unocelli commented 4 years ago

Can you tell me which hardware (device) are you trying to communicate and witch nodejs version have you installed in Raspberry?

cicci44 commented 4 years ago

Can you tell me which hardware (device) are you trying to communicate and witch nodejs version have you installed in Raspberry?

im trying communicate with Heru 100 T EC with node v12.16.2, just saw theres a firmware update on the ftx, going to test upgrade firmware to see if Coms get more stable.. https://fsp.ostberg.com/products/4397/heru-100-t-ec/?region=en&lang=en

unocelli commented 2 years ago

I update the library and the handling of modbus. going to close this as resolved. let me know if you have any issues.