lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am 14.09.2013 00:41 schröbte Sean Conner:
It was thus said that the Great Jayanth Acharya once stated:
Presently I am using the library/module "luars232" installed via luarocks.
I am using this on a Debian Linux machine, on the USB-serial port

I can access this port perfectly well using tools like picocom or minicom,
i.e. have proper bi-directional communication.

However, when I try this snippet:

rs232 = require("luars232")

port_name = "/dev/ttyUSB0"

local e, p =
print(e, p)

I get the output:
2    nil

Indicating an error in opening the port. One thing that I am pretty sure
of, is that this isn't a permission issue. Since I have already added my
userid to the "dialout" group, and use the "picocom" tool similarly. Also,
I am sure that the port is not in use by any other app/tool at the time of
running the lua snippet.

However, I am not sure how to debug this further.

   Under Linux, an errno of 2 (and I'm assuming that's what's being return
from means "No such file or directory" so I would double check
that "/dev/ttyUSB0" does indeed exist (perhaps you need to plug in the
USB-serial device into the computer).

Good idea, but in this case a custom error enum[1] is used where 2 is RS232_ERR_OPEN. Since this is running on Linux the place where the error occurs is probably here[2]. So you could recompile with a suitable definition for the DBG macro to get the errno value and an error string, or use `strace` ...

    strace -o trace.txt -- ./your-lua-script