srdgame/librs232

luajit userdata error

Opened this issue · 0 comments

there seems to be an error with checking for the correct userdata in luajit

here is my example code

rs232 = require("luars232")

err, port = rs232.open("/dev/ttyUSB0", {
  baud         = '_115200';
  data_bits    = '_8';
  parity       = 'NONE';
  stop_bits    = '_1';
  flow_control = 'OFF';
  rts          = 'ON';
})
assert(err == rs232.RS232_ERR_NOERROR)

port:write("help\r\n")
print(port:read(64, 5000))
port:close()

and when i run it in the different interpreters i get an error with jit

$ luajit threadSerial.lua 
luajit: threadSerial.lua:13: calling 'write' on bad self (luars232 expected, got userdata)
stack traceback:
        [C]: in function 'write'
        threadSerial.lua:13: in main chunk
        [C]: at 0x55797089c4
$ lua5.1 threadSerial.lua 
<correct serial output>

i am running on a raspberry pi 3 with these lua versions

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2022 Mike Pall. https://luajit.org/