lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Unfortunately I don't see how else the following could happen. After all the 'send' method was looked up on the same "link" variable/object.
As you can see I naively tried to remedy by adding "link" as a new local variable.

Anyone out there with a clue ?

This happens once in a while .. I'd say once in a 100 on some units. Most of the time everything is just fine.
This is lua 5.1.4 on an ARM9 �patched with the latest lua.org (to 5.1.4-2) and lnum �to double/int64 numbers

Rgds /Flemming

Code:
517 
518    local pdu
519    -- special handling of the simple cases 
520    if action == ac.ACTION_OPTION_GET then
521       pdu = struct.pack(">BHH", funcCode, registerStart, registerCnt)
522    elseif 1 == registerCnt then
523       pdu = struct.pack(">BHc2", funcCode, registerStart, data)
524    else
525       -- Assume only one register range for now
526       pdu = struct.pack(">BHHBc", funcCode, registerStart, registerCnt, 2 * registerCnt, data)
527    end
528    local link = self -- Weird - Saw "attempt to index upvalue 'self' (a nil value)" in the CB's
529    link:send(ioaReq.mModule.mAddress, pdu,  LINK_TX_RETRIES,
530              function(res, pdu)
531                 link:ioaRequestCallback(res, pdu, ioaReq, subReqIx, subReqCnt, funcCode,
532                                         function()
533                                            link:processIOASubRequests(subReqIx + subReqCnt)
534                                         end)
535              end)
536 end
Error:


3:12.09, 08:51:09.020 ! � FATAL EXIT: LUAevent: Error: 2:
3:Modbus/Modbus.lua:531: attempt to index upvalue 'link' (a nil value)
3:stack traceback:
3: Modbus/Modbus.lua:531: in function 'mCallBack'
3: Modbus/Modbus.lua:136: in function 'receiveCB'
3: Modbus/Modbus.lua:168: in function <Modbus/Modbus.lua:167>
3: (tail call): ?
3: (tail call): ?
3: Modbus/Modbus.lua:184: in function <Modbus/Modbus.lua:184>
3: (tail call): ?
3: (tail call): ?