This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script reboot failing
#1
Hi,

I'm trying to reboot a wiser for KNX with a script.
Using this "os.execute('reboot')", the server doesn't reboot.

I also tested this "os.execute(reboot)" but i have the same result.


Respectfully,
BRUN Félix.
Reply
#2
In General configuration there is Block unsafe functions in scripts:
Make sure to disable it.
------------------------------
Ctrl+F5
Reply
#3
(10.06.2024, 10:05)Daniel Wrote: In General configuration there is Block unsafe functions in scripts:
Make sure to disable it.

Thanks Daniel !
Reply
#4
Hi,
I have the same problem as fbrun@domizy to reboot LM5, I don't understand Daniel's answer
BR
Jean-Marc
Reply
#5
Utilities-> General configuration...
------------------------------
Ctrl+F5
Reply
#6
Thanks Daniel, it's OK

Is it also possible to reset the USB port by script, I have a Uart rs232 which from time to time blocks and I am obliged to unplug and replug
Jean-Marc
Reply
#7
What is the device you have problem with?
------------------------------
Ctrl+F5
Reply
#8
It's : FTDI - FT232R USB UART
Jean-Marc
Reply
#9
Did you check if just reboot helps? I think it will need power down anyway.
------------------------------
Ctrl+F5
Reply
#10
Yes reboot helps, I read the frame of a Linky electric meter every minute, some day at 8:00 a.m. the meter sends the tariff change and the ft232 blocks so either reboot or disconnect reconnect

It's not from the script!!
Jean-Marc
Reply
#11
Code:
-- Script USB Reset Final pour LM5 OpenRB
-- Version simplifiée et optimisée

local function write_file_safe(file, value)
    local f = io.open(file, "w")
    if f then
        local success, err = pcall(function()
            f:write(value)
            f:close()
        end)
        if success then
            log("✓ Reset: " .. file)
            return true
        end
    end
    return false
end

-- Configuration LM5 validée
local USB_BUSES = {
    "/sys/devices/platform/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/usb1",
    "/sys/devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2"
}

-- Reset USB rapide et efficace
local function restart_usb_lm5()
    log("=== Redémarrage USB LM5 ===")
   
    for i, bus_path in ipairs(USB_BUSES) do
        log("Reset bus USB" .. i .. "...")
       
        -- Désauthoriser le bus
        write_file_safe(bus_path .. "/authorized", "0")
        os.execute("sleep 1")
       
        -- Réauthoriser le bus 
        write_file_safe(bus_path .. "/authorized", "1")
        os.execute("sleep 1")
    end
   
    log("✓ Reset USB terminé")
   
    -- Attendre la détection des périphériques
    os.execute("sleep 2")
   
    -- Vérification
    log("Vérification des périphériques USB...")
    local handle = io.popen("dmesg | grep -E 'ttyUSB|ftdi_sio|SerialNumber' | tail -5 2>/dev/null")
    if handle then
        for line in handle:lines() do
            log("  > " .. line)
        end
        handle:close()
    end
   
    log("=== Fin du redémarrage ===")
end

-- Fonction principale simplifiée
local function main(arg)
    if #arg == 0 or arg[1] == "restart" then
        restart_usb_lm5()
    else
        log("Usage: main({\"restart\"}) ou main({})")
    end
end

-- Auto-exécution
main({})
It's OK With the help of Claude.ai  Wink
Jean-Marc
Reply
#12
You can power cycle USB port like this:
Code:
io.writefile('/dev/usbctrl', 'low')
os.sleep(1)
io.writefile('/dev/usbctrl', 'high')
os.sleep(1)

Make sure that serial port is not open in a script when doing the power cycle. Otherwise the port name might change and script won't work.
Reply


Forum Jump: