toholio-serialport 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README +1 -1
- data/serialport.gemspec +1 -1
- data/src/posix_serialport_impl.c +4 -4
- data/src/serialport.c +66 -0
- data/src/serialport.h +28 -3
- data/src/win_serialport_impl.c +1 -5
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.7.2 => 02/09/2008: Fix several Windows and POSIX compilation problems.
|
2
|
+
Make GCC compile the code without any warnings.
|
3
|
+
Make RDoc not be so talkative during gem installation.
|
4
|
+
|
1
5
|
0.7.1 => 31/08/2008: Change to gemspec creation and fix posix compilation.
|
2
6
|
|
3
7
|
0.7.0 => 03/07/2008: Major Code Cleanup
|
data/README
CHANGED
@@ -12,7 +12,7 @@ and Borland's C++ compilers.
|
|
12
12
|
-- Installation --
|
13
13
|
|
14
14
|
This gem is hosted at GitHub. Before you can install this, or any other GitHub gem you must
|
15
|
-
add it as a
|
15
|
+
add it as a gem source:
|
16
16
|
gem sources -a http://gems.github.com
|
17
17
|
|
18
18
|
Then you can install the gem as normal:
|
data/serialport.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
SPEC = Gem::Specification.new do |s|
|
2
2
|
s.name = 'serialport'
|
3
|
-
s.version = '0.7.
|
3
|
+
s.version = '0.7.2'
|
4
4
|
s.summary = 'Library for using RS-232 serial ports.'
|
5
5
|
s.description = 'SerialPort is a Ruby library that provides a class for using RS-232 serial ports.'
|
6
6
|
s.files = [ 'CHANGELOG',
|
data/src/posix_serialport_impl.c
CHANGED
@@ -636,13 +636,13 @@ VALUE set_signal_impl(obj, val, sig)
|
|
636
636
|
VALUE sp_set_rts_impl(self, val)
|
637
637
|
VALUE self, val;
|
638
638
|
{
|
639
|
-
return
|
639
|
+
return set_signal_impl(self, val, TIOCM_RTS);
|
640
640
|
}
|
641
641
|
|
642
642
|
VALUE sp_set_dtr_impl(self, val)
|
643
643
|
VALUE self, val;
|
644
644
|
{
|
645
|
-
return
|
645
|
+
return set_signal_impl(self, val, TIOCM_DTR);
|
646
646
|
}
|
647
647
|
|
648
648
|
VALUE sp_get_rts_impl(self)
|
@@ -650,7 +650,7 @@ VALUE sp_get_rts_impl(self)
|
|
650
650
|
{
|
651
651
|
struct line_signals ls;
|
652
652
|
|
653
|
-
|
653
|
+
get_line_signals_helper_impl(self, &ls);
|
654
654
|
return INT2FIX(ls.rts);
|
655
655
|
}
|
656
656
|
|
@@ -659,7 +659,7 @@ VALUE sp_get_dtr_impl(self)
|
|
659
659
|
{
|
660
660
|
struct line_signals ls;
|
661
661
|
|
662
|
-
|
662
|
+
get_line_signals_helper_impl(self, &ls);
|
663
663
|
|
664
664
|
return INT2FIX(ls.dtr);
|
665
665
|
}
|
data/src/serialport.c
CHANGED
@@ -20,12 +20,19 @@
|
|
20
20
|
|
21
21
|
VALUE cSerialPort; /* serial port class */
|
22
22
|
|
23
|
+
VALUE sBaud, sDataBits, sStopBits, sParity; /* strings */
|
24
|
+
VALUE sRts, sDtr, sCts, sDsr, sDcd, sRi;
|
25
|
+
|
26
|
+
/*
|
27
|
+
*/
|
23
28
|
static VALUE sp_create(class, _port)
|
24
29
|
VALUE class, _port;
|
25
30
|
{
|
26
31
|
return sp_create_impl(class, _port);
|
27
32
|
}
|
28
33
|
|
34
|
+
/*
|
35
|
+
*/
|
29
36
|
static VALUE sp_set_modem_params(argc, argv, self)
|
30
37
|
int argc;
|
31
38
|
VALUE *argv, self;
|
@@ -33,67 +40,91 @@ static VALUE sp_set_modem_params(argc, argv, self)
|
|
33
40
|
return sp_set_modem_params_impl(argc, argv, self);
|
34
41
|
}
|
35
42
|
|
43
|
+
/*
|
44
|
+
*/
|
36
45
|
static VALUE sp_break(self, time)
|
37
46
|
VALUE self, time;
|
38
47
|
{
|
39
48
|
return sp_break_impl(self, time);
|
40
49
|
}
|
41
50
|
|
51
|
+
/*
|
52
|
+
*/
|
42
53
|
static VALUE sp_get_dtr(self)
|
43
54
|
VALUE self;
|
44
55
|
{
|
45
56
|
return sp_get_dtr_impl(self);
|
46
57
|
}
|
47
58
|
|
59
|
+
/*
|
60
|
+
*/
|
48
61
|
static VALUE sp_get_flow_control(self)
|
49
62
|
VALUE self;
|
50
63
|
{
|
51
64
|
return sp_get_flow_control_impl(self);
|
52
65
|
}
|
53
66
|
|
67
|
+
/*
|
68
|
+
*/
|
54
69
|
static VALUE sp_get_read_timeout(self)
|
55
70
|
VALUE self;
|
56
71
|
{
|
57
72
|
return sp_get_read_timeout_impl(self);
|
58
73
|
}
|
59
74
|
|
75
|
+
/*
|
76
|
+
*/
|
60
77
|
static VALUE sp_get_rts(self)
|
61
78
|
VALUE self;
|
62
79
|
{
|
63
80
|
return sp_get_rts_impl(self);
|
64
81
|
}
|
65
82
|
|
83
|
+
/*
|
84
|
+
*/
|
66
85
|
static VALUE sp_get_write_timeout(self)
|
67
86
|
VALUE self;
|
68
87
|
{
|
69
88
|
return sp_get_write_timeout_impl(self);
|
70
89
|
}
|
71
90
|
|
91
|
+
/*
|
92
|
+
*/
|
72
93
|
static VALUE sp_set_dtr(self, val)
|
73
94
|
{
|
74
95
|
return sp_set_dtr_impl(self, val);
|
75
96
|
}
|
76
97
|
|
98
|
+
/*
|
99
|
+
*/
|
77
100
|
static VALUE sp_set_flow_control(self, val)
|
78
101
|
{
|
79
102
|
return sp_set_flow_control_impl(self, val);
|
80
103
|
}
|
81
104
|
|
105
|
+
/*
|
106
|
+
*/
|
82
107
|
static VALUE sp_set_read_timeout(self, val)
|
83
108
|
{
|
84
109
|
return sp_set_read_timeout_impl(self, val);
|
85
110
|
}
|
86
111
|
|
112
|
+
/*
|
113
|
+
*/
|
87
114
|
static VALUE sp_set_rts(self, val)
|
88
115
|
{
|
89
116
|
return sp_set_rts_impl(self, val);
|
90
117
|
}
|
91
118
|
|
119
|
+
/*
|
120
|
+
*/
|
92
121
|
static VALUE sp_set_write_timeout(self, val)
|
93
122
|
{
|
94
123
|
return sp_set_write_timeout_impl(self, val);
|
95
124
|
}
|
96
125
|
|
126
|
+
/*
|
127
|
+
*/
|
97
128
|
static void get_modem_params(self, mp)
|
98
129
|
VALUE self;
|
99
130
|
struct modem_params *mp;
|
@@ -101,6 +132,8 @@ static void get_modem_params(self, mp)
|
|
101
132
|
get_modem_params_impl(self, mp);
|
102
133
|
}
|
103
134
|
|
135
|
+
/*
|
136
|
+
*/
|
104
137
|
static VALUE sp_set_data_rate(self, data_rate)
|
105
138
|
VALUE self, data_rate;
|
106
139
|
{
|
@@ -113,6 +146,8 @@ static VALUE sp_set_data_rate(self, data_rate)
|
|
113
146
|
return data_rate;
|
114
147
|
}
|
115
148
|
|
149
|
+
/*
|
150
|
+
*/
|
116
151
|
static VALUE sp_set_data_bits(self, data_bits)
|
117
152
|
VALUE self, data_bits;
|
118
153
|
{
|
@@ -125,6 +160,8 @@ static VALUE sp_set_data_bits(self, data_bits)
|
|
125
160
|
return data_bits;
|
126
161
|
}
|
127
162
|
|
163
|
+
/*
|
164
|
+
*/
|
128
165
|
static VALUE sp_set_stop_bits(self, stop_bits)
|
129
166
|
VALUE self, stop_bits;
|
130
167
|
{
|
@@ -137,6 +174,8 @@ static VALUE sp_set_stop_bits(self, stop_bits)
|
|
137
174
|
return stop_bits;
|
138
175
|
}
|
139
176
|
|
177
|
+
/*
|
178
|
+
*/
|
140
179
|
static VALUE sp_set_parity(self, parity)
|
141
180
|
VALUE self, parity;
|
142
181
|
{
|
@@ -149,6 +188,8 @@ static VALUE sp_set_parity(self, parity)
|
|
149
188
|
return parity;
|
150
189
|
}
|
151
190
|
|
191
|
+
/*
|
192
|
+
*/
|
152
193
|
static VALUE sp_get_data_rate(self)
|
153
194
|
VALUE self;
|
154
195
|
{
|
@@ -159,6 +200,8 @@ static VALUE sp_get_data_rate(self)
|
|
159
200
|
return INT2FIX(mp.data_rate);
|
160
201
|
}
|
161
202
|
|
203
|
+
/*
|
204
|
+
*/
|
162
205
|
static VALUE sp_get_data_bits(self)
|
163
206
|
VALUE self;
|
164
207
|
{
|
@@ -169,6 +212,8 @@ static VALUE sp_get_data_bits(self)
|
|
169
212
|
return INT2FIX(mp.data_bits);
|
170
213
|
}
|
171
214
|
|
215
|
+
/*
|
216
|
+
*/
|
172
217
|
static VALUE sp_get_stop_bits(self)
|
173
218
|
VALUE self;
|
174
219
|
{
|
@@ -179,6 +224,8 @@ static VALUE sp_get_stop_bits(self)
|
|
179
224
|
return INT2FIX(mp.stop_bits);
|
180
225
|
}
|
181
226
|
|
227
|
+
/*
|
228
|
+
*/
|
182
229
|
static VALUE sp_get_parity(self)
|
183
230
|
VALUE self;
|
184
231
|
{
|
@@ -189,6 +236,8 @@ static VALUE sp_get_parity(self)
|
|
189
236
|
return INT2FIX(mp.parity);
|
190
237
|
}
|
191
238
|
|
239
|
+
/*
|
240
|
+
*/
|
192
241
|
static VALUE sp_get_modem_params(self)
|
193
242
|
VALUE self;
|
194
243
|
{
|
@@ -207,6 +256,15 @@ static VALUE sp_get_modem_params(self)
|
|
207
256
|
return hash;
|
208
257
|
}
|
209
258
|
|
259
|
+
void get_line_signals_helper(obj, ls)
|
260
|
+
VALUE obj;
|
261
|
+
struct line_signals *ls;
|
262
|
+
{
|
263
|
+
get_line_signals_helper_impl(obj, ls);
|
264
|
+
}
|
265
|
+
|
266
|
+
/*
|
267
|
+
*/
|
210
268
|
static VALUE sp_get_cts(self)
|
211
269
|
VALUE self;
|
212
270
|
{
|
@@ -217,6 +275,8 @@ static VALUE sp_get_cts(self)
|
|
217
275
|
return INT2FIX(ls.cts);
|
218
276
|
}
|
219
277
|
|
278
|
+
/*
|
279
|
+
*/
|
220
280
|
static VALUE sp_get_dsr(self)
|
221
281
|
VALUE self;
|
222
282
|
{
|
@@ -227,6 +287,8 @@ static VALUE sp_get_dsr(self)
|
|
227
287
|
return INT2FIX(ls.dsr);
|
228
288
|
}
|
229
289
|
|
290
|
+
/*
|
291
|
+
*/
|
230
292
|
static VALUE sp_get_dcd(self)
|
231
293
|
VALUE self;
|
232
294
|
{
|
@@ -237,6 +299,8 @@ static VALUE sp_get_dcd(self)
|
|
237
299
|
return INT2FIX(ls.dcd);
|
238
300
|
}
|
239
301
|
|
302
|
+
/*
|
303
|
+
*/
|
240
304
|
static VALUE sp_get_ri(self)
|
241
305
|
VALUE self;
|
242
306
|
{
|
@@ -247,6 +311,8 @@ static VALUE sp_get_ri(self)
|
|
247
311
|
return INT2FIX(ls.ri);
|
248
312
|
}
|
249
313
|
|
314
|
+
/*
|
315
|
+
*/
|
250
316
|
static VALUE sp_signals(self)
|
251
317
|
VALUE self;
|
252
318
|
{
|
data/src/serialport.h
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
* Guillaume Pierronnet <moumar@netcourrier.com>
|
3
3
|
* Alan Stern <stern@rowland.harvard.edu>
|
4
4
|
* Daniel E. Shipton <dshipton@redshiptechnologies.com>
|
5
|
+
* Tobin Richard <tobin.richard@gmail.com>
|
5
6
|
*
|
6
7
|
* This code is hereby licensed for public consumption under either the
|
7
8
|
* GNU GPL v2 or greater.
|
@@ -19,7 +20,7 @@
|
|
19
20
|
#ifndef _RUBY_SERIAL_PORT_H_
|
20
21
|
#define _RUBY_SERIAL_PORT_H_
|
21
22
|
|
22
|
-
#define RUBY_SERIAL_PORT_VERSION "0.7.
|
23
|
+
#define RUBY_SERIAL_PORT_VERSION "0.7.2"
|
23
24
|
|
24
25
|
#include <ruby.h> /* ruby inclusion */
|
25
26
|
#include <rubyio.h> /* ruby io inclusion */
|
@@ -51,14 +52,38 @@ struct line_signals
|
|
51
52
|
#define MARK MARKPARITY
|
52
53
|
#define EVEN EVENPARITY
|
53
54
|
#define ODD ODDPARITY
|
55
|
+
|
56
|
+
#ifndef RB_SERIAL_EXPORT
|
57
|
+
#define RB_SERIAL_EXPORT __declspec(dllexport)
|
58
|
+
#endif
|
54
59
|
#else
|
55
60
|
#define SPACE 0
|
56
61
|
#define MARK 0
|
57
62
|
#define EVEN 1
|
58
63
|
#define ODD 2
|
64
|
+
|
65
|
+
#define RB_SERIAL_EXPORT
|
59
66
|
#endif
|
60
67
|
|
61
|
-
|
62
|
-
|
68
|
+
extern VALUE sBaud, sDataBits, sStopBits, sParity; /* strings */
|
69
|
+
extern VALUE sRts, sDtr, sCts, sDsr, sDcd, sRi;
|
70
|
+
|
71
|
+
/* Implementation specific functions. */
|
72
|
+
VALUE RB_SERIAL_EXPORT sp_create_impl(VALUE class, VALUE _port);
|
73
|
+
VALUE RB_SERIAL_EXPORT sp_set_modem_params_impl(int argc, VALUE *argv, VALUE self);
|
74
|
+
void RB_SERIAL_EXPORT get_modem_params_impl(VALUE self, struct modem_params *mp);
|
75
|
+
VALUE RB_SERIAL_EXPORT sp_set_flow_control_impl(VALUE self, VALUE val);
|
76
|
+
VALUE RB_SERIAL_EXPORT sp_get_flow_control_impl(VALUE self);
|
77
|
+
VALUE RB_SERIAL_EXPORT sp_set_read_timeout_impl(VALUE self, VALUE val);
|
78
|
+
VALUE RB_SERIAL_EXPORT sp_get_read_timeout_impl(VALUE self);
|
79
|
+
VALUE RB_SERIAL_EXPORT sp_set_write_timeout_impl(VALUE self, VALUE val);
|
80
|
+
VALUE RB_SERIAL_EXPORT sp_get_write_timeout_impl(VALUE self);
|
81
|
+
VALUE RB_SERIAL_EXPORT sp_break_impl(VALUE self, VALUE time);
|
82
|
+
void RB_SERIAL_EXPORT get_line_signals_helper_impl(VALUE obj, struct line_signals *ls);
|
83
|
+
VALUE RB_SERIAL_EXPORT set_signal_impl(VALUE obj, VALUE val, int sig);
|
84
|
+
VALUE RB_SERIAL_EXPORT sp_set_rts_impl(VALUE self, VALUE val);
|
85
|
+
VALUE RB_SERIAL_EXPORT sp_set_dtr_impl(VALUE self, VALUE val);
|
86
|
+
VALUE RB_SERIAL_EXPORT sp_get_rts_impl(VALUE self);
|
87
|
+
VALUE RB_SERIAL_EXPORT sp_get_dtr_impl(VALUE self);
|
63
88
|
|
64
89
|
#endif
|
data/src/win_serialport_impl.c
CHANGED
@@ -25,10 +25,6 @@
|
|
25
25
|
#include <fcntl.h> /* File control definitions */
|
26
26
|
#include <windows.h> /* Windows standard function definitions */
|
27
27
|
|
28
|
-
#ifndef RB_SERIAL_EXPORT
|
29
|
-
#define RB_SERIAL_EXPORT __declspec(dllexport)
|
30
|
-
//#define RB_SERIAL_EXPORT
|
31
|
-
#endif
|
32
28
|
|
33
29
|
static char sGetCommState[] = "GetCommState";
|
34
30
|
static char sSetCommState[] = "SetCommState";
|
@@ -536,7 +532,7 @@ VALUE RB_SERIAL_EXPORT sp_break_impl(self, time)
|
|
536
532
|
return Qnil;
|
537
533
|
}
|
538
534
|
|
539
|
-
void RB_SERIAL_EXPORT
|
535
|
+
void RB_SERIAL_EXPORT get_line_signals_helper_impl(obj, ls)
|
540
536
|
VALUE obj;
|
541
537
|
struct line_signals *ls;
|
542
538
|
{
|