serialport 1.3.2 → 1.4.0
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
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/ci.yml +97 -0
- data/CHANGELOG +11 -0
- data/Gemfile +1 -1
- data/README.md +2 -3
- data/ext/native/extconf.rb +3 -0
- data/ext/native/posix_serialport_impl.c +32 -75
- data/ext/native/serialport.c +55 -68
- data/ext/native/serialport.h +6 -12
- data/ext/native/win_serialport_impl.c +40 -74
- data/lib/serialport/version.rb +2 -2
- data/lib/serialport.rb +3 -2
- data/serialport.gemspec +6 -4
- data.tar.gz.sig +6 -0
- metadata +34 -12
- metadata.gz.sig +3 -0
- data/.travis.yml +0 -12
- data/MANIFEST +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46b308fdb65c3d260d72e40910cab8c92216c80cf0781f2f27635f20acfcf4d6
|
4
|
+
data.tar.gz: c4910296a5bd0ef46f9b1506af71965d85895d5196a22d004c03999ab3235457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9724b16f3729f6f3970d118f847700617587ec5d0d79a583bc3eb4443143a4001b9c9d0a9b86d00ae5cc696b71a14256b7d0fb9450965fbd047bb3fecd3e3376
|
7
|
+
data.tar.gz: c9d5c9b32437df4fab958c2a2d7ace91dec7fdaa62b3b1ea4f8e025a7b081873f97d6c195c738051f83c6e89dd9507fd81f7f13b2cb7e4634a6326463afb8352
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
workflow_dispatch:
|
4
|
+
schedule:
|
5
|
+
- cron: "0 5 * * 3" # At 05:00 on Wednesday # https://crontab.guru/#0_5_*_*_3
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
tags:
|
10
|
+
- "*.*.*"
|
11
|
+
pull_request:
|
12
|
+
types: [opened, synchronize]
|
13
|
+
branches:
|
14
|
+
- "*"
|
15
|
+
permissions:
|
16
|
+
contents: read
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
rcd_build:
|
20
|
+
name: build gem
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v4
|
25
|
+
|
26
|
+
- uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: "3.4"
|
29
|
+
|
30
|
+
- name: Build ffi.gem
|
31
|
+
run: |
|
32
|
+
bundle install
|
33
|
+
bundle exec rake gem
|
34
|
+
|
35
|
+
- name: Upload binary gem
|
36
|
+
uses: actions/upload-artifact@v4
|
37
|
+
with:
|
38
|
+
name: gem
|
39
|
+
path: pkg/*-*.gem
|
40
|
+
|
41
|
+
job_test_native:
|
42
|
+
name: native test
|
43
|
+
needs: rcd_build
|
44
|
+
strategy:
|
45
|
+
fail-fast: false
|
46
|
+
matrix:
|
47
|
+
os:
|
48
|
+
- windows-latest
|
49
|
+
- macos-13
|
50
|
+
- macos-latest
|
51
|
+
- ubuntu-latest
|
52
|
+
- windows-11-arm
|
53
|
+
ruby:
|
54
|
+
- "head"
|
55
|
+
- "3.4"
|
56
|
+
- "3.3"
|
57
|
+
- "3.2"
|
58
|
+
- "3.1"
|
59
|
+
- "3.0"
|
60
|
+
- "2.7"
|
61
|
+
- "2.6"
|
62
|
+
- "2.5"
|
63
|
+
exclude:
|
64
|
+
- os: macos-latest
|
65
|
+
ruby: "2.5"
|
66
|
+
- os: windows-11-arm
|
67
|
+
ruby: "3.3"
|
68
|
+
- os: windows-11-arm
|
69
|
+
ruby: "3.2"
|
70
|
+
- os: windows-11-arm
|
71
|
+
ruby: "3.1"
|
72
|
+
- os: windows-11-arm
|
73
|
+
ruby: "3.0"
|
74
|
+
- os: windows-11-arm
|
75
|
+
ruby: "2.7"
|
76
|
+
- os: windows-11-arm
|
77
|
+
ruby: "2.6"
|
78
|
+
- os: windows-11-arm
|
79
|
+
ruby: "2.5"
|
80
|
+
|
81
|
+
runs-on: ${{ matrix.os }}
|
82
|
+
steps:
|
83
|
+
- uses: actions/checkout@v4
|
84
|
+
- uses: ruby/setup-ruby@v1
|
85
|
+
with:
|
86
|
+
ruby-version: ${{ matrix.ruby }}
|
87
|
+
- run: ruby --version
|
88
|
+
- name: Download gem
|
89
|
+
uses: actions/download-artifact@v4
|
90
|
+
with:
|
91
|
+
name: gem
|
92
|
+
- name: Install gem
|
93
|
+
run: gem install --local *.gem --verbose
|
94
|
+
- name: Run tests
|
95
|
+
run: |
|
96
|
+
bundle install
|
97
|
+
ruby -rserialport -S rake test
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
1.4.0 => 16-06-2025: [FIXED] Fix compatibility with ruby-3.4. [#79](https://github.com/hparra/ruby-serialport/pull/79)
|
2
|
+
[FIXED] Replace ancient K&R function declarations by ANSI style.
|
3
|
+
[FIXED] Fixed various compiler warnings.
|
4
|
+
[FIXED] Avoid deprecated access to fptr->fd
|
5
|
+
[CHANGED] New repository link and add Lars Kanis as new author.
|
6
|
+
[CHANGED] Move CI from Travis to Github
|
7
|
+
[CHANGED] Use autoload for SerialPort::VERSION
|
8
|
+
[REMOVED] Remove compatibility to ruby < 2.5
|
9
|
+
|
10
|
+
1.3.2 => 29-09-2021: [FIXED] Remove calls to rb_secure because it is deprecated and removed in Ruby 3.
|
11
|
+
|
1
12
|
1.3.1 => 07/26/2014: [FIXED] Ruby 2.2 support
|
2
13
|
[NEW] UNIX MARK/SPACE parity (CMSPAR) support
|
3
14
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
# Ruby/SerialPort
|
2
2
|
|
3
|
-
[](https://github.com/larskanis/ruby-serialport/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
## Description
|
6
6
|
|
7
7
|
Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports. This class also contains low-level functions to check and set the current state of the signals on the line.
|
8
8
|
|
9
|
-
The native Windows version of this library supports the Microsoft Visual C++, Borland C++, and MinGW compilers.
|
10
|
-
|
11
9
|
There is an alternative gem with MRI, JRuby, and Rubinius support. See below.
|
12
10
|
|
13
11
|
## Installation
|
@@ -41,3 +39,4 @@ GPL
|
|
41
39
|
* Tobin Richard <tobin.richard@gmail.com>
|
42
40
|
* Hector Parra <hector@hectorparra.com>
|
43
41
|
* Ryan C. Payne <rpayne-oss@bullittsystems.com>
|
42
|
+
* Lars Kanis <lars@greiz-reinsdorf.de>
|
data/ext/native/extconf.rb
CHANGED
@@ -10,4 +10,7 @@ if !(os == 'mswin' or os == 'bccwin' or os == 'mingw')
|
|
10
10
|
exit(1) if not have_header("termios.h") or not have_header("unistd.h")
|
11
11
|
end
|
12
12
|
|
13
|
+
have_func("rb_io_descriptor") # ruby-3.1+
|
14
|
+
have_func("rb_io_open_descriptor") # ruby-3.3+
|
15
|
+
|
13
16
|
create_makefile('serialport')
|
@@ -61,35 +61,23 @@ static char sTcsetattr[] = "tcsetattr";
|
|
61
61
|
static char sIoctl[] = "ioctl";
|
62
62
|
|
63
63
|
|
64
|
-
int get_fd_helper(
|
65
|
-
VALUE obj;
|
64
|
+
int get_fd_helper(VALUE io)
|
66
65
|
{
|
67
|
-
#ifdef
|
68
|
-
|
66
|
+
#ifdef HAVE_RB_IO_DESCRIPTOR
|
67
|
+
return rb_io_descriptor(io);
|
69
68
|
#else
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
#ifdef HAVE_RUBY_IO_H
|
74
|
-
return (fptr->fd);
|
75
|
-
#else
|
76
|
-
return (fileno(fptr->f));
|
69
|
+
rb_io_t* fp;
|
70
|
+
GetOpenFile(io, fp);
|
71
|
+
return fp->fd;
|
77
72
|
#endif
|
78
73
|
}
|
79
74
|
|
80
|
-
VALUE sp_create_impl(class, _port)
|
81
|
-
VALUE class, _port;
|
75
|
+
VALUE sp_create_impl(VALUE class, VALUE _port)
|
82
76
|
{
|
83
|
-
#ifdef HAVE_RUBY_IO_H
|
84
|
-
rb_io_t *fp;
|
85
|
-
#else
|
86
|
-
OpenFile *fp;
|
87
|
-
#endif
|
88
|
-
|
89
77
|
int fd;
|
90
|
-
|
91
|
-
char *port;
|
92
|
-
char *ports[] = {
|
78
|
+
long num_port;
|
79
|
+
const char *port;
|
80
|
+
const char *ports[] = {
|
93
81
|
#if defined(OS_LINUX) || defined(OS_CYGWIN)
|
94
82
|
"/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3",
|
95
83
|
"/dev/ttyS4", "/dev/ttyS5", "/dev/ttyS6", "/dev/ttyS7"
|
@@ -108,16 +96,13 @@ VALUE sp_create_impl(class, _port)
|
|
108
96
|
#endif
|
109
97
|
};
|
110
98
|
struct termios params;
|
111
|
-
|
112
|
-
NEWOBJ(sp, struct RFile);
|
113
|
-
OBJSETUP(sp, class, T_FILE);
|
114
|
-
MakeOpenFile((VALUE) sp, fp);
|
99
|
+
VALUE sp;
|
115
100
|
|
116
101
|
switch(TYPE(_port))
|
117
102
|
{
|
118
103
|
case T_FIXNUM:
|
119
|
-
num_port =
|
120
|
-
if (num_port < 0 || num_port > sizeof(ports) / sizeof(ports[0]))
|
104
|
+
num_port = FIX2LONG(_port);
|
105
|
+
if (num_port < 0 || num_port > (long)(sizeof(ports) / sizeof(ports[0])))
|
121
106
|
{
|
122
107
|
rb_raise(rb_eArgError, "illegal port number");
|
123
108
|
}
|
@@ -166,19 +151,12 @@ VALUE sp_create_impl(class, _port)
|
|
166
151
|
rb_sys_fail(sTcsetattr);
|
167
152
|
}
|
168
153
|
|
169
|
-
|
170
|
-
fp->fd = fd;
|
171
|
-
#else
|
172
|
-
fp->f = rb_fdopen(fd, "r+");
|
173
|
-
#endif
|
174
|
-
fp->mode = FMODE_READWRITE | FMODE_SYNC;
|
154
|
+
sp = rb_io_open_descriptor(class, fd, FMODE_READWRITE | FMODE_SYNC, Qnil, Qnil, NULL);
|
175
155
|
|
176
|
-
return
|
156
|
+
return sp;
|
177
157
|
}
|
178
158
|
|
179
|
-
VALUE sp_set_modem_params_impl(argc, argv, self)
|
180
|
-
int argc;
|
181
|
-
VALUE *argv, self;
|
159
|
+
VALUE sp_set_modem_params_impl(int argc, VALUE *argv, VALUE self)
|
182
160
|
{
|
183
161
|
int fd;
|
184
162
|
struct termios params;
|
@@ -399,9 +377,7 @@ VALUE sp_set_modem_params_impl(argc, argv, self)
|
|
399
377
|
return argv[0];
|
400
378
|
}
|
401
379
|
|
402
|
-
void get_modem_params_impl(self, mp)
|
403
|
-
VALUE self;
|
404
|
-
struct modem_params *mp;
|
380
|
+
void get_modem_params_impl(VALUE self, struct modem_params *mp)
|
405
381
|
{
|
406
382
|
int fd;
|
407
383
|
struct termios params;
|
@@ -493,8 +469,7 @@ void get_modem_params_impl(self, mp)
|
|
493
469
|
}
|
494
470
|
}
|
495
471
|
|
496
|
-
VALUE sp_set_flow_control_impl(self, val)
|
497
|
-
VALUE self, val;
|
472
|
+
VALUE sp_set_flow_control_impl(VALUE self, VALUE val)
|
498
473
|
{
|
499
474
|
int fd;
|
500
475
|
int flowc;
|
@@ -540,8 +515,7 @@ VALUE sp_set_flow_control_impl(self, val)
|
|
540
515
|
return val;
|
541
516
|
}
|
542
517
|
|
543
|
-
VALUE sp_get_flow_control_impl(self)
|
544
|
-
VALUE self;
|
518
|
+
VALUE sp_get_flow_control_impl(VALUE self)
|
545
519
|
{
|
546
520
|
int ret;
|
547
521
|
int fd;
|
@@ -570,8 +544,7 @@ VALUE sp_get_flow_control_impl(self)
|
|
570
544
|
return INT2FIX(ret);
|
571
545
|
}
|
572
546
|
|
573
|
-
VALUE sp_set_read_timeout_impl(self, val)
|
574
|
-
VALUE self, val;
|
547
|
+
VALUE sp_set_read_timeout_impl(VALUE self, VALUE val)
|
575
548
|
{
|
576
549
|
int timeout;
|
577
550
|
int fd;
|
@@ -610,8 +583,7 @@ VALUE sp_set_read_timeout_impl(self, val)
|
|
610
583
|
return val;
|
611
584
|
}
|
612
585
|
|
613
|
-
VALUE sp_get_read_timeout_impl(self)
|
614
|
-
VALUE self;
|
586
|
+
VALUE sp_get_read_timeout_impl(VALUE self)
|
615
587
|
{
|
616
588
|
int fd;
|
617
589
|
struct termios params;
|
@@ -630,22 +602,17 @@ VALUE sp_get_read_timeout_impl(self)
|
|
630
602
|
return INT2FIX(params.c_cc[VTIME] * 100);
|
631
603
|
}
|
632
604
|
|
633
|
-
VALUE sp_set_write_timeout_impl(self, val)
|
634
|
-
VALUE self, val;
|
605
|
+
NORETURN(VALUE sp_set_write_timeout_impl(VALUE self, VALUE val))
|
635
606
|
{
|
636
607
|
rb_notimplement();
|
637
|
-
return self;
|
638
608
|
}
|
639
609
|
|
640
|
-
VALUE sp_get_write_timeout_impl(self)
|
641
|
-
VALUE self;
|
610
|
+
NORETURN(VALUE sp_get_write_timeout_impl(VALUE self))
|
642
611
|
{
|
643
612
|
rb_notimplement();
|
644
|
-
return self;
|
645
613
|
}
|
646
614
|
|
647
|
-
VALUE sp_break_impl(self, time)
|
648
|
-
VALUE self, time;
|
615
|
+
VALUE sp_break_impl(VALUE self, VALUE time)
|
649
616
|
{
|
650
617
|
int fd;
|
651
618
|
|
@@ -661,9 +628,7 @@ VALUE sp_break_impl(self, time)
|
|
661
628
|
return Qnil;
|
662
629
|
}
|
663
630
|
|
664
|
-
void get_line_signals_helper_impl(obj, ls)
|
665
|
-
VALUE obj;
|
666
|
-
struct line_signals *ls;
|
631
|
+
void get_line_signals_helper_impl(VALUE obj, struct line_signals *ls)
|
667
632
|
{
|
668
633
|
int fd, status;
|
669
634
|
|
@@ -682,9 +647,7 @@ void get_line_signals_helper_impl(obj, ls)
|
|
682
647
|
ls->ri = (status & TIOCM_RI ? 1 : 0);
|
683
648
|
}
|
684
649
|
|
685
|
-
VALUE set_signal_impl(obj, val, sig)
|
686
|
-
VALUE obj,val;
|
687
|
-
int sig;
|
650
|
+
VALUE set_signal_impl(VALUE obj, VALUE val, int sig)
|
688
651
|
{
|
689
652
|
int status;
|
690
653
|
int fd;
|
@@ -721,20 +684,17 @@ VALUE set_signal_impl(obj, val, sig)
|
|
721
684
|
return val;
|
722
685
|
}
|
723
686
|
|
724
|
-
VALUE sp_set_rts_impl(self, val)
|
725
|
-
VALUE self, val;
|
687
|
+
VALUE sp_set_rts_impl(VALUE self, VALUE val)
|
726
688
|
{
|
727
689
|
return set_signal_impl(self, val, TIOCM_RTS);
|
728
690
|
}
|
729
691
|
|
730
|
-
VALUE sp_set_dtr_impl(self, val)
|
731
|
-
VALUE self, val;
|
692
|
+
VALUE sp_set_dtr_impl(VALUE self, VALUE val)
|
732
693
|
{
|
733
694
|
return set_signal_impl(self, val, TIOCM_DTR);
|
734
695
|
}
|
735
696
|
|
736
|
-
VALUE sp_get_rts_impl(self)
|
737
|
-
VALUE self;
|
697
|
+
VALUE sp_get_rts_impl(VALUE self)
|
738
698
|
{
|
739
699
|
struct line_signals ls;
|
740
700
|
|
@@ -742,8 +702,7 @@ VALUE sp_get_rts_impl(self)
|
|
742
702
|
return INT2FIX(ls.rts);
|
743
703
|
}
|
744
704
|
|
745
|
-
VALUE sp_get_dtr_impl(self)
|
746
|
-
VALUE self;
|
705
|
+
VALUE sp_get_dtr_impl(VALUE self)
|
747
706
|
{
|
748
707
|
struct line_signals ls;
|
749
708
|
|
@@ -752,8 +711,7 @@ VALUE sp_get_dtr_impl(self)
|
|
752
711
|
return INT2FIX(ls.dtr);
|
753
712
|
}
|
754
713
|
|
755
|
-
VALUE sp_flush_input_data_impl(self)
|
756
|
-
VALUE self;
|
714
|
+
VALUE sp_flush_input_data_impl(VALUE self)
|
757
715
|
{
|
758
716
|
int fd;
|
759
717
|
int ret;
|
@@ -768,8 +726,7 @@ VALUE self;
|
|
768
726
|
return Qtrue;
|
769
727
|
}
|
770
728
|
|
771
|
-
VALUE sp_flush_output_data_impl(self)
|
772
|
-
VALUE self;
|
729
|
+
VALUE sp_flush_output_data_impl(VALUE self)
|
773
730
|
{
|
774
731
|
int fd;
|
775
732
|
int ret;
|
data/ext/native/serialport.c
CHANGED
@@ -20,14 +20,34 @@ VALUE cSerialPort; /* serial port class */
|
|
20
20
|
VALUE sBaud, sDataBits, sStopBits, sParity; /* strings */
|
21
21
|
VALUE sRts, sDtr, sCts, sDsr, sDcd, sRi;
|
22
22
|
|
23
|
+
|
24
|
+
#ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
|
25
|
+
VALUE
|
26
|
+
io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding)
|
27
|
+
{
|
28
|
+
VALUE arguments[2] = {
|
29
|
+
(rb_update_max_fd(descriptor), INT2NUM(descriptor)),
|
30
|
+
INT2FIX(mode),
|
31
|
+
};
|
32
|
+
|
33
|
+
VALUE self = rb_class_new_instance(2, arguments, klass);
|
34
|
+
|
35
|
+
rb_io_t *fptr;
|
36
|
+
GetOpenFile(self, fptr);
|
37
|
+
fptr->pathv = path;
|
38
|
+
fptr->mode |= mode;
|
39
|
+
|
40
|
+
return self;
|
41
|
+
}
|
42
|
+
#endif
|
43
|
+
|
23
44
|
/*
|
24
45
|
* @api private
|
25
46
|
*
|
26
47
|
* @see SerialPort#new
|
27
48
|
* @see SerialPort#open
|
28
49
|
*/
|
29
|
-
static VALUE sp_create(class, _port)
|
30
|
-
VALUE class, _port;
|
50
|
+
static VALUE sp_create(VALUE class, VALUE _port)
|
31
51
|
{
|
32
52
|
return sp_create_impl(class, _port);
|
33
53
|
}
|
@@ -47,7 +67,7 @@ static VALUE sp_create(class, _port)
|
|
47
67
|
* (baud, data_bits = 8, stop_bits = 1, parity = (previous_databits == 8 ? NONE : EVEN))
|
48
68
|
* A baudrate of nil will keep the old value.
|
49
69
|
* The default parity depends on the number of databits configured before this function call.
|
50
|
-
*
|
70
|
+
*
|
51
71
|
* @overload set_modem_params(baud, data_bits, stop_bits, parity)
|
52
72
|
* @param baud [Integer] the baud rate
|
53
73
|
* @param data_bits [Integer] the number of data bits
|
@@ -59,9 +79,7 @@ static VALUE sp_create(class, _port)
|
|
59
79
|
* @return [Hash] the original paramters
|
60
80
|
* @raise [ArgumentError] if values are invalide or unsupported
|
61
81
|
*/
|
62
|
-
static VALUE sp_set_modem_params(argc, argv, self)
|
63
|
-
int argc;
|
64
|
-
VALUE *argv, self;
|
82
|
+
static VALUE sp_set_modem_params(int argc, VALUE *argv, VALUE self)
|
65
83
|
{
|
66
84
|
return sp_set_modem_params_impl(argc, argv, self);
|
67
85
|
}
|
@@ -73,20 +91,18 @@ static VALUE sp_set_modem_params(argc, argv, self)
|
|
73
91
|
* @return [nil]
|
74
92
|
* @note (POSIX) this value is very approximate
|
75
93
|
*/
|
76
|
-
static VALUE sp_break(self, time)
|
77
|
-
VALUE self, time;
|
94
|
+
static VALUE sp_break(VALUE self, VALUE time)
|
78
95
|
{
|
79
96
|
return sp_break_impl(self, time);
|
80
97
|
}
|
81
98
|
|
82
99
|
/*
|
83
|
-
* Get the state of the DTR line
|
100
|
+
* Get the state of the DTR line
|
84
101
|
*
|
85
102
|
* @note (Windows) DTR is not available
|
86
103
|
* @return [Integer] the state of DTR line, 0 or 1
|
87
104
|
*/
|
88
|
-
static VALUE sp_get_dtr(self)
|
89
|
-
VALUE self;
|
105
|
+
static VALUE sp_get_dtr(VALUE self)
|
90
106
|
{
|
91
107
|
return sp_get_dtr_impl(self);
|
92
108
|
}
|
@@ -97,8 +113,7 @@ static VALUE sp_get_dtr(self)
|
|
97
113
|
* @return [Integer] the flow control flag
|
98
114
|
* @see SerialPort#set_flow_control
|
99
115
|
*/
|
100
|
-
static VALUE sp_get_flow_control(self)
|
101
|
-
VALUE self;
|
116
|
+
static VALUE sp_get_flow_control(VALUE self)
|
102
117
|
{
|
103
118
|
return sp_get_flow_control_impl(self);
|
104
119
|
}
|
@@ -109,8 +124,7 @@ static VALUE sp_get_flow_control(self)
|
|
109
124
|
* @return [Integer] the read timeout, in milliseconds
|
110
125
|
* @see SerialPort#set_read_timeout
|
111
126
|
*/
|
112
|
-
static VALUE sp_get_read_timeout(self)
|
113
|
-
VALUE self;
|
127
|
+
static VALUE sp_get_read_timeout(VALUE self)
|
114
128
|
{
|
115
129
|
return sp_get_read_timeout_impl(self);
|
116
130
|
}
|
@@ -121,8 +135,7 @@ static VALUE sp_get_read_timeout(self)
|
|
121
135
|
* @return [Integer] the state of RTS line, 0 or 1
|
122
136
|
* @note (Windows) RTS is not available
|
123
137
|
*/
|
124
|
-
static VALUE sp_get_rts(self)
|
125
|
-
VALUE self;
|
138
|
+
static VALUE sp_get_rts(VALUE self)
|
126
139
|
{
|
127
140
|
return sp_get_rts_impl(self);
|
128
141
|
}
|
@@ -133,8 +146,7 @@ static VALUE sp_get_rts(self)
|
|
133
146
|
* @return [Integer] the write timeout, in milliseconds
|
134
147
|
* @note (POSIX) write timeouts are not implemented
|
135
148
|
*/
|
136
|
-
static VALUE sp_get_write_timeout(self)
|
137
|
-
VALUE self;
|
149
|
+
static VALUE sp_get_write_timeout(VALUE self)
|
138
150
|
{
|
139
151
|
return sp_get_write_timeout_impl(self);
|
140
152
|
}
|
@@ -145,8 +157,7 @@ static VALUE sp_get_write_timeout(self)
|
|
145
157
|
* @param val [Integer] the desired state of the DTR line, 0 or 1
|
146
158
|
* @return [Integer] the original +val+ parameter
|
147
159
|
*/
|
148
|
-
static VALUE sp_set_dtr(self, val)
|
149
|
-
VALUE self, val;
|
160
|
+
static VALUE sp_set_dtr(VALUE self, VALUE val)
|
150
161
|
{
|
151
162
|
return sp_set_dtr_impl(self, val);
|
152
163
|
}
|
@@ -161,8 +172,7 @@ static VALUE sp_set_dtr(self, val)
|
|
161
172
|
* @note SerialPort::HARD uses RTS/CTS handshaking.
|
162
173
|
* DSR/DTR is not supported.
|
163
174
|
*/
|
164
|
-
static VALUE sp_set_flow_control(self, val)
|
165
|
-
VALUE self, val;
|
175
|
+
static VALUE sp_set_flow_control(VALUE self, VALUE val)
|
166
176
|
{
|
167
177
|
return sp_set_flow_control_impl(self, val);
|
168
178
|
}
|
@@ -179,8 +189,7 @@ static VALUE sp_set_flow_control(self, val)
|
|
179
189
|
* @return [Integer] the original +timeout+ parameter
|
180
190
|
* @note Read timeouts don't mix well with multi-threading
|
181
191
|
*/
|
182
|
-
static VALUE sp_set_read_timeout(self, val)
|
183
|
-
VALUE self, val;
|
192
|
+
static VALUE sp_set_read_timeout(VALUE self, VALUE val)
|
184
193
|
{
|
185
194
|
return sp_set_read_timeout_impl(self, val);
|
186
195
|
}
|
@@ -191,8 +200,7 @@ static VALUE sp_set_read_timeout(self, val)
|
|
191
200
|
* @param val [Integer] the state of RTS line, 0 or 1
|
192
201
|
* @return [Integer] the original +val+ parameter
|
193
202
|
*/
|
194
|
-
static VALUE sp_set_rts(self, val)
|
195
|
-
VALUE self, val;
|
203
|
+
static VALUE sp_set_rts(VALUE self, VALUE val)
|
196
204
|
{
|
197
205
|
return sp_set_rts_impl(self, val);
|
198
206
|
}
|
@@ -204,8 +212,7 @@ static VALUE sp_set_rts(self, val)
|
|
204
212
|
* @return [Integer] the original +val+ parameter
|
205
213
|
* @note (POSIX) write timeouts are not implemented
|
206
214
|
*/
|
207
|
-
static VALUE sp_set_write_timeout(self, val)
|
208
|
-
VALUE self, val;
|
215
|
+
static VALUE sp_set_write_timeout(VALUE self, VALUE val)
|
209
216
|
{
|
210
217
|
return sp_set_write_timeout_impl(self, val);
|
211
218
|
}
|
@@ -213,9 +220,7 @@ static VALUE sp_set_write_timeout(self, val)
|
|
213
220
|
/*
|
214
221
|
* @private helper
|
215
222
|
*/
|
216
|
-
static void get_modem_params(self, mp)
|
217
|
-
VALUE self;
|
218
|
-
struct modem_params *mp;
|
223
|
+
static void get_modem_params(VALUE self, struct modem_params *mp)
|
219
224
|
{
|
220
225
|
get_modem_params_impl(self, mp);
|
221
226
|
}
|
@@ -227,8 +232,7 @@ static void get_modem_params(self, mp)
|
|
227
232
|
* @return [Integer] the original +data_rate+ parameter
|
228
233
|
* @see SerialPort#set_modem_params
|
229
234
|
*/
|
230
|
-
static VALUE sp_set_data_rate(self, data_rate)
|
231
|
-
VALUE self, data_rate;
|
235
|
+
static VALUE sp_set_data_rate(VALUE self, VALUE data_rate)
|
232
236
|
{
|
233
237
|
VALUE argv[4];
|
234
238
|
|
@@ -246,8 +250,7 @@ static VALUE sp_set_data_rate(self, data_rate)
|
|
246
250
|
* @return [Integer] the original +data_bits+ parameter
|
247
251
|
* @see SerialPort#set_modem_params
|
248
252
|
*/
|
249
|
-
static VALUE sp_set_data_bits(self, data_bits)
|
250
|
-
VALUE self, data_bits;
|
253
|
+
static VALUE sp_set_data_bits(VALUE self, VALUE data_bits)
|
251
254
|
{
|
252
255
|
VALUE argv[4];
|
253
256
|
|
@@ -265,8 +268,7 @@ static VALUE sp_set_data_bits(self, data_bits)
|
|
265
268
|
* @return [Integer] the original +stop_bits+ parameter
|
266
269
|
* @see SerialPort#set_modem_params
|
267
270
|
*/
|
268
|
-
static VALUE sp_set_stop_bits(self, stop_bits)
|
269
|
-
VALUE self, stop_bits;
|
271
|
+
static VALUE sp_set_stop_bits(VALUE self, VALUE stop_bits)
|
270
272
|
{
|
271
273
|
VALUE argv[4];
|
272
274
|
|
@@ -284,8 +286,7 @@ static VALUE sp_set_stop_bits(self, stop_bits)
|
|
284
286
|
* @return [Integer] the original +parity+ parameter
|
285
287
|
* @see SerialPort#set_modem_params
|
286
288
|
*/
|
287
|
-
static VALUE sp_set_parity(self, parity)
|
288
|
-
VALUE self, parity;
|
289
|
+
static VALUE sp_set_parity(VALUE self, VALUE parity)
|
289
290
|
{
|
290
291
|
VALUE argv[4];
|
291
292
|
|
@@ -302,8 +303,7 @@ static VALUE sp_set_parity(self, parity)
|
|
302
303
|
* @return [Integer] the current baud rate
|
303
304
|
* @see SerialPort#set_modem_params
|
304
305
|
*/
|
305
|
-
static VALUE sp_get_data_rate(self)
|
306
|
-
VALUE self;
|
306
|
+
static VALUE sp_get_data_rate(VALUE self)
|
307
307
|
{
|
308
308
|
struct modem_params mp;
|
309
309
|
|
@@ -318,8 +318,7 @@ static VALUE sp_get_data_rate(self)
|
|
318
318
|
* @return [Integer] the current number of data bits
|
319
319
|
* @see SerialPort#set_modem_params
|
320
320
|
*/
|
321
|
-
static VALUE sp_get_data_bits(self)
|
322
|
-
VALUE self;
|
321
|
+
static VALUE sp_get_data_bits(VALUE self)
|
323
322
|
{
|
324
323
|
struct modem_params mp;
|
325
324
|
|
@@ -334,8 +333,7 @@ static VALUE sp_get_data_bits(self)
|
|
334
333
|
* @return [Integer] the current number of stop bits
|
335
334
|
* @see SerialPort#set_modem_params for details
|
336
335
|
*/
|
337
|
-
static VALUE sp_get_stop_bits(self)
|
338
|
-
VALUE self;
|
336
|
+
static VALUE sp_get_stop_bits(VALUE self)
|
339
337
|
{
|
340
338
|
struct modem_params mp;
|
341
339
|
|
@@ -350,8 +348,7 @@ static VALUE sp_get_stop_bits(self)
|
|
350
348
|
* @return [Integer] the current parity
|
351
349
|
* @see SerialPort#set_modem_params
|
352
350
|
*/
|
353
|
-
static VALUE sp_get_parity(self)
|
354
|
-
VALUE self;
|
351
|
+
static VALUE sp_get_parity(VALUE self)
|
355
352
|
{
|
356
353
|
struct modem_params mp;
|
357
354
|
|
@@ -366,8 +363,7 @@ static VALUE sp_get_parity(self)
|
|
366
363
|
* @return [Hash] the serial port configuration
|
367
364
|
* @see SerialPort#set_modem_params
|
368
365
|
*/
|
369
|
-
static VALUE sp_get_modem_params(self)
|
370
|
-
VALUE self;
|
366
|
+
static VALUE sp_get_modem_params(VALUE self)
|
371
367
|
{
|
372
368
|
struct modem_params mp;
|
373
369
|
VALUE hash;
|
@@ -387,9 +383,7 @@ static VALUE sp_get_modem_params(self)
|
|
387
383
|
/*
|
388
384
|
* @api private
|
389
385
|
*/
|
390
|
-
void get_line_signals_helper(obj, ls)
|
391
|
-
VALUE obj;
|
392
|
-
struct line_signals *ls;
|
386
|
+
void get_line_signals_helper(VALUE obj, struct line_signals *ls)
|
393
387
|
{
|
394
388
|
get_line_signals_helper_impl(obj, ls);
|
395
389
|
}
|
@@ -400,8 +394,7 @@ void get_line_signals_helper(obj, ls)
|
|
400
394
|
* @return [Integer] the state of the CTS line, 0 or 1
|
401
395
|
* @see SerialPort#get_signals
|
402
396
|
*/
|
403
|
-
static VALUE sp_get_cts(self)
|
404
|
-
VALUE self;
|
397
|
+
static VALUE sp_get_cts(VALUE self)
|
405
398
|
{
|
406
399
|
struct line_signals ls;
|
407
400
|
|
@@ -416,8 +409,7 @@ static VALUE sp_get_cts(self)
|
|
416
409
|
* @return [Integer] the state of the DSR line, 0 or 1
|
417
410
|
* @see SerialPort#get_signals
|
418
411
|
*/
|
419
|
-
static VALUE sp_get_dsr(self)
|
420
|
-
VALUE self;
|
412
|
+
static VALUE sp_get_dsr(VALUE self)
|
421
413
|
{
|
422
414
|
struct line_signals ls;
|
423
415
|
|
@@ -432,8 +424,7 @@ static VALUE sp_get_dsr(self)
|
|
432
424
|
* @return [Integer] the state of the DCD line, 0 or 1
|
433
425
|
* @see SerialPort#get_signals
|
434
426
|
*/
|
435
|
-
static VALUE sp_get_dcd(self)
|
436
|
-
VALUE self;
|
427
|
+
static VALUE sp_get_dcd(VALUE self)
|
437
428
|
{
|
438
429
|
struct line_signals ls;
|
439
430
|
|
@@ -448,8 +439,7 @@ static VALUE sp_get_dcd(self)
|
|
448
439
|
* @return [Integer] the state of the RI line, 0 or 1
|
449
440
|
* @see SerialPort#get_signals
|
450
441
|
*/
|
451
|
-
static VALUE sp_get_ri(self)
|
452
|
-
VALUE self;
|
442
|
+
static VALUE sp_get_ri(VALUE self)
|
453
443
|
{
|
454
444
|
struct line_signals ls;
|
455
445
|
|
@@ -467,8 +457,7 @@ static VALUE sp_get_ri(self)
|
|
467
457
|
* @note (Windows) the rts and dtr values are not included
|
468
458
|
* @note This method is implemented as both SerialPort#signals and SerialPort#get_signals
|
469
459
|
*/
|
470
|
-
static VALUE sp_signals(self)
|
471
|
-
VALUE self;
|
460
|
+
static VALUE sp_signals(VALUE self)
|
472
461
|
{
|
473
462
|
struct line_signals ls;
|
474
463
|
VALUE hash;
|
@@ -494,8 +483,7 @@ static VALUE sp_signals(self)
|
|
494
483
|
*
|
495
484
|
* @return [Boolean] true on success or false if an error occurs.
|
496
485
|
*/
|
497
|
-
static VALUE sp_flush_input_data(self)
|
498
|
-
VALUE self;
|
486
|
+
static VALUE sp_flush_input_data(VALUE self)
|
499
487
|
{
|
500
488
|
return sp_flush_input_data_impl(self);
|
501
489
|
}
|
@@ -505,14 +493,13 @@ static VALUE sp_flush_input_data(self)
|
|
505
493
|
*
|
506
494
|
* @return [Boolean] true on success or false if an error occurs.
|
507
495
|
*/
|
508
|
-
static VALUE sp_flush_output_data(self)
|
509
|
-
VALUE self;
|
496
|
+
static VALUE sp_flush_output_data(VALUE self)
|
510
497
|
{
|
511
498
|
return sp_flush_output_data_impl(self);
|
512
499
|
}
|
513
500
|
|
514
501
|
|
515
|
-
void Init_serialport()
|
502
|
+
void Init_serialport(void)
|
516
503
|
{
|
517
504
|
sBaud = rb_str_new2("baud");
|
518
505
|
sDataBits = rb_str_new2("data_bits");
|
data/ext/native/serialport.h
CHANGED
@@ -22,10 +22,11 @@
|
|
22
22
|
#define _RUBY_SERIAL_PORT_H_
|
23
23
|
|
24
24
|
#include <ruby.h> /* ruby inclusion */
|
25
|
-
#
|
26
|
-
|
27
|
-
#
|
28
|
-
|
25
|
+
#include <ruby/io.h>
|
26
|
+
|
27
|
+
#ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
|
28
|
+
VALUE io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding);
|
29
|
+
#define rb_io_open_descriptor io_open_descriptor_fallback
|
29
30
|
#endif
|
30
31
|
|
31
32
|
struct modem_params
|
@@ -56,14 +57,7 @@ struct line_signals
|
|
56
57
|
#define EVEN EVENPARITY
|
57
58
|
#define ODD ODDPARITY
|
58
59
|
|
59
|
-
#
|
60
|
-
#ifndef HAVE_RUBY_IO_H
|
61
|
-
#define RB_SERIAL_EXPORT __declspec(dllexport)
|
62
|
-
#else
|
63
|
-
#define RB_SERIAL_EXPORT
|
64
|
-
#endif
|
65
|
-
#endif
|
66
|
-
|
60
|
+
#define RB_SERIAL_EXPORT
|
67
61
|
#else
|
68
62
|
#define EVEN 1
|
69
63
|
#define ODD 2
|
@@ -33,52 +33,37 @@ static char sGetCommTimeouts[] = "GetCommTimeouts";
|
|
33
33
|
static char sSetCommTimeouts[] = "SetCommTimeouts";
|
34
34
|
|
35
35
|
|
36
|
-
static HANDLE get_handle_helper(
|
37
|
-
VALUE obj;
|
36
|
+
static HANDLE get_handle_helper(VALUE io)
|
38
37
|
{
|
39
|
-
#ifdef
|
40
|
-
|
38
|
+
#ifdef HAVE_RB_IO_DESCRIPTOR
|
39
|
+
return (HANDLE) _get_osfhandle(rb_io_descriptor(io));
|
41
40
|
#else
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
GetOpenFile(obj, fptr);
|
46
|
-
#ifdef HAVE_RUBY_IO_H
|
47
|
-
return (HANDLE) _get_osfhandle(fptr->fd);
|
48
|
-
#else
|
49
|
-
return (HANDLE) _get_osfhandle(fileno(fptr->f));
|
41
|
+
rb_io_t* fp;
|
42
|
+
GetOpenFile(io, fp);
|
43
|
+
return (HANDLE) _get_osfhandle(fp->fd);
|
50
44
|
#endif
|
51
45
|
}
|
52
46
|
|
53
47
|
/* hack to work around the fact that Ruby doesn't use GetLastError? */
|
54
|
-
static void _rb_win32_fail(const char *function_call) {
|
48
|
+
static NORETURN( void _rb_win32_fail(const char *function_call) {
|
55
49
|
rb_raise(
|
56
|
-
rb_eRuntimeError,
|
57
|
-
"%s failed: GetLastError returns %
|
50
|
+
rb_eRuntimeError,
|
51
|
+
"%s failed: GetLastError returns %lu",
|
58
52
|
function_call, GetLastError( )
|
59
53
|
);
|
60
|
-
}
|
54
|
+
})
|
61
55
|
|
62
|
-
VALUE RB_SERIAL_EXPORT sp_create_impl(class, _port)
|
63
|
-
VALUE class, _port;
|
56
|
+
VALUE RB_SERIAL_EXPORT sp_create_impl(VALUE class, VALUE _port)
|
64
57
|
{
|
65
|
-
#ifdef HAVE_RUBY_IO_H
|
66
|
-
rb_io_t *fp;
|
67
|
-
#else
|
68
|
-
OpenFile *fp;
|
69
|
-
#endif
|
70
58
|
int fd;
|
71
59
|
HANDLE fh;
|
72
60
|
int num_port;
|
73
61
|
char *str_port;
|
74
62
|
char port[260]; /* Windows XP MAX_PATH. See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx */
|
63
|
+
VALUE sp;
|
75
64
|
|
76
65
|
DCB dcb;
|
77
66
|
|
78
|
-
NEWOBJ(sp, struct RFile);
|
79
|
-
OBJSETUP(sp, class, T_FILE);
|
80
|
-
MakeOpenFile((VALUE) sp, fp);
|
81
|
-
|
82
67
|
switch(TYPE(_port))
|
83
68
|
{
|
84
69
|
case T_FIXNUM:
|
@@ -148,18 +133,11 @@ VALUE RB_SERIAL_EXPORT sp_create_impl(class, _port)
|
|
148
133
|
}
|
149
134
|
|
150
135
|
errno = 0;
|
151
|
-
|
152
|
-
|
153
|
-
fp->fd = fd;
|
154
|
-
#else
|
155
|
-
fp->f = fdopen(fd, "rb+");
|
156
|
-
#endif
|
157
|
-
return (VALUE) sp;
|
136
|
+
sp = rb_io_open_descriptor(class, fd, FMODE_READWRITE | FMODE_BINMODE | FMODE_SYNC, Qnil, Qnil, NULL);
|
137
|
+
return sp;
|
158
138
|
}
|
159
139
|
|
160
|
-
VALUE RB_SERIAL_EXPORT sp_set_modem_params_impl(argc, argv, self)
|
161
|
-
int argc;
|
162
|
-
VALUE *argv, self;
|
140
|
+
VALUE RB_SERIAL_EXPORT sp_set_modem_params_impl(int argc, VALUE *argv, VALUE self)
|
163
141
|
{
|
164
142
|
HANDLE fh;
|
165
143
|
DCB dcb;
|
@@ -294,9 +272,7 @@ VALUE RB_SERIAL_EXPORT sp_set_modem_params_impl(argc, argv, self)
|
|
294
272
|
return argv[0];
|
295
273
|
}
|
296
274
|
|
297
|
-
void RB_SERIAL_EXPORT get_modem_params_impl(self, mp)
|
298
|
-
VALUE self;
|
299
|
-
struct modem_params *mp;
|
275
|
+
void RB_SERIAL_EXPORT get_modem_params_impl(VALUE self, struct modem_params *mp)
|
300
276
|
{
|
301
277
|
HANDLE fh;
|
302
278
|
DCB dcb;
|
@@ -314,8 +290,7 @@ void RB_SERIAL_EXPORT get_modem_params_impl(self, mp)
|
|
314
290
|
mp->parity = dcb.Parity;
|
315
291
|
}
|
316
292
|
|
317
|
-
VALUE RB_SERIAL_EXPORT sp_set_flow_control_impl(self, val)
|
318
|
-
VALUE self, val;
|
293
|
+
VALUE RB_SERIAL_EXPORT sp_set_flow_control_impl(VALUE self, VALUE val)
|
319
294
|
{
|
320
295
|
HANDLE fh;
|
321
296
|
int flowc;
|
@@ -359,8 +334,7 @@ VALUE RB_SERIAL_EXPORT sp_set_flow_control_impl(self, val)
|
|
359
334
|
return val;
|
360
335
|
}
|
361
336
|
|
362
|
-
VALUE RB_SERIAL_EXPORT sp_get_flow_control_impl(self)
|
363
|
-
VALUE self;
|
337
|
+
VALUE RB_SERIAL_EXPORT sp_get_flow_control_impl(VALUE self)
|
364
338
|
{
|
365
339
|
HANDLE fh;
|
366
340
|
int ret;
|
@@ -387,8 +361,7 @@ VALUE RB_SERIAL_EXPORT sp_get_flow_control_impl(self)
|
|
387
361
|
return INT2FIX(ret);
|
388
362
|
}
|
389
363
|
|
390
|
-
VALUE RB_SERIAL_EXPORT sp_set_read_timeout_impl(self, val)
|
391
|
-
VALUE self, val;
|
364
|
+
VALUE RB_SERIAL_EXPORT sp_set_read_timeout_impl(VALUE self, VALUE val)
|
392
365
|
{
|
393
366
|
int timeout;
|
394
367
|
HANDLE fh;
|
@@ -430,8 +403,7 @@ VALUE RB_SERIAL_EXPORT sp_set_read_timeout_impl(self, val)
|
|
430
403
|
return val;
|
431
404
|
}
|
432
405
|
|
433
|
-
VALUE RB_SERIAL_EXPORT sp_get_read_timeout_impl(self)
|
434
|
-
VALUE self;
|
406
|
+
VALUE RB_SERIAL_EXPORT sp_get_read_timeout_impl(VALUE self)
|
435
407
|
{
|
436
408
|
HANDLE fh;
|
437
409
|
COMMTIMEOUTS ctout;
|
@@ -453,8 +425,7 @@ VALUE RB_SERIAL_EXPORT sp_get_read_timeout_impl(self)
|
|
453
425
|
return INT2FIX(ctout.ReadTotalTimeoutConstant);
|
454
426
|
}
|
455
427
|
|
456
|
-
VALUE RB_SERIAL_EXPORT sp_set_write_timeout_impl(self, val)
|
457
|
-
VALUE self, val;
|
428
|
+
VALUE RB_SERIAL_EXPORT sp_set_write_timeout_impl(VALUE self, VALUE val)
|
458
429
|
{
|
459
430
|
int timeout;
|
460
431
|
HANDLE fh;
|
@@ -488,8 +459,7 @@ VALUE RB_SERIAL_EXPORT sp_set_write_timeout_impl(self, val)
|
|
488
459
|
return val;
|
489
460
|
}
|
490
461
|
|
491
|
-
VALUE RB_SERIAL_EXPORT sp_get_write_timeout_impl(self)
|
492
|
-
VALUE self;
|
462
|
+
VALUE RB_SERIAL_EXPORT sp_get_write_timeout_impl(VALUE self)
|
493
463
|
{
|
494
464
|
HANDLE fh;
|
495
465
|
COMMTIMEOUTS ctout;
|
@@ -503,8 +473,7 @@ VALUE RB_SERIAL_EXPORT sp_get_write_timeout_impl(self)
|
|
503
473
|
return INT2FIX(ctout.WriteTotalTimeoutMultiplier);
|
504
474
|
}
|
505
475
|
|
506
|
-
static void delay_ms(time)
|
507
|
-
int time;
|
476
|
+
static void delay_ms(int time)
|
508
477
|
{
|
509
478
|
HANDLE ev;
|
510
479
|
|
@@ -522,8 +491,7 @@ static void delay_ms(time)
|
|
522
491
|
CloseHandle(ev);
|
523
492
|
}
|
524
493
|
|
525
|
-
VALUE RB_SERIAL_EXPORT sp_break_impl(self, time)
|
526
|
-
VALUE self, time;
|
494
|
+
VALUE RB_SERIAL_EXPORT sp_break_impl(VALUE self, VALUE time)
|
527
495
|
{
|
528
496
|
HANDLE fh;
|
529
497
|
|
@@ -541,9 +509,7 @@ VALUE RB_SERIAL_EXPORT sp_break_impl(self, time)
|
|
541
509
|
return Qnil;
|
542
510
|
}
|
543
511
|
|
544
|
-
void RB_SERIAL_EXPORT get_line_signals_helper_impl(obj, ls)
|
545
|
-
VALUE obj;
|
546
|
-
struct line_signals *ls;
|
512
|
+
void RB_SERIAL_EXPORT get_line_signals_helper_impl(VALUE obj, struct line_signals *ls)
|
547
513
|
{
|
548
514
|
HANDLE fh;
|
549
515
|
unsigned long status; /* DWORD */
|
@@ -560,9 +526,7 @@ void RB_SERIAL_EXPORT get_line_signals_helper_impl(obj, ls)
|
|
560
526
|
ls->ri = (status & MS_RING_ON ? 1 : 0);
|
561
527
|
}
|
562
528
|
|
563
|
-
static VALUE set_signal(obj, val, sigoff, sigon)
|
564
|
-
VALUE obj,val;
|
565
|
-
int sigoff, sigon;
|
529
|
+
static VALUE set_signal(VALUE obj, VALUE val, int sigoff, int sigon)
|
566
530
|
{
|
567
531
|
HANDLE fh;
|
568
532
|
int set, sig;
|
@@ -592,36 +556,35 @@ static VALUE set_signal(obj, val, sigoff, sigon)
|
|
592
556
|
return val;
|
593
557
|
}
|
594
558
|
|
595
|
-
VALUE RB_SERIAL_EXPORT sp_set_rts_impl(self, val)
|
596
|
-
VALUE self, val;
|
559
|
+
VALUE RB_SERIAL_EXPORT sp_set_rts_impl(VALUE self, VALUE val)
|
597
560
|
{
|
598
561
|
return set_signal(self, val, CLRRTS, SETRTS);
|
599
562
|
}
|
600
563
|
|
601
|
-
VALUE RB_SERIAL_EXPORT sp_set_dtr_impl(self, val)
|
602
|
-
VALUE self, val;
|
564
|
+
VALUE RB_SERIAL_EXPORT sp_set_dtr_impl(VALUE self, VALUE val)
|
603
565
|
{
|
604
566
|
return set_signal(self, val, CLRDTR, SETDTR);
|
605
567
|
}
|
606
568
|
|
607
|
-
VALUE RB_SERIAL_EXPORT sp_get_rts_impl(self)
|
608
|
-
VALUE self;
|
569
|
+
VALUE RB_SERIAL_EXPORT sp_get_rts_impl(VALUE self)
|
609
570
|
{
|
610
571
|
rb_notimplement();
|
611
572
|
return self;
|
612
573
|
}
|
613
574
|
|
614
|
-
VALUE RB_SERIAL_EXPORT sp_get_dtr_impl(self)
|
615
|
-
VALUE self;
|
575
|
+
VALUE RB_SERIAL_EXPORT sp_get_dtr_impl(VALUE self)
|
616
576
|
{
|
617
577
|
rb_notimplement();
|
618
578
|
return self;
|
619
579
|
}
|
620
580
|
|
581
|
+
#ifndef PURGE_RXABORT
|
621
582
|
#define PURGE_RXABORT 0x02
|
583
|
+
#endif
|
584
|
+
#ifndef PURGE_RXCLEAR
|
622
585
|
#define PURGE_RXCLEAR 0x08
|
623
|
-
|
624
|
-
|
586
|
+
#endif
|
587
|
+
VALUE RB_SERIAL_EXPORT sp_flush_input_data_impl(VALUE self)
|
625
588
|
{
|
626
589
|
BOOL ret;
|
627
590
|
HANDLE fh;
|
@@ -635,10 +598,13 @@ VALUE RB_SERIAL_EXPORT sp_flush_input_data_impl(self)
|
|
635
598
|
return Qtrue;
|
636
599
|
}
|
637
600
|
|
601
|
+
#ifndef PURGE_TXABORT
|
638
602
|
#define PURGE_TXABORT 0x01
|
603
|
+
#endif
|
604
|
+
#ifndef PURGE_TXCLEAR
|
639
605
|
#define PURGE_TXCLEAR 0x04
|
640
|
-
|
641
|
-
|
606
|
+
#endif
|
607
|
+
VALUE RB_SERIAL_EXPORT sp_flush_output_data_impl(VALUE self)
|
642
608
|
{
|
643
609
|
BOOL ret;
|
644
610
|
HANDLE fh;
|
data/lib/serialport/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
class SerialPort
|
2
|
-
VERSION = "1.
|
1
|
+
class SerialPort < IO
|
2
|
+
VERSION = "1.4.0"
|
3
3
|
end
|
data/lib/serialport.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'serialport.so'
|
2
|
-
require 'serialport/version'
|
3
2
|
|
4
3
|
|
5
4
|
# This class is used for communication over a serial port.
|
@@ -7,7 +6,9 @@ require 'serialport/version'
|
|
7
6
|
#
|
8
7
|
# @see http://rubydoc.info/stdlib/core/IO Ruby IO class
|
9
8
|
# @see http://www.cmrr.umn.edu/~strupp/serial.html "Serial Programming Guide for POSIX Operating Systems"
|
10
|
-
class SerialPort
|
9
|
+
class SerialPort < IO
|
10
|
+
autoload :VERSION, 'serialport/version'
|
11
|
+
|
11
12
|
private_class_method(:create)
|
12
13
|
|
13
14
|
# Creates a serial port object.
|
data/serialport.gemspec
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
$: << "lib"
|
3
|
+
require "serialport/version"
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = "serialport"
|
6
7
|
s.license = "GPL-2"
|
7
8
|
s.version = SerialPort::VERSION
|
8
|
-
s.authors = ["Guillaume Pierronnet", "Alan Stern", "Daniel E. Shipton", "Tobin Richard", "Hector Parra", "Ryan C. Payne"]
|
9
|
+
s.authors = ["Guillaume Pierronnet", "Alan Stern", "Daniel E. Shipton", "Tobin Richard", "Hector Parra", "Ryan C. Payne", "Lars Kanis"]
|
9
10
|
s.summary = "Library for using RS-232 serial ports."
|
10
11
|
s.description = "Ruby/SerialPort is a Ruby library that provides a class for using RS-232 serial ports."
|
11
|
-
s.email = "
|
12
|
-
s.homepage = "http://github.com/
|
12
|
+
s.email = "lars@greiz-reinsdorf.de"
|
13
|
+
s.homepage = "http://github.com/larskanis/ruby-serialport/"
|
13
14
|
|
15
|
+
s.required_ruby_version = '>= 2.5'
|
14
16
|
s.add_development_dependency "bundler"
|
15
17
|
s.add_development_dependency "rake"
|
16
18
|
s.add_development_dependency "rake-compiler", ">= 0.4.1"
|
data.tar.gz.sig
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serialport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Pierronnet
|
@@ -10,10 +10,35 @@ authors:
|
|
10
10
|
- Tobin Richard
|
11
11
|
- Hector Parra
|
12
12
|
- Ryan C. Payne
|
13
|
-
|
13
|
+
- Lars Kanis
|
14
14
|
bindir: bin
|
15
|
-
cert_chain:
|
16
|
-
|
15
|
+
cert_chain:
|
16
|
+
- |
|
17
|
+
-----BEGIN CERTIFICATE-----
|
18
|
+
MIIEBDCCAmygAwIBAgIBAzANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1sYXJz
|
19
|
+
L0RDPWdyZWl6LXJlaW5zZG9yZi9EQz1kZTAeFw0yNDEyMjkxOTU2NTZaFw0yNTEy
|
20
|
+
MjkxOTU2NTZaMCgxJjAkBgNVBAMMHWxhcnMvREM9Z3JlaXotcmVpbnNkb3JmL0RD
|
21
|
+
PWRlMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAwum6Y1KznfpzXOT/
|
22
|
+
mZgJTBbxZuuZF49Fq3K0WA67YBzNlDv95qzSp7V/7Ek3NCcnT7G+2kSuhNo1FhdN
|
23
|
+
eSDO/moYebZNAcu3iqLsuzuULXPLuoU0GsMnVMqV9DZPh7cQHE5EBZ7hlzDBK7k/
|
24
|
+
8nBMvR0mHo77kIkapHc26UzVq/G0nKLfDsIHXVylto3PjzOumjG6GhmFN4r3cP6e
|
25
|
+
SDfl1FSeRYVpt4kmQULz/zdSaOH3AjAq7PM2Z91iGwQvoUXMANH2v89OWjQO/NHe
|
26
|
+
JMNDFsmHK/6Ji4Kk48Z3TyscHQnipAID5GhS1oD21/WePdj7GhmbF5gBzkV5uepd
|
27
|
+
eJQPgWGwrQW/Z2oPjRuJrRofzWfrMWqbOahj9uth6WSxhNexUtbjk6P8emmXOJi5
|
28
|
+
chQPnWX+N3Gj+jjYxqTFdwT7Mj3pv1VHa+aNUbqSPpvJeDyxRIuo9hvzDaBHb/Cg
|
29
|
+
9qRVcm8a96n4t7y2lrX1oookY6bkBaxWOMtWlqIprq8JZXM9AgMBAAGjOTA3MAkG
|
30
|
+
A1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQ4h1tIyvdUWtMI739xMzTR
|
31
|
+
7EfMFzANBgkqhkiG9w0BAQsFAAOCAYEAoZZWzNV2XXaoSmvyamSSN+Wt/Ia+DNrU
|
32
|
+
2pc3kMEqykH6l1WiVPszr6HavQ//2I2UcSRSS5AGDdiSXcfyFmHtMBdtJHhTPcn7
|
33
|
+
4DLliB0szpvwG+ltGD8PI8eWkLaTQeFzs+0QCTavgKV+Zw56Q0J5zZvHHUMrLkUD
|
34
|
+
qhwKjdTdkrRTn9Sqi0BrIRRZGTUDdrt8qoWm35aES5arKZzytgrRD/kXfFW2LCg0
|
35
|
+
FzgTKibR4/3g8ph94kQLg/D2SMlVPkQ3ECi036mZxDC2n8V6u3rDkG5923wmrRZB
|
36
|
+
J6cqz475Q8HYORQCB68OPzkWMfC7mBo3vpSsIqRoNs1FE4FJu4FGwZG8fBSrDC4H
|
37
|
+
bZe+GtyS3e2SMjgT65zp35gLO9I7MquzYN9P6V2u1iBpTycchk5z9R1ghxzZSBT8
|
38
|
+
DrkJ9tVlPQtJB0LqT0tvBap4upnwT1xYq721b5dwH6AF4Pi6iz/dc5vnq1/MH8bV
|
39
|
+
8VbbBzzeE7MsvgkP3sHlLmY8PtuyViJ8
|
40
|
+
-----END CERTIFICATE-----
|
41
|
+
date: 2025-06-16 00:00:00.000000000 Z
|
17
42
|
dependencies:
|
18
43
|
- !ruby/object:Gem::Dependency
|
19
44
|
name: bundler
|
@@ -59,7 +84,7 @@ dependencies:
|
|
59
84
|
version: 0.4.1
|
60
85
|
description: Ruby/SerialPort is a Ruby library that provides a class for using RS-232
|
61
86
|
serial ports.
|
62
|
-
email:
|
87
|
+
email: lars@greiz-reinsdorf.de
|
63
88
|
executables: []
|
64
89
|
extensions:
|
65
90
|
- ext/native/extconf.rb
|
@@ -67,13 +92,12 @@ extra_rdoc_files:
|
|
67
92
|
- LICENSE
|
68
93
|
- README.md
|
69
94
|
files:
|
95
|
+
- ".github/workflows/ci.yml"
|
70
96
|
- ".gitignore"
|
71
|
-
- ".travis.yml"
|
72
97
|
- CHANGELOG
|
73
98
|
- CHECKLIST
|
74
99
|
- Gemfile
|
75
100
|
- LICENSE
|
76
|
-
- MANIFEST
|
77
101
|
- README.md
|
78
102
|
- Rakefile
|
79
103
|
- ext/native/extconf.rb
|
@@ -86,11 +110,10 @@ files:
|
|
86
110
|
- serialport.gemspec
|
87
111
|
- test/miniterm.rb
|
88
112
|
- test/set_readtimeout.rb
|
89
|
-
homepage: http://github.com/
|
113
|
+
homepage: http://github.com/larskanis/ruby-serialport/
|
90
114
|
licenses:
|
91
115
|
- GPL-2
|
92
116
|
metadata: {}
|
93
|
-
post_install_message:
|
94
117
|
rdoc_options: []
|
95
118
|
require_paths:
|
96
119
|
- lib
|
@@ -98,15 +121,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
121
|
requirements:
|
99
122
|
- - ">="
|
100
123
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
124
|
+
version: '2.5'
|
102
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
126
|
requirements:
|
104
127
|
- - ">="
|
105
128
|
- !ruby/object:Gem::Version
|
106
129
|
version: '0'
|
107
130
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
-
signing_key:
|
131
|
+
rubygems_version: 3.6.2
|
110
132
|
specification_version: 4
|
111
133
|
summary: Library for using RS-232 serial ports.
|
112
134
|
test_files: []
|
metadata.gz.sig
ADDED
data/.travis.yml
DELETED
data/MANIFEST
DELETED