Value considered as UNDEFINED

Hi guys, I have a problem that I don't understand at all.

First to understand the situation:

My programs works by going on a dashboard and by selecting a variable. When this variable is selected the list number is returned so that the modbus flex getter go search at the right place the value of this variable. This value is than joined in an object with the list number and kept in a msg.payload for later use.

This object is than put in the flow so that the function node can use it.
The function node works by getting an int number, putting it as a boolean number and then via the list number, choosing the right bit to show on the dashboard.

here's the debug:

So when I select a value in the dashboard going from 0 to 16 the program will work properly but when the value is bigger it will print me this undefined. And I don't understand why it stops working when the list number of the dashboard is bigger than 16.
image

[
    {
        "id": "ad42f873412c2f98",
        "type": "tab",
        "label": "RPI  Shelter EIA",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5bad0cb6533899a8",
        "type": "ui_button",
        "z": "ad42f873412c2f98",
        "name": "",
        "group": "780cfd9c93f7b572",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "Lire",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 90,
        "y": 740,
        "wires": [
            [
                "e85dee5092aec692"
            ]
        ]
    },
    {
        "id": "6817ad78d442051b",
        "type": "ui_button",
        "z": "ad42f873412c2f98",
        "name": "",
        "group": "18997b9d48e95027",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "INITIALISATION",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "date",
        "topic": "topic",
        "topicType": "msg",
        "x": 120,
        "y": 320,
        "wires": [
            [
                "f56948d866932748"
            ]
        ]
    },
    {
        "id": "f56948d866932748",
        "type": "file in",
        "z": "ad42f873412c2f98",
        "name": "RequĂȘte1",
        "filename": "C:\\Users\\Theodros\\Documents\\GRTgaz\\NODE-RED_GRTgaz\\Tables modbus\\Requete1 bool.csv",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 360,
        "y": 320,
        "wires": [
            [
                "1e304abcae2ccf65"
            ]
        ]
    },
    {
        "id": "1e304abcae2ccf65",
        "type": "csv",
        "z": "ad42f873412c2f98",
        "name": "",
        "sep": ",",
        "hdrin": false,
        "hdrout": "all",
        "multi": "mult",
        "ret": "\\r\\n",
        "temp": "label",
        "skip": "0",
        "strings": true,
        "include_empty_strings": "",
        "include_null_values": "",
        "x": 510,
        "y": 320,
        "wires": [
            [
                "3500365835d5d8ac"
            ]
        ]
    },
    {
        "id": "3500365835d5d8ac",
        "type": "function",
        "z": "ad42f873412c2f98",
        "name": "REMPLISSAGE",
        "func": "msg.options = msg.payload.map((el, index) => {\n\nreturn { [el.label] : index }\n    \n})\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 320,
        "wires": [
            [
                "b4cd49f83874842e"
            ]
        ]
    },
    {
        "id": "b4cd49f83874842e",
        "type": "ui_dropdown",
        "z": "ad42f873412c2f98",
        "name": "",
        "label": "",
        "tooltip": "",
        "place": "Select option",
        "group": "780cfd9c93f7b572",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "multiple": false,
        "options": [],
        "payload": "",
        "topic": "S1",
        "topicType": "str",
        "className": "",
        "x": 880,
        "y": 320,
        "wires": [
            [
                "a02a3e6a86c1ea6f",
                "1dd903ddc2f6e1dd"
            ]
        ]
    },
    {
        "id": "cf3418e05735fbd7",
        "type": "ui_text",
        "z": "ad42f873412c2f98",
        "group": "780cfd9c93f7b572",
        "order": 1,
        "width": 6,
        "height": 1,
        "name": "",
        "label": "BOOL",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "",
        "x": 350,
        "y": 260,
        "wires": []
    },
    {
        "id": "0eaf9f8b5014fd0f",
        "type": "ui_text",
        "z": "ad42f873412c2f98",
        "group": "780cfd9c93f7b572",
        "order": 4,
        "width": 0,
        "height": 0,
        "name": "BOOL",
        "label": "",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "",
        "x": 1070,
        "y": 740,
        "wires": []
    },
    {
        "id": "f80557635255a803",
        "type": "function",
        "z": "ad42f873412c2f98",
        "name": "Adressage",
        "func": "const num = msg.payload.S1; //Chiffre allant de 0 à 79\nconst val =  msg.payload.B1[0]; // booléen\n\nnewArr=[]; //crée un nouveau tableau\n\nbit = val.toString(2).padStart(16,\"0\") ; //transforme le résultat sous forme de binaire\ntab = bit.split('');//sépare chaque chiffre\n\n//On inverse le tableau afin que les valeurs soit dans le bon sens\nfor(let i = tab.length - 1; i>=0; i--)\n{\n    newArr.push(tab[i]);\n}\n\nmsg.payload = newArr[num];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 670,
        "y": 740,
        "wires": [
            [
                "0eaf9f8b5014fd0f",
                "bc7cb18204d747dc"
            ]
        ]
    },
    {
        "id": "a02a3e6a86c1ea6f",
        "type": "function",
        "z": "ad42f873412c2f98",
        "name": "modbus flex getter options",
        "func": "const num = msg.payload; //Chiffre allant de 0 Ă  78\n\nconst parsedInput = { WORD_OFFSET: Math.floor(num / 16) }\n\nmsg.payload= {\n    'fc': 3,\n    'unitid': 1,\n    'address': 59 + parsedInput.WORD_OFFSET,\n    'quantity': 1,\n}\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 960,
        "y": 480,
        "wires": [
            [
                "b562440633b74130"
            ]
        ]
    },
    {
        "id": "b562440633b74130",
        "type": "modbus-flex-getter",
        "z": "ad42f873412c2f98",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "logIOActivities": false,
        "server": "7d0292a23936c0ce",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "x": 1220,
        "y": 480,
        "wires": [
            [
                "09e7a16b624a6065"
            ],
            []
        ]
    },
    {
        "id": "09e7a16b624a6065",
        "type": "change",
        "z": "ad42f873412c2f98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "B1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1440,
        "y": 480,
        "wires": [
            [
                "1dd903ddc2f6e1dd"
            ]
        ]
    },
    {
        "id": "d872c1545f718544",
        "type": "change",
        "z": "ad42f873412c2f98",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "selected",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1650,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "1dd903ddc2f6e1dd",
        "type": "join",
        "z": "ad42f873412c2f98",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": true,
        "timeout": "",
        "count": "1",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 1420,
        "y": 320,
        "wires": [
            [
                "d872c1545f718544"
            ]
        ]
    },
    {
        "id": "f78c38bb795f3c5c",
        "type": "modbus-server",
        "z": "ad42f873412c2f98",
        "name": "",
        "logEnabled": false,
        "hostname": "0.0.0.0",
        "serverPort": 10502,
        "responseDelay": 100,
        "delayUnit": "ms",
        "coilsBufferSize": 10000,
        "holdingBufferSize": 10000,
        "inputBufferSize": 10000,
        "discreteBufferSize": 10000,
        "showErrors": false,
        "x": 640,
        "y": 100,
        "wires": [
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "e85dee5092aec692",
        "type": "change",
        "z": "ad42f873412c2f98",
        "name": "Envoie des données",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "selected",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 300,
        "y": 740,
        "wires": [
            [
                "f80557635255a803",
                "b07658c8cddfcebd"
            ]
        ]
    },
    {
        "id": "bc7cb18204d747dc",
        "type": "debug",
        "z": "ad42f873412c2f98",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 580,
        "wires": []
    },
    {
        "id": "b07658c8cddfcebd",
        "type": "debug",
        "z": "ad42f873412c2f98",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 390,
        "y": 540,
        "wires": []
    },
    {
        "id": "8a43d090e4c4e17a",
        "type": "ui_spacer",
        "z": "ad42f873412c2f98",
        "name": "spacer",
        "group": "780cfd9c93f7b572",
        "order": 5,
        "width": 6,
        "height": 1
    },
    {
        "id": "2d8e385d43e906c7",
        "type": "ui_spacer",
        "z": "ad42f873412c2f98",
        "name": "spacer",
        "group": "780cfd9c93f7b572",
        "order": 10,
        "width": 6,
        "height": 1
    },
    {
        "id": "373285ef2508ebc9",
        "type": "ui_spacer",
        "z": "ad42f873412c2f98",
        "name": "spacer",
        "group": "780cfd9c93f7b572",
        "order": 15,
        "width": 6,
        "height": 1
    },
    {
        "id": "ba8e0a9132cd1daf",
        "type": "ui_spacer",
        "z": "ad42f873412c2f98",
        "name": "spacer",
        "group": "15528da52822872e",
        "order": 6,
        "width": 6,
        "height": 1
    },
    {
        "id": "7ad12eb46dbba9d7",
        "type": "ui_spacer",
        "z": "ad42f873412c2f98",
        "name": "spacer",
        "group": "15528da52822872e",
        "order": 12,
        "width": 6,
        "height": 1
    },
    {
        "id": "780cfd9c93f7b572",
        "type": "ui_group",
        "name": "RequĂȘte 1",
        "tab": "0baea998ce75eabd",
        "order": 1,
        "disp": true,
        "width": 6,
        "collapse": false,
        "className": ""
    },
    {
        "id": "18997b9d48e95027",
        "type": "ui_group",
        "name": "INITIALISATION",
        "tab": "0baea998ce75eabd",
        "order": 4,
        "disp": true,
        "width": 8,
        "collapse": false,
        "className": ""
    },
    {
        "id": "7d0292a23936c0ce",
        "type": "modbus-client",
        "name": "",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "tcpHost": "0.0.0.0",
        "tcpPort": "10502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    },
    {
        "id": "15528da52822872e",
        "type": "ui_group",
        "name": "RequĂȘte 3",
        "tab": "0baea998ce75eabd",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "0baea998ce75eabd",
        "type": "ui_tab",
        "name": "RPI Shelter EIA",
        "icon": "RPI Shelter EIA",
        "disabled": false,
        "hidden": false
    }
]

PS: Hope what I said is understandable, don't hesitate on correcting me or asking questions

Hello Theodros,

What is the content of the Requete1 bool.csv file ?
Can you share (in text form) in order to fully replicate your flow ?

As far as I can tell bit = val.toString(2).padStart(16,"0") ; creates a string 16 chars long. Then you split it to an array 16 elements long. So if list number is greater than 15 it will return undefined, as there are no array elements above 15.

1 Like

COMPRESSEUR Started
RADIATEUR D'HUILE Started
LA POMPE À HUILE Started
LA POMPE À EAU Started
G1 FANS / GASCOOLER Started
G2 FANS / GASCOOLER Started
DE RECHANGE
CHAUFFAGE SALLE DE COMPRESSEUR Started
SOUPAPE D'ADMISSION Open
POUSSOIR DE SOUPAPE 1ER ETAGE Open
SORTIE/BLOWDOWN SOUPAPE Open
ALARME VISUELLE ROUGE CLIGNOTANT ON
ALARME VISUELLE BLEU CLIGNOTANT ON
LAMPE DE BOUTON POUSSOIR ON
VENTILATEUR D'EXTRACTION D'AIR Started
RESET VARIATEUR DE VITESSE COMPRESSEUR Active
SOUPAPE DE VIDANGE LIQUIDE Open
TRIP HAUTE PRESSION (PSHH) Active
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
SOUPAPE D'ENTRÉE COMPRESSEUR Open
SOUPAPE DE SORTIE COMPRESSEUR Open
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
BOUTON DE DÉMARRAGE
BOUTON D'ARRÊT
RÉINITIALISATION DES ALARMES
CIRCUIT D'URGENCE OK
CONTRÔLE DE TENSION
LA PRESSIONDE L'AIR
TEMPÉRATURE DE PANNEAU DE CONTRÔLE
CONSENTEMENTEXTERNE
COMPRESSEUREN EN MARCHE
CHAUFFE A L'HUILE THERMIQUE
FILTRE DE GAZ D'ADMISSION
NIVEAU D'HUILE
MOTEUR DE COMPRESSEUR THERMIQUE
FILTRE À HUILE
PRESSION DE GAZ DE SORTIE
PRESSION DE GAZ D'ENTREE
POMPE À EAU THERMIQUE
G1 FANS THERMIQUE
POMPE À HUILE THERMIQUE
L'EXTRACTEUR THERMIQUE
ESPACE VIDE NON FONCTIONNEL
PTC MOTEUR
DE RECHANGE
G2 FANS THERMIQUE
MODE LOCAL AUT
MODE DISTANCE AUT
HORS SERVICE
DÉTECTEUR DE FLAMME D'ALARME CUMULATIVE
THERMOSTAT COMPRESSEUR CHAUFFE
THERMIQUE SALLE DE COMPRESSEUR CHAUFFE
THERMIQUE SALLE DE CONTRÔLE CHAUFFE
NIVEAU DE RÉCUPÉRATION D'HUILE
CUMULATIVO ANOMALIA SENSORE GAS
ALARME HAUTE CONCENTRATION DE GAZ À EFFET CUMULATIF
DÉTECTEURS DE FUMÉE DE DÉFAUT COMP. PIÈCE
DÉTECTEURS DE FUMÉE DE ALARM COMP. PIÈCE
CUMULATIVO ANOMALIA SENSORE GAS
ENTRÉE STATUS SLAM SHUT
SOUPAPE EVA004 POSITION SWITCH-OPEN
SOUPAPE EVA004 POSITION SWITCH-CLOSE
SOUPAPE EVJ001 POSITION SWITCH-OPEN
SOUPAPE EVJ001 POSITION SWITCH-CLOSE
SOUPAPE EVJ002 POSITION SWITCH-OPEN
SOUPAPE EVJ002 POSITION SWITCH-CLOSE
ESPACE VIDE NON FONCTIONNEL
ESPACE VIDE NON FONCTIONNEL
ALARME TRES HAUT TEMPÉRATURE AMBIANT

Hello ..

I see you use a Join node at the top part of your flow .. just to pass a topic? its not needed .. you can set your Modbus node option to keep msg properties and set any additional properties (like topic and selection) in the Function node.

image

Also in the Adressage Function .. there is no need to loop through the array to reverse it.
Just use the JS method .reverse()

Modified Flow

[{"id":"ad42f873412c2f98","type":"tab","label":"RPI  Shelter EIA","disabled":false,"info":"","env":[]},{"id":"5bad0cb6533899a8","type":"ui_button","z":"ad42f873412c2f98","name":"","group":"780cfd9c93f7b572","order":2,"width":0,"height":0,"passthru":false,"label":"Lire","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":740,"wires":[["b07658c8cddfcebd","f80557635255a803"]]},{"id":"6817ad78d442051b","type":"ui_button","z":"ad42f873412c2f98","name":"","group":"18997b9d48e95027","order":1,"width":0,"height":0,"passthru":true,"label":"INITIALISATION","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"date","topic":"topic","topicType":"msg","x":120,"y":320,"wires":[["f56948d866932748"]]},{"id":"f56948d866932748","type":"file in","z":"ad42f873412c2f98","name":"RequĂȘte1","filename":"C:\\Users\\Theodros\\Documents\\GRTgaz\\NODE-RED_GRTgaz\\Tables modbus\\Requete1 bool.csv","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":255,"y":320,"wires":[["1e304abcae2ccf65"]],"l":false},{"id":"3500365835d5d8ac","type":"function","z":"ad42f873412c2f98","name":"REMPLISSAGE","func":"msg.options = msg.payload.map((el, index) => {\n\nreturn { [el.label] : index }\n    \n})\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":320,"wires":[["b4cd49f83874842e"]]},{"id":"b4cd49f83874842e","type":"ui_dropdown","z":"ad42f873412c2f98","name":"","label":"","tooltip":"","place":"Select option","group":"780cfd9c93f7b572","order":3,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"S1","topicType":"str","className":"","x":720,"y":320,"wires":[["a02a3e6a86c1ea6f","d808d0e8638ca72f"]]},{"id":"cf3418e05735fbd7","type":"ui_text","z":"ad42f873412c2f98","group":"780cfd9c93f7b572","order":1,"width":6,"height":1,"name":"","label":"BOOL","format":"{{msg.payload}}","layout":"col-center","className":"","x":230,"y":240,"wires":[]},{"id":"0eaf9f8b5014fd0f","type":"ui_text","z":"ad42f873412c2f98","group":"780cfd9c93f7b572","order":4,"width":0,"height":0,"name":"BOOL","label":"","format":"{{msg.payload}}","layout":"col-center","className":"","x":530,"y":740,"wires":[]},{"id":"f80557635255a803","type":"function","z":"ad42f873412c2f98","name":"Adressage","func":"let selected = flow.get(\"selected\")\n\nconst num = selected.S1; // Chiffre allant de 0 Ă  79\nconst val = selected.B1; // boolĂ©en\n\nlet newArr = []; // crĂ©e un nouveau tableau\n\nlet bit = val.toString(2).padStart(16, \"0\"); // transforme le rĂ©sultat sous forme de binaire\nlet tab = bit.split('').reverse(); // sĂ©pare chaque chiffre\nnode.warn({ bit, tab });\n\n// On inverse le tableau afin que les valeurs soit dans le bon sens\n// for (let i = tab.length - 1; i >= 0; i--) {\n//     newArr.push(tab[i]);\n// }\n\nmsg.payload = tab[num];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":740,"wires":[["0eaf9f8b5014fd0f","bc7cb18204d747dc"]]},{"id":"a02a3e6a86c1ea6f","type":"function","z":"ad42f873412c2f98","name":"modbus flex getter options","func":"const num = msg.payload; //Chiffre allant de 0 Ă  78\n\nconst parsedInput = { WORD_OFFSET: Math.floor(num / 16) }\n//node.warn(parsedInput);\n\nmsg.payload= {\n    'fc': 3,\n    'unitid': 1,\n    'address': 59 + parsedInput.WORD_OFFSET,\n    'quantity': 1,\n}\n\nmsg.topic = \"B1\"\nmsg.S1 = num\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":320,"wires":[["b562440633b74130"]]},{"id":"b562440633b74130","type":"modbus-flex-getter","z":"ad42f873412c2f98","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"7d0292a23936c0ce","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":true,"x":1200,"y":320,"wires":[["85ff17fb22849925","d872c1545f718544"],[]]},{"id":"d872c1545f718544","type":"change","z":"ad42f873412c2f98","name":"","rules":[{"t":"set","p":"selected","pt":"flow","to":"{ \"S1\" : S1, \"B1\": payload[0]}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":300,"wires":[[]]},{"id":"f78c38bb795f3c5c","type":"modbus-server","z":"ad42f873412c2f98","name":"","logEnabled":false,"hostname":"0.0.0.0","serverPort":10502,"responseDelay":100,"delayUnit":"ms","coilsBufferSize":10000,"holdingBufferSize":10000,"inputBufferSize":10000,"discreteBufferSize":10000,"showErrors":false,"x":640,"y":100,"wires":[[],[],[],[],[]]},{"id":"bc7cb18204d747dc","type":"debug","z":"ad42f873412c2f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":660,"wires":[]},{"id":"b07658c8cddfcebd","type":"debug","z":"ad42f873412c2f98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":210,"y":660,"wires":[]},{"id":"9cfd4a4501452247","type":"debug","z":"ad42f873412c2f98","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":260,"wires":[]},{"id":"d808d0e8638ca72f","type":"debug","z":"ad42f873412c2f98","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":260,"wires":[]},{"id":"1e304abcae2ccf65","type":"csv","z":"ad42f873412c2f98","name":"","sep":",","hdrin":false,"hdrout":"all","multi":"mult","ret":"\\r\\n","temp":"label","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":370,"y":320,"wires":[["3500365835d5d8ac","9cfd4a4501452247"]]},{"id":"85ff17fb22849925","type":"debug","z":"ad42f873412c2f98","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1340,"y":260,"wires":[]},{"id":"8a43d090e4c4e17a","type":"ui_spacer","z":"ad42f873412c2f98","name":"spacer","group":"780cfd9c93f7b572","order":5,"width":6,"height":1},{"id":"2d8e385d43e906c7","type":"ui_spacer","z":"ad42f873412c2f98","name":"spacer","group":"780cfd9c93f7b572","order":10,"width":6,"height":1},{"id":"373285ef2508ebc9","type":"ui_spacer","z":"ad42f873412c2f98","name":"spacer","group":"780cfd9c93f7b572","order":15,"width":6,"height":1},{"id":"ba8e0a9132cd1daf","type":"ui_spacer","z":"ad42f873412c2f98","name":"spacer","group":"15528da52822872e","order":6,"width":6,"height":1},{"id":"7ad12eb46dbba9d7","type":"ui_spacer","z":"ad42f873412c2f98","name":"spacer","group":"15528da52822872e","order":12,"width":6,"height":1},{"id":"780cfd9c93f7b572","type":"ui_group","name":"RequĂȘte 1","tab":"0baea998ce75eabd","order":1,"disp":true,"width":6,"collapse":false,"className":""},{"id":"18997b9d48e95027","type":"ui_group","name":"INITIALISATION","tab":"0baea998ce75eabd","order":4,"disp":true,"width":8,"collapse":false,"className":""},{"id":"7d0292a23936c0ce","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"0.0.0.0","tcpPort":"10502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"15528da52822872e","type":"ui_group","name":"RequĂȘte 3","tab":"0baea998ce75eabd","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"0baea998ce75eabd","type":"ui_tab","name":"RPI Shelter EIA","icon":"RPI Shelter EIA","disabled":false,"hidden":false}]

your modbus device has a Holding register (FC3) to present its Digital (true/false) values ?
how many Digital inputs/outputs does the device have ?
you are reading 1 register each time. thats 16bits of 0s and 1s
as @E1cid noted .. you are running out of elements in the array

thanks for all this info I will see to apply it and yes I was checking what @E1cid was saying and I understood the problem. I need to understand how to retrieve the elements correctly in a bigger array (78 elements)

So I changed my program and seperated the whole list in 5 array of 16 elements.

Now it works because everytime the list number returned is going from 0 to 16.

Thanks for everything guys

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.