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.

RS232
#3
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
Reply


Messages In This Thread
RS232 - by JMM - 11.06.2025, 08:35
RE: RS232 - by Daniel - 11.06.2025, 08:38
RE: RS232 - by JMM - 11.06.2025, 08:53
RE: RS232 - by Daniel - 11.06.2025, 08:56
RE: RS232 - by JMM - 11.06.2025, 09:00
RE: RS232 - by Erwin van der Zwart - 11.06.2025, 14:27
RE: RS232 - by JMM - 11.06.2025, 15:16

Forum Jump: