rs_232 3.0.0.pre4 → 3.0.0.pre5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rs_232/extconf.rb +14 -15
- data/ext/rs_232/windows/Port.c +15 -30
- data/lib/rs_232/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac888dadace7e7e0225d1c7bb4e9c9b816484493
|
4
|
+
data.tar.gz: 09acd44b4e25022e183b1c2aaa111ef69ecc6626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566e436963f3bd808566f27fabaab010fea424f3a88de1ba99cb0635627d9fd580300516cc8a1420580b78c3d8175fee3ac827be8564f55cb3f38bb69782236e
|
7
|
+
data.tar.gz: bd1dfb14e6f7308c34eeba95622fd7d662e137692ead69ea4c53c0f4cc733f465afd18874f98735bc77a4e4ab8eaa59f62f6f2b348c9ebd29792544a67dc6d46
|
data/ext/rs_232/extconf.rb
CHANGED
@@ -15,25 +15,24 @@ $CFLAGS << ' -Wall -g'
|
|
15
15
|
$warnflags = '-Wall'
|
16
16
|
|
17
17
|
OS = case RbConfig::CONFIG['host_os'].downcase
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
when /linux/
|
19
|
+
'linux'
|
20
|
+
when /darwin/
|
21
|
+
'darwin'
|
22
|
+
when /freebsd/
|
23
|
+
'freebsd'
|
24
|
+
when /openbsd/
|
25
|
+
'openbsd'
|
26
|
+
when /sunos|solaris/
|
27
|
+
'solaris'
|
28
|
+
when /mswin|mingw/
|
29
|
+
'windows'
|
30
|
+
else
|
31
|
+
RbConfig::CONFIG['host_os'].downcase
|
32
32
|
end
|
33
33
|
|
34
34
|
have_header('ruby.h')
|
35
35
|
have_header('stdio.h')
|
36
|
-
have_library( 'stdc++' )
|
37
36
|
|
38
37
|
if OS == 'windows'
|
39
38
|
$VPATH << '$(srcdir)/windows'
|
data/ext/rs_232/windows/Port.c
CHANGED
@@ -167,7 +167,6 @@ void updateSettings(PortDescriptor *port)
|
|
167
167
|
static int queryStatusIO(VALUE self)
|
168
168
|
{
|
169
169
|
PortDescriptor *port = NULL;
|
170
|
-
|
171
170
|
Data_Get_Struct(self, PortDescriptor, port);
|
172
171
|
|
173
172
|
return port->status;
|
@@ -176,7 +175,7 @@ static int queryStatusIO(VALUE self)
|
|
176
175
|
|
177
176
|
VALUE isOpenIO(VALUE self)
|
178
177
|
{
|
179
|
-
return queryStatusIO(self) != PORT_OPEN ?
|
178
|
+
return queryStatusIO(self) != PORT_OPEN ? Qfalse : Qtrue;
|
180
179
|
}
|
181
180
|
|
182
181
|
|
@@ -228,15 +227,12 @@ VALUE openIO(VALUE self)
|
|
228
227
|
|
229
228
|
if (port->fd == INVALID_HANDLE_VALUE)
|
230
229
|
{
|
231
|
-
|
232
230
|
port->status = PORT_CLOSED;
|
233
231
|
rb_raise(rb_eIOError, "Unable to open comport: `%s`", port->settings.ComPort);
|
234
232
|
|
235
|
-
} else
|
236
|
-
{
|
237
|
-
|
233
|
+
} else {
|
238
234
|
port->status = PORT_OPEN;
|
239
|
-
rb_iv_set(self, "@open",
|
235
|
+
rb_iv_set(self, "@open", isOpenIO(self));
|
240
236
|
|
241
237
|
GetCommConfig(port->fd, &port->commConfig, &conf_length);
|
242
238
|
GetCommState(port->fd, &(port->commConfig.dcb));
|
@@ -261,7 +257,6 @@ VALUE openIO(VALUE self)
|
|
261
257
|
|
262
258
|
VALUE writeIO(VALUE self, VALUE message)
|
263
259
|
{
|
264
|
-
|
265
260
|
int recv;
|
266
261
|
int len;
|
267
262
|
PortDescriptor *port = NULL;
|
@@ -275,31 +270,23 @@ VALUE writeIO(VALUE self, VALUE message)
|
|
275
270
|
strcpy(cStr, RSTRING_PTR(message));
|
276
271
|
|
277
272
|
if (!WriteFile(port->fd, cStr, len, (LPDWORD)((void *) &recv), NULL))
|
278
|
-
|
279
|
-
rb_raise(rb_eIOError, "IO: writing of the %d bytes has been failed", len);
|
280
|
-
}
|
281
|
-
|
282
|
-
return (INT2FIX(recv));
|
273
|
+
rb_raise(rb_eIOError, "IO: writing of the %d bytes has been failed. Error #%d", len, (int) GetLastError());
|
283
274
|
|
275
|
+
return INT2FIX(recv);
|
284
276
|
}
|
285
277
|
|
286
|
-
|
287
278
|
VALUE readIO(VALUE self, VALUE rb_int)
|
288
279
|
{
|
289
|
-
|
290
|
-
{
|
291
|
-
Check_Type(rb_int, T_FIXNUM);
|
292
|
-
}
|
293
|
-
|
280
|
+
Check_Type(rb_int, T_FIXNUM);
|
294
281
|
PortDescriptor *port = NULL;
|
295
|
-
|
296
282
|
Data_Get_Struct(self, PortDescriptor, port);
|
297
283
|
|
298
284
|
int n;
|
299
285
|
int len = FIX2INT(rb_int);
|
300
286
|
char buf[len];
|
301
287
|
|
302
|
-
ReadFile(port->fd, &buf, len, (LPDWORD)((void *) &n), NULL)
|
288
|
+
if(!ReadFile(port->fd, &buf, len, (LPDWORD)((void *) &n), NULL))
|
289
|
+
rb_raise(rb_eIOError, "IO: reading of %d bytes has been failed. Error #%d", len, (int) GetLastError());
|
303
290
|
|
304
291
|
if (n > 0)
|
305
292
|
return rb_str_new(buf, n);
|
@@ -310,19 +297,17 @@ VALUE readIO(VALUE self, VALUE rb_int)
|
|
310
297
|
|
311
298
|
VALUE closeIO(VALUE self)
|
312
299
|
{
|
313
|
-
|
314
300
|
PortDescriptor *port = NULL;
|
315
|
-
|
316
301
|
Data_Get_Struct(self, PortDescriptor, port);
|
317
302
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
return INT2FIX(port->status);
|
303
|
+
if (port->fd != INVALID_HANDLE_VALUE) {
|
304
|
+
flushIO(self);
|
305
|
+
port->status = CloseHandle(port->fd);
|
306
|
+
port->fd = INVALID_HANDLE_VALUE;
|
307
|
+
rb_iv_set(self, "@open", isOpenIO(self));
|
308
|
+
}
|
325
309
|
|
310
|
+
return !isOpenIO(self);
|
326
311
|
}
|
327
312
|
|
328
313
|
|
data/lib/rs_232/version.rb
CHANGED