Code:
-- Fonction pour vérifier si le port est libre (sans lsof)
function isPortFree()
local test_port = serial.open('/dev/RS232', {
baudrate = 1200,
databits = 7,
stopbits = 1,
parity = 'even',
duplex = 'half'
})
if test_port then
test_port:close()
log("Port libre")
return true
else
log("Port occupé ou inaccessible")
return false
end
end
isPortFree()
And error log :
test le port rs232 11.06.2025 10:45:53
User script:3: attempt to index global 'serial' (a nil value)
stack traceback:
User script:3: in function 'isPortFree'
User script:21: in main chunk
Jean-Marc