Coder Social home page Coder Social logo

librs232's Introduction

This project is not maintained anymore and marked as archived. I've lost interest in closed source operating systems like Windows, so I simply don't want to spend my time on anything related to the Windows ecosystem.

Anyway @srdgame has forked this project and it seems to be alive and in a good shape so feel free to look at it as a viable alternative.

librs232's People

Contributors

jasperla avatar minoki avatar vitcil avatar ynezz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

librs232's Issues

Working on Mac OS X

I managed to get librs232 to compile on OS X 10.6.4. The autogen.sh script uses libtoolize and OS X uses glibtoolize. I just changed the line to glibtoolize. I have been able to make other projects compile in OS X and Linux by using the autoreconf script.

I also had to add the O_NDELAY flag to the open() call in rs232_linux.c (line 423). This may not be necessary. If I used the cu.usbserial*** version instead of the tty.usbserial*** version of the device it worked. It may also be possible to use the O_NONBLOCK flag instead and then change the port configuration after the port is opened. This has something to do with the USB/Serial converter drivers and the carrier detect signal.

I have been using the Lua bindings on a little project of mine and so far they seem to work fine on OS X. I haven't tested them much but what I have done has worked well.

failed build on macos

sudo luarocks install luars232
Password:
Installing https://luarocks.org/luars232-1.0.3-1.src.rock...
Using https://luarocks.org/luars232-1.0.3-1.src.rock... switching to 'build' mode
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c src/rs232.c -o src/rs232.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c src/rs232_posix.c -o src/rs232_posix.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c bindings/lua/luars232.c -o bindings/lua/luars232.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
bindings/lua/luars232.c:386:8: error: unknown type name 'luaL_reg'; did you mean
      'luaL_Reg'?
static luaL_reg port_methods[] = {
       ^~~~~~~~
       luaL_Reg
/usr/local/include/lauxlib.h:26:3: note: 'luaL_Reg' declared here
} luaL_Reg;
  ^
bindings/lua/luars232.c:426:8: error: unknown type name 'luaL_reg'; did you mean
      'luaL_Reg'?
static luaL_reg port_functions[] = {
       ^~~~~~~~
       luaL_Reg
/usr/local/include/lauxlib.h:26:3: note: 'luaL_Reg' declared here
} luaL_Reg;
  ^
bindings/lua/luars232.c:432:69: error: unknown type name 'luaL_reg'; did you mean
      'luaL_Reg'?
static void create_metatables(lua_State *L, const char *name, const luaL_reg *methods)
                                                                    ^~~~~~~~
                                                                    luaL_Reg
/usr/local/include/lauxlib.h:26:3: note: 'luaL_Reg' declared here
} luaL_Reg;
  ^
bindings/lua/luars232.c:437:2: warning: implicit declaration of function
      'luaL_register' is invalid in C99 [-Wimplicit-function-declaration]
        luaL_register(L, NULL, methods);
        ^
1 warning and 3 errors generated.

Error: Build error: Failed compiling object bindings/lua/luars232.o

Librarry doesn't build under Lua 5.2

Environment
Linux vbox 3.2.0-52-generic #78-Ubuntu SMP Fri Jul 26 16:21:44 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Installed lua5.2 libs
liblua5.2-0 - Shared library for the Lua interpreter version 5.2
liblua5.2-0-dbg - Debug symbols for the Lua shared library interpreter
liblua5.2-dev - Development files for the Lua language version 5.2

Even installed some 5.0 libraries
rfg@vbox:~/librs232$ sudo apt-get install liblualib50-dev
sudo: unable to resolve host vbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
liblua50 liblua50-dev liblualib50 lua50
The following NEW packages will be installed:
liblua50 liblua50-dev liblualib50 liblualib50-dev lua50
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.

  1. Even modified for l in "$lua_suffix" "" "52" "5.2" "51" "5.1" "50" "5.0" ; do
    but it didn't detect the Lua installation

checking for Lua headers and librairies with pkg-config...
checking for Lua compiling and linking... no
configure: WARNING:
*** Lua (>=5.0) headers and/or librairies couldn't be found in your system.
*** Try to install liblua, liblualib and liblua-dev with your software package manager.
*** librs232 will be built without Lua bindings library.

  1. Once again, started afresh with a new git clone and liblua50 liblua50-dev liblualib50 lua50 extra libs installed
    This time, the ./configuire did detect lua but in the make phase, I get a compiler errors

luars232.c: In function 'lua_port_open':
luars232.c:112:3: error: implicit declaration of function 'lua_pushinteger' [-Werror=implicit-function-declaration]
luars232.c: In function 'lua_port_read':
luars232.c:169:3: error: implicit declaration of function 'luaL_checkinteger' [-Werror=implicit-function-declaration]
luars232.c: In function 'lua_port_get_strbaud':
luars232.c:381:1: error: implicit declaration of function 'luaL_optinteger' [-Werror=implicit-function-declaration]
luars232.c: In function 'create_metatables':
luars232.c:439:2: error: implicit declaration of function 'lua_setfield' [-Werror=implicit-function-declaration]
luars232.c:440:2: error: implicit declaration of function 'luaL_register' [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[2]: *** [luars232.lo] Error 1
make[2]: Leaving directory /home/rfg/librs232/bindings/lua' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/home/rfg/librs232/bindings'
make: *** [all-recursive] Error 1

Greetings
Rafael

Unable to load dll

Tried both 1.0.0 and 1.0.3 release under Lua 5.3.4 and the output is:

> local rs232 = require('luars232')
error loading module 'luars232' from file 'D:\Lua\luars232.dll':
        找不到指定的模块。

stack traceback:
        [C]: in ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?

Under Lua 5.2 the output is:

> local rs232 = require('luars232')
error loading module 'luars232' from file 'D:\Lua\52\luars232.dll':
        %1 不是有效的 Win32 应用程序。

stack traceback:
        [C]: in ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?

rs232_end

没有任何地方调用rs232_end,导致内存泄露

fails to build

I am trying to build lua on arch linux with lua 5.1 installed. My configure looks like this:
./configure --with-lua-inc=/usr/include/lua5.1/ --with-lua-lib=/usr/lib/lua/5.1/
make
Making all in include
make[1]: Entering directory '/home/comotion/code/lua/librs232/include'
Making all in librs232
make[2]: Entering directory '/home/comotion/code/lua/librs232/include/librs232'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/comotion/code/lua/librs232/include/librs232'
make[2]: Entering directory '/home/comotion/code/lua/librs232/include'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/home/comotion/code/lua/librs232/include'
make[1]: Leaving directory '/home/comotion/code/lua/librs232/include'
Making all in src
make[1]: Entering directory '/home/comotion/code/lua/librs232/src'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/comotion/code/lua/librs232/src'
Making all in bindings
make[1]: Entering directory '/home/comotion/code/lua/librs232/bindings'
Making all in lua
make[2]: Entering directory '/home/comotion/code/lua/librs232/bindings/lua'
/bin/sh ../../libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME="librs232" -DPACKAGE_TARNAME="librs232" -DPACKAGE_VERSION="0.0.1" -DPACKAGE_STRING="librs232\ 0.0.1" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="librs232" -DVERSION="0.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DBUILD_LUA=1 -I. -I../../include -Wall -ansi -pedantic -W -Wmissing-prototypes -Wmissing-declarations -Werror -Wno-unused-but-set-variable -std=gnu99 -O2 -g -O2 -MT luars232.lo -MD -MP -MF .deps/luars232.Tpo -c -o luars232.lo luars232.c
libtool: compile: gcc -DPACKAGE_NAME="librs232" -DPACKAGE_TARNAME="librs232" -DPACKAGE_VERSION="0.0.1" "-DPACKAGE_STRING="librs232 0.0.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="" -DPACKAGE="librs232" -DVERSION="0.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DBUILD_LUA=1 -I. -I../../include -Wall -ansi -pedantic -W -Wmissing-prototypes -Wmissing-declarations -Werror -Wno-unused-but-set-variable -std=gnu99 -O2 -g -O2 -MT luars232.lo -MD -MP -MF .deps/luars232.Tpo -c luars232.c -fPIC -DPIC -o .libs/luars232.o
luars232.c:389:8: error: unknown type name ‘luaL_reg’
static luaL_reg port_methods[] = {
^
luars232.c:390:2: error: braces around scalar initializer [-Werror]
{ "__tostring", lua_port_tostring },
^
luars232.c:390:2: error: (near initialization for ‘port_methods[0]’) [-Werror]
luars232.c:390:2: error: initialization makes integer from pointer without a cast [-Werror]
luars232.c:390:2: error: (near initialization for ‘port_methods[0]’) [-Werror]
luars232.c:390:2: error: initializer element is not computable at load time
luars232.c:390:2: error: (near initialization for ‘port_methods[0]’)
luars232.c:390:2: error: excess elements in scalar initializer [-Werror]
luars232.c:390:2: error: (near initialization for ‘port_methods[0]’) [-Werror]
luars232.c:391:2: error: braces around scalar initializer [-Werror]
{ "__gc", lua_port_close },
^
[.. snip a lot of similar errors...]

possible leak?

in this line a call to luaL_checkstring() is done. Upon an error, this will not return iirc (long jump).

But by then p will already contain the return value from p = rs232_init(); (on this line).

Shouldn't the assignment to p be reversed to prevent a leak in case luaL_checkstring() does error?

librs232 in LuaDist under win32 - error 2

In current LuaDist the following lines fail under win32 ( tested with Win8, Win7, WinXP ):

local rs232 = require"luars232"
print( rs232.open("COM1"))

It always gives "error 2". When trying the same with e.g. putty, then COM1 can be opened.

After a some research I found that the reason might be a bug in rs232_windows.c lines 390ff:

Line 390: wchar_t *wname = a2w(fix_device_name(p->dev));
^^^ here you change filename to unicode
...
...
wx->fd = CreateFile(wname, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
^^^ but here you call CreateFile() instead of CreateFileW(), meaning you pass Unicode-Devicename to Ansi-Dll Function - which fails every time. At least LuaDist is compiled against Mingw, which seems to default to Ansi-Build, which uses the CreateFileA() call...

In windows,luars232 can not open "COM24" but can open "COM4"

I can not open "COM24" with luars232,but when I change the com port name to "COM4",luars232 open successfully.And I can open "COM24" with HyperTerminal (hypertrm.exe).

I examine the code of luars232,but have not found the reason,and I have not VS2005,so I just submit this issue here.

Thanks.

Bug on windows.

In rs232_windows.c fail.

392 line, char *wname = fix_device_name(p->dev);
wname is a static buffer, not malloced, so
It should not be free at 407 line.

Please check this.

Compiling error

[josema@marengo librs232]$ ./autogen.sh
running: autoreconf --force --install --symlink --verbose
./autogen.sh: línea 6: autoreconf: no se encontró la orden
error: while running 'autoreconf --force --install --symlink --verbose'
[josema@marengo librs232]$

"no se encontró la orden" means "command not found" or similar

Error when installing luars232 with "luarocks install luars232"

Hi ynezz,

i tried to install luars232 using luarocks today and got an error message on my Mac and on a Linux system, claiming 'Error: Directory 'invalid' not found'.

I took a look into luars232-1.0.3-1.rockspec and found a strange looking entry

copy_directories = {
"invalid"
},

After i had commented out that entry, i was able to build luars232 successfully on both my boxes.

BR

Sergeij

Fix timeouts in Posix functions for values > 1 second

FYI, the routines rs232_read_timeout_forced(), rs232_read_timeout(), and
rs232_write_timeout() in rs232_posix.c assume that timeout is less than a
second. I made the following change to my copy of the previous release to
work around a problem that I encountered while testing:

  • tv.tv_sec = 0;
  • tv.tv_usec = timeout * 1000;
  • tv.tv_sec = (timeout * 1000) / 1000000;
  • tv.tv_usec = (timeout * 1000) % 1000000;

Failed to compile on OS X Lion, B460800 undeclared

I've read the instructions as best I could and did as much research as possible. I'm not a guru, so forgive my ignorance, please. :)

On Mac OSX Lion, I followed your instructions for build, including:
chmod +x autoconf.sh
./autoconf.sh
./configure --prefix=$PWD/dist
and
sudo make install

I also ran it with and without the reported request to re-run glibtoolize after making the two entries that it requested.

The tail of sudo make install is as follows:

rs232_linux.c: In function 'rs232_set_baud':
rs232_linux.c:534: error: 'B460800' undeclared (first use in this function)
rs232_linux.c:534: error: (Each undeclared identifier is reported only once
rs232_linux.c:534: error: for each function it appears in.)
make[1]: *** [rs232_linux.lo] Error 1
make: *** [install-recursive] Error 1

So..... what'd I do?

The library does not support device name with more than 30 characters

The support for serial device file name longer than 30 characters is needed for Linux, where a USB-to-serial device may have a very long name. The actual device name for USB-to-serial device, not the symlink, is used to achieve consistent name after the USB device is unplugged/plugged. An example device name on Ubuntu: /dev/serial/by-id/usb_to_serial_ftdi_FTDIXYZ_port0_0.

OpenWRT Attitude Adjustment

Please provide step-by-step instructions on how to build for OpenWRT Attitude Adjustment. Currently I am using the ImageBuilder to create my own firmware, and I would like to integrate luci modules which interact with an Arduino connected to the internal serial port.

fails to install from luarocks

sudo luarocks-5.1 install luars232
Installing https://rocks.moonscript.org/luars232-1.0.3-1.src.rock...
Using https://rocks.moonscript.org/luars232-1.0.3-1.src.rock... switching to 'build' mode
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/rs232.c -o src/rs232.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/rs232_posix.c -o src/rs232_posix.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
gcc -O2 -fPIC -I/usr/include/lua5.1 -c bindings/lua/luars232.c -o bindings/lua/luars232.o -DLUAROCKS_HACK -std=gnu99 -Iinclude
gcc -shared -o luars232.so -L/usr/lib src/rs232.o src/rs232_posix.o bindings/lua/luars232.o

Error: Directory 'invalid' not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.