Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
- fixed issue with rs232_strbaud() which incorrectly returned bogus n…
Browse files Browse the repository at this point in the history
…umber

  instead of correct text
- fixed issue with rs232_to_string() function which returned enum numbers
  instead of correct text
- add simple example script for Lua
- (Win) add separate resource for Lua DLL
- bump version to 1.0.0
  • Loading branch information
ynezz committed Jan 6, 2010
1 parent 86ba7ed commit 879f398
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 19 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
@@ -1 +1 @@
Petr Štetiar <ynezz@true.cz>
Petr Stetiar <ynezz@true.cz>
2 changes: 1 addition & 1 deletion COPYING
@@ -1,4 +1,4 @@
Copyright (c) 2009 Petr Štetiar <ynezz@true.cz>, Gaben Ltd.
Copyright (c) 2009 Petr Stetiar <ynezz@true.cz>, Gaben Ltd.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
4 changes: 2 additions & 2 deletions bindings/lua/luars232.c
Expand Up @@ -39,8 +39,8 @@

#define MODULE_TIMESTAMP __DATE__ " " __TIME__
#define MODULE_NAMESPACE "luars232"
#define MODULE_VERSION "0.0.5"
#define MODULE_BUILD "$Id$"
#define MODULE_VERSION "1.0.0"
#define MODULE_BUILD "$Id: luars232.c 13 2010-01-06 09:15:31Z sp $"
#define MODULE_COPYRIGHT "Copyright (c) 2009 Petr Stetiar <ynezz@true.cz>, Gaben Ltd."

static struct {
Expand Down
44 changes: 44 additions & 0 deletions doc/example.lua
@@ -0,0 +1,44 @@
rs232 = require("luars232")

-- Linux
-- port_name = "/dev/ttyS0"

-- Windows
port_name = "COM1"

local out = io.stderr

-- open port
local e, p = rs232.open(port_name)
if e ~= rs232.RS232_ERR_NOERROR then
-- handle error
out:write(string.format("can't open serial port '%s', error: '%s'\n",
port_name, rs232.error_tostring(e)))
return
end

-- set port settings
assert(p:set_baud_rate(rs232.RS232_BAUD_115200) == rs232.RS232_ERR_NOERROR)
assert(p:set_data_bits(rs232.RS232_DATA_8) == rs232.RS232_ERR_NOERROR)
assert(p:set_parity(rs232.RS232_PARITY_NONE) == rs232.RS232_ERR_NOERROR)
assert(p:set_stop_bits(rs232.RS232_STOP_1) == rs232.RS232_ERR_NOERROR)
assert(p:set_flow_control(rs232.RS232_FLOW_OFF) == rs232.RS232_ERR_NOERROR)

out:write(string.format("OK, port open with values '%s'\n", tostring(p)))

-- read with timeout
local read_len = 1 -- read one byte
local timeout = 100 -- in miliseconds
local err, data_read, size = p:read(read_len, timeout)
assert(e == rs232.RS232_ERR_NOERROR)

-- write without timeout
err, len_written = p:write("test")
assert(e == rs232.RS232_ERR_NOERROR)

-- write with timeout 100 msec
err, len_written = p:write("test\n", timeout)
assert(e == rs232.RS232_ERR_NOERROR)

-- close
assert(p:close() == rs232.RS232_ERR_NOERROR)
12 changes: 6 additions & 6 deletions src/resource.rc
@@ -1,8 +1,8 @@
#include "afxres.h"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,5
PRODUCTVERSION 0,0,0,5
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -17,14 +17,14 @@ BEGIN
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "Petr Stetiar"
VALUE "CompanyName", "Petr Stetiar, Gaben Ltd."
VALUE "FileDescription", "librs232 - Library for serial communication over RS232"
VALUE "FileVersion", "0, 0, 0, 5"
VALUE "FileVersion", "1, 0, 0, 0"
VALUE "InternalName", "librs232"
VALUE "LegalCopyright", "Copyright (c) 2008-2009 Petr Stetiar"
VALUE "LegalCopyright", "Copyright (c) 2008-2010 Petr Stetiar, Gaben Ltd."
VALUE "OriginalFilename", "librs232.dll"
VALUE "ProductName", "librs232 - Library for serial communication over RS232"
VALUE "ProductVersion", "0, 0, 0, 5"
VALUE "ProductVersion", "1, 0, 0, 0"
END
END
BLOCK "VarFileInfo"
Expand Down
34 changes: 34 additions & 0 deletions src/resource_lua.rc
@@ -0,0 +1,34 @@
#include "afxres.h"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "Petr Stetiar, Gaben Ltd."
VALUE "FileDescription", "luars232 - Lua library for serial communication over RS232"
VALUE "FileVersion", "1, 0, 0, 0"
VALUE "InternalName", "luars232"
VALUE "LegalCopyright", "Copyright (c) 2009 Petr Stetiar, Gaben Ltd."
VALUE "OriginalFilename", "luars232.dll"
VALUE "ProductName", "luars232 - Library for serial communication over RS232"
VALUE "ProductVersion", "1, 0, 0, 0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
12 changes: 6 additions & 6 deletions src/rs232.c
Expand Up @@ -33,7 +33,7 @@

static const char *
rs232_baud[] = {
"2400"
"2400",
"4800",
"9600",
"19200",
Expand Down Expand Up @@ -204,11 +204,11 @@ rs232_to_string(struct rs232_port_t *p)
" parity: %s, stop bits: %s,"
" flow control: %s",
p->dev,
rs232_baud[p->baud],
rs232_data[p->data],
rs232_parity[p->parity],
rs232_stop[p->stop],
rs232_flow[p->flow]);
rs232_strbaud(p->baud),
rs232_strdata(p->data),
rs232_strparity(p->parity),
rs232_strstop(p->stop),
rs232_strflow(p->flow));

return str;
}
Expand Down
6 changes: 3 additions & 3 deletions windows/vs2k5/librs232lua/librs232lua.vcproj
Expand Up @@ -142,10 +142,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="lua51.lib"
AdditionalDependencies="lua5.1.lib"
OutputFile="luars232.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\..\build\win32\Release\"
AdditionalLibraryDirectories="d:\Lua\5.1\lib;..\..\..\..\..\build\win32\Release\"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
Expand Down Expand Up @@ -219,7 +219,7 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\..\..\src\resource.rc"
RelativePath="..\..\..\src\resource_lua.rc"
>
</File>
</Filter>
Expand Down

0 comments on commit 879f398

Please sign in to comment.