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

Commit 60a0737

Browse files
committed
- version 1.0.2
- added 460800 baudrate - fixed memory leak in rs232_end() if the port wasn't open - update year in the copyright - sync debug message print format between win/Linux
1 parent e9017b6 commit 60a0737

14 files changed

+59
-33
lines changed

COPYING

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
1+
Copyright (c) 2011 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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -39,9 +39,9 @@
3939

4040
#define MODULE_TIMESTAMP __DATE__ " " __TIME__
4141
#define MODULE_NAMESPACE "luars232"
42-
#define MODULE_VERSION "1.0.1"
42+
#define MODULE_VERSION "1.0.2"
4343
#define MODULE_BUILD "$Id: luars232.c 15 2011-02-23 09:02:20Z sp $"
44-
#define MODULE_COPYRIGHT "Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd."
44+
#define MODULE_COPYRIGHT "Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd."
4545

4646
static struct {
4747
const char *name;
@@ -56,6 +56,7 @@ static struct {
5656
{ "RS232_BAUD_38400", RS232_BAUD_38400 },
5757
{ "RS232_BAUD_57600", RS232_BAUD_57600 },
5858
{ "RS232_BAUD_115200", RS232_BAUD_115200 },
59+
{ "RS232_BAUD_460800", RS232_BAUD_460800 },
5960
/* databits */
6061
{ "RS232_DATA_5", RS232_DATA_5 },
6162
{ "RS232_DATA_6", RS232_DATA_6 },

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
make distclean
33
. autogen.sh
4-
./configure --prefix=$PWD/bin --enable-debug
5-
#./configure --prefix=$PWD/bin
4+
#./configure --prefix=$PWD/inst-dbg --enable-debug
5+
./configure --prefix=$PWD/inst
66
make install

include/librs232/qrs232.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -47,4 +47,4 @@ class QRS232 {
4747
private:
4848
bool m_open;
4949
struct rs232_port_t *m_port;
50-
};
50+
};

include/librs232/rs232.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -67,6 +67,7 @@ enum rs232_baud_e {
6767
RS232_BAUD_38400,
6868
RS232_BAUD_57600,
6969
RS232_BAUD_115200,
70+
RS232_BAUD_460800,
7071
RS232_BAUD_MAX
7172
};
7273

include/librs232/rs232_linux.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation

include/librs232/rs232_windows.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -29,6 +29,10 @@
2929

3030
#include <windows.h>
3131

32+
#ifndef CBR_460800
33+
#define CBR_460800 460800
34+
#endif
35+
3236
struct rs232_windows_t {
3337
HANDLE fd;
3438
COMMTIMEOUTS old_tm;

src/qrs232.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation

src/resource.rc

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

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

src/resource_lua.rc

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

33
VS_VERSION_INFO VERSIONINFO
4-
FILEVERSION 1,0,1,0
5-
PRODUCTVERSION 1,0,1,0
4+
FILEVERSION 1,0,2,0
5+
PRODUCTVERSION 1,0,2,0
66
FILEFLAGSMASK 0x17L
77
#ifdef _DEBUG
88
FILEFLAGS 0x1L
@@ -19,12 +19,12 @@ BEGIN
1919
BEGIN
2020
VALUE "CompanyName", "Petr Stetiar, Gaben Ltd.\0"
2121
VALUE "FileDescription", "luars232 - Lua library for serial communication over RS232\0"
22-
VALUE "FileVersion", "1, 0, 1, 0\0"
22+
VALUE "FileVersion", "1, 0, 2, 0\0"
2323
VALUE "InternalName", "luars232\0"
24-
VALUE "LegalCopyright", "Copyright (c) 2009-2011 Petr Stetiar, Gaben Ltd.\0"
24+
VALUE "LegalCopyright", "Copyright (c) 2011 Petr Stetiar, Gaben Ltd.\0"
2525
VALUE "OriginalFilename", "luars232.dll\0"
2626
VALUE "ProductName", "luars232 - Library for serial communication over RS232\0"
27-
VALUE "ProductVersion", "1, 0, 1, 0\0"
27+
VALUE "ProductVersion", "1, 0, 2, 0\0"
2828
END
2929
END
3030
BLOCK "VarFileInfo"

src/rs232.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -41,6 +41,7 @@ rs232_baud[] = {
4141
"38400",
4242
"57600",
4343
"115200",
44+
"460800",
4445
};
4546

4647
static const char *

src/rs232_linux.c

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -54,6 +54,7 @@ rs232_init(void)
5454

5555
DBG("p=%p p->pt=%p\n", (void *)p, p->pt);
5656

57+
memset(p->pt, 0, sizeof(struct rs232_linux_t));
5758
memset(p->dev, 0, RS232_STRLEN_DEVICE+1);
5859
strncpy(p->dev, RS232_PORT_LINUX, RS232_STRLEN_DEVICE);
5960

@@ -76,8 +77,11 @@ rs232_end(struct rs232_port_t *p)
7677

7778
DBG("p=%p p->pt=%p\n", (void *)p, p->pt);
7879

79-
if (!rs232_port_open(p))
80+
if (!rs232_port_open(p)) {
81+
free(p->pt);
82+
free(p);
8083
return;
84+
}
8185

8286
rs232_flush(p);
8387

@@ -488,7 +492,8 @@ rs232_set_baud(struct rs232_port_t *p, enum rs232_baud_e baud)
488492
struct termios term;
489493
struct rs232_linux_t *ux = p->pt;
490494

491-
DBG("p=%p p->pt=%p baud=%d\n", (void *)p, p->pt, baud);
495+
DBG("p=%p p->pt=%p baud=%d (%s bauds)\n",
496+
(void *)p, p->pt, baud, rs232_strbaud(baud));
492497

493498
GET_PORT_STATE(ux->fd, &term)
494499

@@ -525,6 +530,10 @@ rs232_set_baud(struct rs232_port_t *p, enum rs232_baud_e baud)
525530
cfsetispeed(&term, B115200);
526531
cfsetospeed(&term, B115200);
527532
break;
533+
case RS232_BAUD_460800:
534+
cfsetispeed(&term, B460800);
535+
cfsetospeed(&term, B460800);
536+
break;
528537
default:
529538
return RS232_ERR_UNKNOWN;
530539
}
@@ -617,7 +626,8 @@ rs232_set_parity(struct rs232_port_t *p, enum rs232_parity_e parity)
617626
struct termios term;
618627
struct rs232_linux_t *ux = p->pt;
619628

620-
DBG("p=%p p->pt=%p parity=%d\n", (void *)p, p->pt, parity);
629+
DBG("p=%p p->pt=%p parity=%d (parity %s)\n",
630+
(void *)p, p->pt, parity, rs232_strparity(parity));
621631

622632
GET_PORT_STATE(ux->fd, &term)
623633

@@ -648,7 +658,8 @@ rs232_set_stop(struct rs232_port_t *p, enum rs232_stop_e stop)
648658
struct termios term;
649659
struct rs232_linux_t *ux = p->pt;
650660

651-
DBG("p=%p p->pt=%p stop=%d\n", (void *)p, p->pt, stop);
661+
DBG("p=%p p->pt=%p stop=%d (%s stop bits)\n",
662+
(void *)p, p->pt, stop, rs232_strstop(stop));
652663

653664
GET_PORT_STATE(ux->fd, &term)
654665
term.c_cflag &= ~CSTOPB;
@@ -675,7 +686,8 @@ rs232_set_data(struct rs232_port_t *p, enum rs232_data_e data)
675686
struct termios term;
676687
struct rs232_linux_t *ux = p->pt;
677688

678-
DBG("p=%p p->pt=%p data=%d\n", (void *)p, p->pt, data);
689+
DBG("p=%p p->pt=%p data=%d (%s data bits)\n",
690+
(void *)p, p->pt, data, rs232_strdata(data));
679691

680692
GET_PORT_STATE(ux->fd, &term)
681693
term.c_cflag &= ~CSIZE;
@@ -709,7 +721,8 @@ rs232_set_flow(struct rs232_port_t *p, enum rs232_flow_e flow)
709721
struct termios term;
710722
struct rs232_linux_t *ux = p->pt;
711723

712-
DBG("p=%p p->pt=%p flow=%d\n", (void *)p, p->pt, flow);
724+
DBG("p=%p p->pt=%p flow=%d (flow control %s)\n",
725+
(void *)p, p->pt, flow, rs232_strflow(flow));
713726

714727
GET_PORT_STATE(ux->fd, &term)
715728

src/rs232_test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation

src/rs232_windows.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009 Petr Stetiar <[email protected]>, Gaben Ltd.
2+
* Copyright (c) 2011 Petr Stetiar <[email protected]>, Gaben Ltd.
33
*
44
* Permission is hereby granted, free of charge, to any person
55
* obtaining a copy of this software and associated documentation
@@ -165,8 +165,11 @@ rs232_end(struct rs232_port_t *p)
165165

166166
DBG("p=%p p->pt=%p\n", (void *)p, p->pt);
167167

168-
if (!rs232_port_open(p))
168+
if (!rs232_port_open(p)) {
169+
free(p->pt);
170+
free(p);
169171
return;
172+
}
170173

171174
rs232_flush(p);
172175

@@ -464,6 +467,9 @@ rs232_set_baud(struct rs232_port_t *p, enum rs232_baud_e baud)
464467
case RS232_BAUD_115200:
465468
pdcb.BaudRate = CBR_115200;
466469
break;
470+
case RS232_BAUD_460800:
471+
pdcb.BaudRate = CBR_460800;
472+
break;
467473
default:
468474
return RS232_ERR_UNKNOWN;
469475
}

0 commit comments

Comments
 (0)