Robotframework Serial library not throwing error or exception when unable to open serial port

I am using Serial Library in robot framework like this

Library           SerialLibrary

If my serial port is already opened in minicom Robot framework is unable to read from that and its logical, but the library is not throwing any error exception to notify me, my serial port code looks like this

Open Serial Port
    [Arguments]    ${EXPECTED_PORT}
    Add Port   ${EXPECTED_PORT}
    ...        baudrate=115200
    ...        bytesize=8
    ...        parity=N
    ...        stopbits=1
    ...        timeout=999

Close Serial Port
    Delete All Ports

Am i missing to add something?

I saw your question on stack overflow …

Im not 100% sure but this is speculation. Minicom itself writes a lock file to typically /var/lock/ or /tmp/ directory on Linux at least that prevents another instance if minicom to use that. Neither

Quickly scanned thru the robotframework-seriallibrary’s code and it looked like it is just wrapper for PySerial and on seriallibrary’s own codebase, there’s no handling for lock files, neither on PySerial.

Now, there is exclusive kwarg in pyserial that says:

exclusive (bool) – Set exclusive access mode (POSIX only). A port cannot be opened in exclusive access mode if it is already open in exclusive access mode.

Try that and see if it helps ? Depending on how minicom sets up the port, this might or might not work – probably will if minicom does flock too when it creates a lockfile.

However, in general, on posix system, what are are experiencing is what i’d say how things are supposed to work and if you need extra features, you probably have to implement those yourself. Checking if lock file exists before opening a port should be straight forward “does file exists” type of operation once you know where the lockfile is actually stored …

1 Like