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

Commit 879f398

Browse files
committed
- fixed issue with rs232_strbaud() which incorrectly returned bogus number
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
1 parent 86ba7ed commit 879f398

File tree

8 files changed

+97
-19
lines changed

8 files changed

+97
-19
lines changed

AUTHORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Petr Štetiar <[email protected]>
1+
Petr Stetiar <[email protected]>

COPYING

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009 Petr Štetiar <[email protected]>, Gaben Ltd.
1+
Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

bindings/lua/luars232.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
#define MODULE_TIMESTAMP __DATE__ " " __TIME__
4141
#define MODULE_NAMESPACE "luars232"
42-
#define MODULE_VERSION "0.0.5"
43-
#define MODULE_BUILD "$Id$"
42+
#define MODULE_VERSION "1.0.0"
43+
#define MODULE_BUILD "$Id: luars232.c 13 2010-01-06 09:15:31Z sp $"
4444
#define MODULE_COPYRIGHT "Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd."
4545

4646
static struct {

doc/example.lua

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
rs232 = require("luars232")
2+
3+
-- Linux
4+
-- port_name = "/dev/ttyS0"
5+
6+
-- Windows
7+
port_name = "COM1"
8+
9+
local out = io.stderr
10+
11+
-- open port
12+
local e, p = rs232.open(port_name)
13+
if e ~= rs232.RS232_ERR_NOERROR then
14+
-- handle error
15+
out:write(string.format("can't open serial port '%s', error: '%s'\n",
16+
port_name, rs232.error_tostring(e)))
17+
return
18+
end
19+
20+
-- set port settings
21+
assert(p:set_baud_rate(rs232.RS232_BAUD_115200) == rs232.RS232_ERR_NOERROR)
22+
assert(p:set_data_bits(rs232.RS232_DATA_8) == rs232.RS232_ERR_NOERROR)
23+
assert(p:set_parity(rs232.RS232_PARITY_NONE) == rs232.RS232_ERR_NOERROR)
24+
assert(p:set_stop_bits(rs232.RS232_STOP_1) == rs232.RS232_ERR_NOERROR)
25+
assert(p:set_flow_control(rs232.RS232_FLOW_OFF) == rs232.RS232_ERR_NOERROR)
26+
27+
out:write(string.format("OK, port open with values '%s'\n", tostring(p)))
28+
29+
-- read with timeout
30+
local read_len = 1 -- read one byte
31+
local timeout = 100 -- in miliseconds
32+
local err, data_read, size = p:read(read_len, timeout)
33+
assert(e == rs232.RS232_ERR_NOERROR)
34+
35+
-- write without timeout
36+
err, len_written = p:write("test")
37+
assert(e == rs232.RS232_ERR_NOERROR)
38+
39+
-- write with timeout 100 msec
40+
err, len_written = p:write("test\n", timeout)
41+
assert(e == rs232.RS232_ERR_NOERROR)
42+
43+
-- close
44+
assert(p:close() == rs232.RS232_ERR_NOERROR)

src/resource.rc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "afxres.h"
22

33
VS_VERSION_INFO VERSIONINFO
4-
FILEVERSION 0,0,0,5
5-
PRODUCTVERSION 0,0,0,5
4+
FILEVERSION 1,0,0,0
5+
PRODUCTVERSION 1,0,0,0
66
FILEFLAGSMASK 0x17L
77
#ifdef _DEBUG
88
FILEFLAGS 0x1L
@@ -17,14 +17,14 @@ BEGIN
1717
BEGIN
1818
BLOCK "000004b0"
1919
BEGIN
20-
VALUE "CompanyName", "Petr Stetiar"
20+
VALUE "CompanyName", "Petr Stetiar, Gaben Ltd."
2121
VALUE "FileDescription", "librs232 - Library for serial communication over RS232"
22-
VALUE "FileVersion", "0, 0, 0, 5"
22+
VALUE "FileVersion", "1, 0, 0, 0"
2323
VALUE "InternalName", "librs232"
24-
VALUE "LegalCopyright", "Copyright (c) 2008-2009 Petr Stetiar"
24+
VALUE "LegalCopyright", "Copyright (c) 2008-2010 Petr Stetiar, Gaben Ltd."
2525
VALUE "OriginalFilename", "librs232.dll"
2626
VALUE "ProductName", "librs232 - Library for serial communication over RS232"
27-
VALUE "ProductVersion", "0, 0, 0, 5"
27+
VALUE "ProductVersion", "1, 0, 0, 0"
2828
END
2929
END
3030
BLOCK "VarFileInfo"

src/resource_lua.rc

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "afxres.h"
2+
3+
VS_VERSION_INFO VERSIONINFO
4+
FILEVERSION 1,0,0,0
5+
PRODUCTVERSION 1,0,0,0
6+
FILEFLAGSMASK 0x17L
7+
#ifdef _DEBUG
8+
FILEFLAGS 0x1L
9+
#else
10+
FILEFLAGS 0x0L
11+
#endif
12+
FILEOS 0x4L
13+
FILETYPE 0x2L
14+
FILESUBTYPE 0x0L
15+
BEGIN
16+
BLOCK "StringFileInfo"
17+
BEGIN
18+
BLOCK "000004b0"
19+
BEGIN
20+
VALUE "CompanyName", "Petr Stetiar, Gaben Ltd."
21+
VALUE "FileDescription", "luars232 - Lua library for serial communication over RS232"
22+
VALUE "FileVersion", "1, 0, 0, 0"
23+
VALUE "InternalName", "luars232"
24+
VALUE "LegalCopyright", "Copyright (c) 2009 Petr Stetiar, Gaben Ltd."
25+
VALUE "OriginalFilename", "luars232.dll"
26+
VALUE "ProductName", "luars232 - Library for serial communication over RS232"
27+
VALUE "ProductVersion", "1, 0, 0, 0"
28+
END
29+
END
30+
BLOCK "VarFileInfo"
31+
BEGIN
32+
VALUE "Translation", 0x0, 1200
33+
END
34+
END

src/rs232.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
static const char *
3535
rs232_baud[] = {
36-
"2400"
36+
"2400",
3737
"4800",
3838
"9600",
3939
"19200",
@@ -204,11 +204,11 @@ rs232_to_string(struct rs232_port_t *p)
204204
" parity: %s, stop bits: %s,"
205205
" flow control: %s",
206206
p->dev,
207-
rs232_baud[p->baud],
208-
rs232_data[p->data],
209-
rs232_parity[p->parity],
210-
rs232_stop[p->stop],
211-
rs232_flow[p->flow]);
207+
rs232_strbaud(p->baud),
208+
rs232_strdata(p->data),
209+
rs232_strparity(p->parity),
210+
rs232_strstop(p->stop),
211+
rs232_strflow(p->flow));
212212

213213
return str;
214214
}

windows/vs2k5/librs232lua/librs232lua.vcproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@
142142
/>
143143
<Tool
144144
Name="VCLinkerTool"
145-
AdditionalDependencies="lua51.lib"
145+
AdditionalDependencies="lua5.1.lib"
146146
OutputFile="luars232.dll"
147147
LinkIncremental="1"
148-
AdditionalLibraryDirectories="..\..\..\..\..\build\win32\Release\"
148+
AdditionalLibraryDirectories="d:\Lua\5.1\lib;..\..\..\..\..\build\win32\Release\"
149149
GenerateDebugInformation="true"
150150
SubSystem="2"
151151
OptimizeReferences="2"
@@ -219,7 +219,7 @@
219219
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
220220
>
221221
<File
222-
RelativePath="..\..\..\src\resource.rc"
222+
RelativePath="..\..\..\src\resource_lua.rc"
223223
>
224224
</File>
225225
</Filter>

0 commit comments

Comments
 (0)