read failed: Illegal data address - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10) +--- Thread: read failed: Illegal data address (/showthread.php?tid=1386) |
read failed: Illegal data address - sx3 - 08.05.2018 Hello, I'm trying to make a JSON mapper for the Schneider APC UPS ove Modbus TCP but I'm having some problems. No values get present, and the error is: read failed: Illegal data address This is what I have mapped up so far: Code: { This is the documentation regarding Modbus protocol for the UPS: http://download.schneider-electric.com/files?p_Reference=APC_LFLG-A32G3L_EN&p_EnDocType=User%20guide&p_File_Id=6278616888&p_File_Name=LFLG-A32G3L_R1_EN.pdf Is it something with hexadecimal/decimal adresses? or with my bitmasking? The documentations states UINT16 on datatype, must I add this to the mapper? RE: read failed: Illegal data address - admin - 08.05.2018 Does RTU read test work for these register addresses? Also there's no point in using float16, you will get precision loss when converting from uint16 to float16 for larger values. RE: read failed: Illegal data address - sx3 - 08.05.2018 Actually I found my mistake, I was looking at an old documentation when mappin. Things have changed alot with the one linked in OP. Tried the new registers in OP documentation and it seem to work. So I should just delete bus_datatype column? How about dividing a value with 256 or 64? is there a mapper object for that? RE: read failed: Illegal data address - admin - 09.05.2018 Set multiplier to 1/value, 0.015625 for 64 and 0.00390625 for 256 RE: read failed: Illegal data address - sx3 - 09.05.2018 Thanks! I have problems reading and writing to bool-registers that in the documentation have stated "Length # register" = 2. Does this have anything to do with why I'm not able to read out from theese? Read: { "name": "Online state", "bus_datatype": "bool","type": "register", "address": 0, "bus_address": "6/0/0", "value_bitmask": "0x0002" }, { "name": "On battery state", "bus_datatype": "bool","type": "register", "address": 0, "bus_address": "6/0/1", "value_bitmask": "0x0004" }, { "name": "Bypass state", "bus_datatype": "bool","type": "register", "address": 0, "bus_address": "6/0/2", "value_bitmask": "0x0008" }, Write: { "name": "Output into bypass", "bus_datatype": "bool","type": "register", "address": 1536, "bus_address": "6/1/0", "value_bitmask": "0x0010" }, { "name": "Output out of bypass", "bus_datatype": "bool","type": "register", "address": 1536, "bus_address": "6/1/1", "value_bitmask": "0x0020" }, RE: read failed: Illegal data address - admin - 10.05.2018 To read two registers at once set "datatype" to "uint32". At this moment writing to registers with bitmasks is not supported, you have to calculate final register value via a script. RE: read failed: Illegal data address - sx3 - 10.05.2018 Thanks! uint32 worked for reading. Now to the bigger problem, scripting. I searched the forums and found a similar thread regarding writing a bit, but I'm not sure I understand it? I have edited it to suit me. Must I first set mode, before I send either of the bool KNX telegrams? This register contains 32 bits, no need store all the other bits? But I'm not convinced I have done it right, valuue+512=512+512 and so on? How will the Bool KNX objects be resetted to 0? Otherwise they will be 1 next time the script runs and perhaps set the UPS in ByPass by error? Code: -- 0=set bit 0, 1 RE: read failed: Illegal data address - admin - 10.05.2018 It's much better to use bit functions for setting bits: Code: function setbit(value, nr) The only thing I don't understand is why you have 1-byte value and bool values setting the same bits. How many writable bits are there? RE: read failed: Illegal data address - sx3 - 10.05.2018 1-byte value comes from the example that you gave in another thread, that I tried to understand. I have no clue to be honest. In this register there are 32 writable bits, some of them are reserved though. https://forum.logicmachine.net/showthread.php?tid=1140&pid=6824#pid6824 Bit 4 (bypass) and bit 5 (out of bypass) are exclusive as they both control the state of the UPS. I can only write true to one of them because it toggles between thoose states, either bypass or online. Am I in the ball park with this script? Setting bit 4 in 1536 to true. Code: require('luamodbus') RE: read failed: Illegal data address - admin - 10.05.2018 Correct, but only if you need to have bit 0 set permanently. Otherwise, set value = 0 before any setbit calls RE: read failed: Illegal data address - sx3 - 10.05.2018 I tried it, but it doesn't seem, to work.. I have log(value) in the end, and the value shows up in the log. I tried with both value=0 and 1, no difference. I get nothing in the error log either. Where in the code do I actually settrue/false to the register bit? I guess the UPS would want a "true" in BOOL for the bit to react. Also, do I need to setslave in TCP script as I have done? RE: read failed: Illegal data address - admin - 10.05.2018 Start with logging what writeregisters returns. If you need to write two registers at once, do it like this: Code: res, err = mb:writeregistervalue(1536, value, 'uint32') Refer to product manual for slave id. Some TCP devices ignore slave id completely. RE: read failed: Illegal data address - sx3 - 10.05.2018 It writes: Code: * arg: 1 RE: read failed: Illegal data address - admin - 10.05.2018 Check return values of connect call. Also try it without setting slave id. |