• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
433nano stops receiving
#41
I'm running that now. So far I have noticed it surviving one "invalid stream" message - I'll keep watching.

Earlier when the reception died, the LED on the nano was still flashing once per second. It also reacts to remote button presses so I guess it is still sending data.
 
Reply
#42
But nano activity should trigger the lua serial read messages.
 
Reply
#43
Stuck again. And yes, the LED is still flashing.

Code:
[Jan 11 22:08:50:582357] DEBUG: cpu: 3.290978%
[Jan 11 22:08:51:545230] DEBUG: lua serial read on state #0
[Jan 11 22:08:52:544028] DEBUG: lua serial read on state #0
[Jan 11 22:08:53:542872] DEBUG: lua serial read on state #0
[Jan 11 22:08:53:584333] DEBUG: cpu: 3.347246%
[Jan 11 22:08:54:541814] DEBUG: lua serial read on state #0
[Jan 11 22:08:55:540805] DEBUG: lua serial read on state #0
[Jan 11 22:08:56:539519] DEBUG: lua serial read on state #0
[Jan 11 22:08:56:585119] DEBUG: cpu: 3.422852%
[Jan 11 22:08:57:554734] DEBUG: lua serial read on state #0
[Jan 11 22:08:58:553690] DEBUG: lua serial read on state #0
[Jan 11 22:08:59:552540] DEBUG: lua serial read on state #0
[Jan 11 22:08:59:590724] DEBUG: cpu: 3.438929%
[Jan 11 22:09:00:551358] DEBUG: lua serial read on state #0
[Jan 11 22:09:01:550203] DEBUG: lua serial read on state #0
[Jan 11 22:09:02:548067] DEBUG: lua serial read on state #0
[Jan 11 22:09:02:587786] DEBUG: cpu: 3.385398%
[Jan 11 22:09:03:546884] DEBUG: lua serial read on state #0
[Jan 11 22:09:04:545869] DEBUG: lua serial read on state #0
[Jan 11 22:09:04:938866] DEBUG: lua serial read on state #0
[Jan 11 22:09:04:969335] NOTICE: 433nano: received invalid stream 'c'
[Jan 11 22:09:05:587066] DEBUG: cpu: 3.361695%
[Jan 11 22:09:08:587630] DEBUG: cpu: 0.270453%
[Jan 11 22:09:11:586689] DEBUG: cpu: 0.252652%
[Jan 11 22:09:14:586579] DEBUG: cpu: 0.246676%
[Jan 11 22:09:17:586716] DEBUG: cpu: 0.257425%
[Jan 11 22:09:20:586907] DEBUG: cpu: 0.256754%
[Jan 11 22:09:23:586943] DEBUG: cpu: 0.250171%
[Jan 11 22:09:26:586866] DEBUG: cpu: 0.247310%
[Jan 11 22:09:29:586910] DEBUG: cpu: 0.250967%
[Jan 11 22:09:32:586775] DEBUG: cpu: 0.245948%
[Jan 11 22:09:35:587115] DEBUG: cpu: 0.258312%
[Jan 11 22:09:38:587829] DEBUG: cpu: 0.276033%
[Jan 11 22:09:41:587594] DEBUG: cpu: 0.274491%
[Jan 11 22:09:44:587215] DEBUG: cpu: 0.273305%
[Jan 11 22:09:47:588024] DEBUG: cpu: 0.276463%
[Jan 11 22:09:50:588116] DEBUG: cpu: 0.277995%
[Jan 11 22:09:53:588789] DEBUG: cpu: 0.272076%
[Jan 11 22:09:56:588694] DEBUG: cpu: 0.280883%
 
Reply
#44
Was there a pilight version with the lua hardware modules that worked without issues?



Can you give me more insight in how to reproduce it? I have the same devices as you, so that helps.
 
Reply
#45
I have only used pilight for two months or so. My goal was to integrate Nexa remotes and light switches to Home Assistant. As far as I remember, this problem was there in the stable version. Then I switched to nightlies and started following this thread. All the versions I have tried have stopped receiving at some point (sending continues to work).

Unfortunately there's not much more I can tell about reproducing it. The nano & RF hardware are from pilight shop, the RPi is a B rev.2, running Buster with the latest updates. Sometimes I can trigger the fault by playing with the Nexa remote, often it just happens by itself.

Just an idea - since the nano is apparently sending something once per second, would it be possible to create a watchdog function to reset/restart the receiver, if nothing is seen for a little while? Of course this wouldn't fix the actual problem, but the end result would work for everyday use. This could also improve the overall reliability even after the problem is found.
 
Reply
#46
Really great that since you only have been using pilight this shortly, you are willing to spent time debugging this issue!

I've set up a test environment again myself and found two more bugs since the last code i shared. I'm testing the same code as below, so we'll see. Would be great if you can test this version as well. The short button presses should be recognized as well now.
PHP Code:
--
-- 
Copyright (CCurlyMo
--
-- 
This Source Code Form is subject to the terms of the Mozilla Public
-- 
Licensev2.0. If a copy of the MPL was not distributed with this
-- fileYou can obtain one at http://mozilla.org/MPL/2.0/.
--

local dump = require "dump";
local lookup = require "lookup";

local M = {}

function 
M.timer(timer)
    
local config pilight.config();
    
local data config.getData();
    
local port lookup(data 'hardware''433nano''comport') or nil;
    
local data1 timer.getUserdata();
    
data1['write'] = 0;

    if 
port == nil then
        
return;
    
end

    local serial 
pilight.io.serial(port);
    if 
serial.open() == false then
        pilight
.log(LOG_ERR"could not connect to device \"" .. port .. "\"");
        return;
    
end
    serial
.read();
    
timer.stop();
end

function M.send(objreasondata)
    if 
reason ~= pilight.reason.SEND_CODE then
        
return;
    
end

    local config 
pilight.config();
    
local data1 config.getData();

    
local code "c:";
    
local match = -1;
    
local pulses = {};

    for 
i in pairs(data['pulses']) do
        
match = -1;
        
local x 0;
        for 
x in pairs(pulses) do
            if 
pulses[x] == data['pulses'][ithen
                match 
x;
                break;
            
end
        end
        
if match == -1 then
            pulses
[#pulses + 1] = data['pulses'][i];
            
code code .. tostring(#pulses - 1);
        
else
            
code code .. tostring(match 1);
        
end
    end
    code 
code .. ";p:";
    for 
x in pairs(pulses) do
        
code code .. tostring(pulses[x])
        if 
#pulses then
            
code code .. ","
        
end
    end
    code 
code .. ";r:" .. data['txrpt'] .. "@";

    
local port data1['hardware']['433nano']['comport'];

    
local serial pilight.io.serial(port);
    
serial.write(code);
end

function M.callback(rwserialline)
    if 
line == nil then
        
return;
    
end

    
if rw == 'read' then
        
if #line > 0 or line == '\n' then
            
local data serial.getUserdata();

            if 
line == '\n' and data['write'] == 0 then
                data
['write'] = 1;
            
end

            
if data['write'] == 1 then
                data
['write'] = 2;
                
local config pilight.config();
                
local data1 config.getData();
                
local minrawlen lookup(data1'registry''hardware''RF433''minrawlen') or 0;
                
local maxrawlen lookup(data1'registry''hardware''RF433''maxrawlen') or 0;
                
local mingaplen lookup(data1'registry''hardware''RF433''mingaplen') or 0;
                
local maxgaplen lookup(data1'registry''hardware''RF433''maxgaplen') or 0;
                
serial.write("s:" .. minrawlen .. "," .. maxrawlen .. "," .. 5200 .. "," .. maxgaplen .. "@");
            
end

            
if data['content'] == nil then
                data
['content'] = "";
            
end

            
if line ~= '\n' then
                data
['content'] = data['content'] .. line;
            else
                
data['content'] = "";
            
end

            local a 
#data['content'];
            
local l a;

            while 
true do
                for 
1ldo
                    if 
string.sub(data['content'], ii) == '@' then
                        l 
i;
                        break;
                    
end
                end

                local c 
string.sub(data['content'], ll);

                if 
== and ~= '@' then
                    
break;
                
end

                
if == '@' then
                    content 
string.sub(data['content'], 1l)

                    
data['content'] = string.sub(data['content'], l+1a);
                    
#data['content'];

                    
local stream = {};
                    
local pulses = {};
                    for 
1ldo
                        
string.sub(contentii);
                        if 
== 'c' then
                            
if string.sub(contenti+1i+1) == ':' then
                                i 
1;
                                for 
ildo
                                    
string.sub(contentx+1x+1);
                                    if 
== ';' then
                                        i 
2;
                                        break;
                                    
end
                                    stream
[#stream+1] = c;
                                
end
                            
else
                                
serial.read();
                                return;
                            
end
                        end
                        
if == 'p' then
                            
if string.sub(contenti+1i+1) == ':' then
                                i 
1;
                                for 
ildo
                                    
string.sub(contentx+1x+1);
                                    if 
== ',' or == '@' then
                                        c 
string.sub(contenti+1x);
                                        
1;
                                        
pulses[#pulses+1] = tonumber(c);

                                        
if #pulses >= 9 then
                                            
pilight.log(LOG_NOTICE"433nano: discarded invalid pulse train");
                                            
serial.read();
                                            return;
                                        
end
                                        
if == '@' then
                                            i 
1;
                                            break;
                                        
end
                                    end
                                end
                            
else
                                
serial.read();
                                return;
                            
end
                        end
                        
if == 'v' then
                            
-- pilight usb nano initialized
                        end
                    end
                    l 
a;

                    if 
data['length'] == nil then
                        data
['length'] = 0;
                    
end
                    
if data['pulses'] == nil then
                        data
['pulses'] = {};
                    
end

                    
if #stream > 0 then
                        
local b 1;
                        for 
1#stream, 1 do
                            
if tonumber(stream[i]) ~= nil then
                            data
['pulses'][b] = pulses[1];
                            
1;
                            
data['pulses'][b] = pulses[stream[i] + 1];
                            
1;
                            
end
                        end

                        data
['length'] = b-1;
                        
local tmp data['content'];
                        
data['content'] = nil;
                        
data['write'] = nil;

                        
local event pilight.async.event();
                        
event.register(pilight.reason.RECEIVED_PULSETRAIN);
                        
event.trigger(getmetatable(data)());

                        
data['pulses'] = {};
                        
data['content'] = tmp;
                        
data['write'] = 2;
                    
end
                end
            end
        end
        serial
.read();
    elseif 
rw == 'disconnect' then
        local timer 
pilight.async.timer();
        
timer.setUserdata(serial.getUserdata()());
        
timer.setCallback("timer");
        
timer.setTimeout(1000);
        
timer.setRepeat(1000);
        
timer.start();
    
end
end

function M.validate()
    
local config pilight.config();
    
local data config.getData();
    
local obj nil;
    
local settings lookup(data'hardware''433nano') or nil;

    if 
settings == nil then
        
return;
    
end

    
for x in pairs(settings) do
        if 
~= 'comport' then
            pilight
.log(LOG_ERR.. "is an unknown parameter")
        
end
    end

    local port 
lookup(data'hardware''433nano''comport') or nil;

    if 
port == nil then
        pilight
.log(LOG_ERR"comport parameter is missing");
    
end

    file 
pilight.io.file(port);

    if 
file.exists() == false then
        pilight
.log(LOG_ERRport .. " does not exist");
    
end

    
if file.open("a+") == false then
        pilight
.log(LOG_ERRport .. " cannot be opened for reading and/or writing");
    
end
    file
.close();
end

function M.run()
    
local config pilight.config();
    
local data config.getData();
    
local obj nil;
    
local port lookup(data'hardware''433nano''comport') or nil;

    if 
port == nil then
        pilight
.log(LOG_ERR"comport parameter is missing");
    
end

    local serial 
pilight.io.serial(port);
    
serial.setBaudrate(57600);
    
serial.setParity('n');
    
serial.setCallback("callback");
    if 
serial.open() == false then
        pilight
.log(LOG_ERR"could not connect to device \"" .. port .. "\"");
    
end
    serial
.read();

    
local data serial.getUserdata();
    
data['write'] = 0;
    
data['hardware'] = '433nano';

    
local event pilight.async.event();
    
event.register(pilight.reason.SEND_CODE);
    
event.setCallback("send");

    return 
1;
end

function M.implements()
    return 
pilight.hardware.RF433;
end

function M.info()
    return {
        
name "433nano",
        
version "4.1",
        
reqversion "7.0",
        
reqcommit "94"
    
}
end

return M
 
Reply
#47
Still working fine here.



And it failed Smile Got an invalid pulse train, and now it stopped receiving. And it works again.



Small update:
PHP Code:
--
-- 
Copyright (CCurlyMo
--
-- 
This Source Code Form is subject to the terms of the Mozilla Public
-- 
Licensev2.0. If a copy of the MPL was not distributed with this
-- fileYou can obtain one at http://mozilla.org/MPL/2.0/.
--

local dump = require "dump";
local lookup = require "lookup";

local M = {}

function 
M.timer(timer)
    
local config pilight.config();
    
local data config.getData();
    
local port lookup(data 'hardware''433nano''comport') or nil;
    
local data1 timer.getUserdata();
    
data1['write'] = 0;

    if 
port == nil then
        
return;
    
end

    local serial 
pilight.io.serial(port);
    if 
serial.open() == false then
        pilight
.log(LOG_ERR"could not connect to device \"" .. port .. "\"");
        return;
    
end
    serial
.read();
    
timer.stop();
end

function M.send(objreasondata)
    if 
reason ~= pilight.reason.SEND_CODE then
        
return;
    
end

    local config 
pilight.config();
    
local data1 config.getData();

    
local code "c:";
    
local match = -1;
    
local pulses = {};

    for 
i in pairs(data['pulses']) do
        
match = -1;
        
local x 0;
        for 
x in pairs(pulses) do
            if 
pulses[x] == data['pulses'][ithen
                match 
x;
                break;
            
end
        end
        
if match == -1 then
            pulses
[#pulses + 1] = data['pulses'][i];
            
code code .. tostring(#pulses - 1);
        
else
            
code code .. tostring(match 1);
        
end
    end
    code 
code .. ";p:";
    for 
x in pairs(pulses) do
        
code code .. tostring(pulses[x])
        if 
#pulses then
            
code code .. ","
        
end
    end
    code 
code .. ";r:" .. data['txrpt'] .. "@";

    
local port data1['hardware']['433nano']['comport'];

    
local serial pilight.io.serial(port);
    
serial.write(code);
end

function invalid_stream(data)
    
pilight.log(LOG_NOTICE"433nano: received invalid stream \'" .. data['content'] .. "'");

    
data['pulses'] = {};
    
data['length'] = 0;
    
data['content'] = '';
    
data['write'] = 2;
end

function M.callback(rwserialline)
    if 
line == nil then
        
return;
    
end

    
if rw == 'read' then
        
if #line > 0 or line == '\n' then
            
local data serial.getUserdata();

            if 
line == '\n' and data['write'] == 0 then
                data
['write'] = 1;
            
end

            
if data['write'] == 1 then
                data
['write'] = 2;
                
local config pilight.config();
                
local data1 config.getData();
                
local minrawlen lookup(data1'registry''hardware''RF433''minrawlen') or 0;
                
local maxrawlen lookup(data1'registry''hardware''RF433''maxrawlen') or 0;
                
local mingaplen lookup(data1'registry''hardware''RF433''mingaplen') or 0;
                
local maxgaplen lookup(data1'registry''hardware''RF433''maxgaplen') or 0;
                
serial.write("s:" .. minrawlen .. "," .. maxrawlen .. "," .. 5200 .. "," .. maxgaplen .. "@");
            
end

            
if data['content'] == nil then
                data
['content'] = "";
            
end

            
if line ~= '\n' then
                data
['content'] = data['content'] .. line;
            else
                
data['content'] = "";
            
end

            local a 
#data['content'];
            
local l a;

            while 
true do
                for 
1ldo
                    if 
string.sub(data['content'], ii) == '@' then
                        l 
i;
                        break;
                    
end
                end

                local c 
string.sub(data['content'], ll);

                if 
== and ~= '@' then
                    
break;
                
end

                
if == '@' then
                    content 
string.sub(data['content'], 1l)

                    
data['content'] = string.sub(data['content'], l+1a);
                    
#data['content'];

                    
local stream = {};
                    
local pulses = {};
                    for 
1ldo
                        
string.sub(contentii);
                        if 
== 'c' then
                            
if string.sub(contenti+1i+1) == ':' then
                                i 
1;
                                for 
ildo
                                    
string.sub(contentx+1x+1);
                                    if 
== ';' then
                                        i 
2;
                                        break;
                                    
end
                                    stream
[#stream+1] = c;
                                
end
                            
else
                                
serial.read();
                                return;
                            
end
                        end
                        
if == 'p' then
                            
if string.sub(contenti+1i+1) == ':' then
                                i 
1;
                                for 
ildo
                                    
string.sub(contentx+1x+1);
                                    if 
== ',' or == '@' then
                                        c 
string.sub(contenti+1x);
                                        
1;
                                        
pulses[#pulses+1] = tonumber(c);

                                        
if #pulses >= 9 then
                                            
invalid_stream(data);
                                            
serial.read();
                                            return;
                                        
end
                                        
if == '@' then
                                            i 
1;
                                            break;
                                        
end
                                    end
                                end
                            
else
                                
serial.read();
                                return;
                            
end
                        end
                        
if == 'v' then
                            
-- pilight usb nano initialized
                        end
                    end
                    l 
a;

                    if 
data['length'] == nil then
                        data
['length'] = 0;
                    
end
                    
if data['pulses'] == nil then
                        data
['pulses'] = {};
                    
end

                    
if #stream > 0 then
                        
local b 1;
                        for 
1#stream, 1 do
                            
if tonumber(stream[i]) ~= nil then
                            data
['pulses'][b] = pulses[1];
                            
1;
                            
data['pulses'][b] = pulses[stream[i] + 1];
                            
1;
                            
end
                        end

                        data
['length'] = b-1;
                        
local tmp data['content'];
                        
data['content'] = nil;
                        
data['write'] = nil;

                        
local event pilight.async.event();
                        
event.register(pilight.reason.RECEIVED_PULSETRAIN);
                        
event.trigger(getmetatable(data)());

                        
data['pulses'] = {};
                        
data['content'] = tmp;
                        
data['write'] = 2;
                    
end
                end
            end
        end
        serial
.read();
    elseif 
rw == 'disconnect' then
        local timer 
pilight.async.timer();
        
timer.setUserdata(serial.getUserdata()());
        
timer.setCallback("timer");
        
timer.setTimeout(1000);
        
timer.setRepeat(1000);
        
timer.start();
    
end
end

function M.validate()
    
local config pilight.config();
    
local data config.getData();
    
local obj nil;
    
local settings lookup(data'hardware''433nano') or nil;

    if 
settings == nil then
        
return;
    
end

    
for x in pairs(settings) do
        if 
~= 'comport' then
            pilight
.log(LOG_ERR.. "is an unknown parameter")
        
end
    end

    local port 
lookup(data'hardware''433nano''comport') or nil;

    if 
port == nil then
        pilight
.log(LOG_ERR"comport parameter is missing");
    
end

    file 
pilight.io.file(port);

    if 
file.exists() == false then
        pilight
.log(LOG_ERRport .. " does not exist");
    
end

    
if file.open("a+") == false then
        pilight
.log(LOG_ERRport .. " cannot be opened for reading and/or writing");
    
end
    file
.close();
end

function M.run()
    
local config pilight.config();
    
local data config.getData();
    
local obj nil;
    
local port lookup(data'hardware''433nano''comport') or nil;

    if 
port == nil then
        pilight
.log(LOG_ERR"comport parameter is missing");
    
end

    local serial 
pilight.io.serial(port);
    
serial.setBaudrate(57600);
    
serial.setParity('n');
    
serial.setCallback("callback");
    if 
serial.open() == false then
        pilight
.log(LOG_ERR"could not connect to device \"" .. port .. "\"");
    
end
    serial
.read();

    
local data serial.getUserdata();
    
data['write'] = 0;
    
data['hardware'] = '433nano';

    
local event pilight.async.event();
    
event.register(pilight.reason.SEND_CODE);
    
event.setCallback("send");

    return 
1;
end

function M.implements()
    return 
pilight.hardware.RF433;
end

function M.info()
    return {
        
name "433nano",
        
version "4.1",
        
reqversion "7.0",
        
reqcommit "94"
    
}
end

return M
 
Reply
#48
I just updated to this last version, running it now. The previous version indeed seemed more responsive than the earlier ones.
 
Reply
#49
Worked for 9.5 hours, until this:


Code:
[Jan 13 08:27:58:685555] DEBUG: lua serial read on state #0
[Jan 13 08:27:59:684425] DEBUG: lua serial read on state #0
[Jan 13 08:28:00:683324] DEBUG: lua serial read on state #0
[Jan 13 08:28:01:505057] DEBUG: cpu: 3.669280%
[Jan 13 08:28:01:682229] DEBUG: lua serial read on state #0
[Jan 13 08:28:02:681063] DEBUG: lua serial read on state #0
[Jan 13 08:28:03:679939] DEBUG: lua serial read on state #0
[Jan 13 08:28:04:505614] DEBUG: cpu: 3.653826%
[Jan 13 08:28:04:695118] DEBUG: lua serial read on state #0
[Jan 13 08:28:05:694199] DEBUG: lua serial read on state #0
[Jan 13 08:28:06:693185] DEBUG: lua serial read on state #0
[Jan 13 08:28:06:758691] DEBUG: lua serial read on state #0
[Jan 13 08:28:06:792656] NOTICE: 433nano: received invalid stream 'c:102022002022'
[Jan 13 08:28:07:505349] DEBUG: cpu: 4.833897%
[Jan 13 08:28:10:505345] DEBUG: cpu: 0.248471%
[Jan 13 08:28:13:505316] DEBUG: cpu: 0.249776%
[Jan 13 08:28:16:505135] DEBUG: cpu: 0.244485%
[Jan 13 08:28:19:506445] DEBUG: cpu: 0.283016%
[Jan 13 08:28:22:505998] DEBUG: cpu: 0.268510%
[Jan 13 08:28:25:506766] DEBUG: cpu: 0.275400%
[Jan 13 08:28:28:506060] DEBUG: cpu: 0.260571%
[Jan 13 08:28:31:506426] DEBUG: cpu: 0.263971%
 
Reply
#50
I have that as well sometimes, but normally it started working again a short while after.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  433nano stops receiving with FHEM RichiG 1 35 03-27-2020, 07:36 PM
Last Post: curlymo
  communication between main daemon and clientized daemon stops tomk 29 3,137 05-06-2019, 08:57 PM
Last Post: curlymo
Bug Bug report: WIFI dongle stops when gpio_switch.gpio = 20 woutput 16 6,044 01-03-2018, 10:11 PM
Last Post: zackdvd
  pilight for dummies? receiving door contact state DazRave 7 4,617 10-03-2014, 10:01 PM
Last Post: creamers
  Sending and receiving at the same time geerttttt 2 1,901 07-09-2014, 01:12 AM
Last Post: scorpydude

Forum Jump:


Browsing: 1 Guest(s)