![]() |
|
Script reboot failing - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Script reboot failing (/showthread.php?tid=5457) |
Script reboot failing - fbrun@domizy - 10.06.2024 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. RE: Script reboot failing - Daniel - 10.06.2024 In General configuration there is Block unsafe functions in scripts: Make sure to disable it. RE: Script reboot failing - fbrun@domizy - 10.06.2024 (10.06.2024, 10:05)Daniel Wrote: In General configuration there is Block unsafe functions in scripts: Thanks Daniel ! RE: Script reboot failing - JMM - 24.06.2025 Hi, I have the same problem as fbrun@domizy to reboot LM5, I don't understand Daniel's answer BR RE: Script reboot failing - Daniel - 24.06.2025 Utilities-> General configuration... RE: Script reboot failing - JMM - 24.06.2025 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 RE: Script reboot failing - Daniel - 24.06.2025 What is the device you have problem with? RE: Script reboot failing - JMM - 24.06.2025 It's : FTDI - FT232R USB UART RE: Script reboot failing - Daniel - 24.06.2025 Did you check if just reboot helps? I think it will need power down anyway. RE: Script reboot failing - JMM - 24.06.2025 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!! RE: Script reboot failing - JMM - 24.06.2025 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({})
RE: Script reboot failing - admin - 25.06.2025 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. RE: Script reboot failing - JMM - 26.06.2025 Thanks Daniel, but is not work RE: Script reboot failing - JMM - 04.07.2025 Hello, Is there a way from a Lua script (or system command via os.execute()) to completely cut and restore the 5V power supply to a USB port on the LM5? BR RE: Script reboot failing - Erwin van der Zwart - 04.07.2025 Could be “block unsafe scripts” in general configuration io.writefile could be blocked, not sure if that is also on LM.. RE: Script reboot failing - Daniel - 04.07.2025 (04.07.2025, 12:42)Erwin van der Zwart Wrote: Could be “block unsafe scripts” in general configuration io.writefile could be blocked, not sure if that is also on LM.. No it's not. RE: Script reboot failing - admin - 07.07.2025 What is your LM hardware version (printed on the sticker on the side of the housing)? Create an event script mapped to a binary object to control USB power power: Code: state = event.getvalue() and 'high' or 'low'
io.writefile('/dev/usbctrl', state)Check System config > Status > System log, you should see that USB converter is disconnected when the port is powered down. Similar to this: Code: Jul 7 11:17:03 LogicMachine kern.info kernel: [11838588.128976] cp210x 1-1:1.0: device disconnected
Jul 7 11:17:03 LogicMachine kern.info kernel: [11838588.128729] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
Jul 7 11:17:03 LogicMachine kern.info kernel: [11838588.128345] usb 1-1: USB disconnect, device number 4 |