rubyserial 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/LICENSE +1 -1
- data/README.md +26 -2
- data/lib/rubyserial.rb +3 -2
- data/lib/rubyserial/linux_constants.rb +2 -2
- data/lib/rubyserial/osx_constants.rb +1 -1
- data/lib/rubyserial/posix.rb +13 -3
- data/lib/rubyserial/version.rb +3 -1
- data/lib/rubyserial/windows.rb +23 -11
- data/lib/rubyserial/windows_constants.rb +221 -221
- data/rubyserial.gemspec +1 -1
- data/spec/rubyserial_spec.rb +12 -2
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f04ee25b99a43446963e07bc51a82bab7fc6b2
|
4
|
+
data.tar.gz: 0df2b7cbbde4edc8f268d1b78c744ff88d608a45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 764b79276ea5b8d352dda64d5ade0f9a0b260af4c45c845c45addd8c184b760e10e0eba0cd9ab2e2648fae84264a8c050c462e4702f7a45dd72ca0993e34b8d0
|
7
|
+
data.tar.gz: 510df41b207862690ce47456763ea0a8bcfeb0ccf19b7989e7defaeb52f98ed4ed0823468854e6483b82182b3abc7060c58fe81ee99cb27cebbcd835af470267
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# rubyserial
|
2
2
|
|
3
|
-
RubySerial is a simple Ruby gem for reading from and writing to serial ports.
|
3
|
+
RubySerial is a simple Ruby gem for reading from and writing to serial ports.
|
4
4
|
|
5
5
|
Unlike other Ruby serial port implementations, it supports all of the most popular Ruby implementations (MRI, JRuby, & Rubinius) on the most popular operating systems (OSX, Linux, & Windows). And it does not require any native compilation thanks to using RubyFFI [https://github.com/ffi/ffi](https://github.com/ffi/ffi).
|
6
6
|
|
@@ -36,13 +36,37 @@ available. Emits a `RubySerial::Exception` on error.
|
|
36
36
|
|
37
37
|
**getbyte -> Fixnum or nil**
|
38
38
|
|
39
|
-
Returns an 8 bit byte or nil if no data is available.
|
39
|
+
Returns an 8 bit byte or nil if no data is available.
|
40
40
|
Emits a `RubySerial::Exception` on error.
|
41
41
|
|
42
42
|
**RubySerial::Exception**
|
43
43
|
|
44
44
|
A wrapper exception type, that returns the underlying system error code.
|
45
45
|
|
46
|
+
## Running the tests
|
47
|
+
|
48
|
+
The test suite is written using rspec, just use the `rspec` command.
|
49
|
+
|
50
|
+
However, to run the tests, you must also have the `socat` utility program installed.
|
51
|
+
|
52
|
+
### Installing socat on OS X
|
53
|
+
|
54
|
+
```
|
55
|
+
brew install socat
|
56
|
+
```
|
57
|
+
|
58
|
+
### Installing socat on Linux
|
59
|
+
|
60
|
+
```
|
61
|
+
sudo apt-get install socat
|
62
|
+
```
|
63
|
+
|
64
|
+
### Installing socat on Windows
|
65
|
+
|
66
|
+
You might need to build from source... the latest build of socat for Windows is quite old. Get source from here:
|
67
|
+
|
68
|
+
http://www.dest-unreach.org/socat/download/
|
69
|
+
|
46
70
|
## License
|
47
71
|
|
48
72
|
Apache 2.0. See `LICENSE` for more details.
|
data/lib/rubyserial.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2014-2016 The Hybrid Group
|
2
2
|
|
3
3
|
module RubySerial
|
4
4
|
module Posix
|
@@ -211,4 +211,4 @@ module RubySerial
|
|
211
211
|
attach_function :write, [:int, :pointer, :int],:int
|
212
212
|
attach_function :read, [:int, :pointer, :int],:int
|
213
213
|
end
|
214
|
-
end
|
214
|
+
end
|
data/lib/rubyserial/posix.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2014-2016 The Hybrid Group
|
2
2
|
|
3
3
|
class Serial
|
4
4
|
def initialize(address, baude_rate=9600, data_bits=8)
|
@@ -83,6 +83,18 @@ class Serial
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def gets(sep=$/, limit=nil)
|
86
|
+
if block_given?
|
87
|
+
loop do
|
88
|
+
yield(get_until_sep(sep, limit))
|
89
|
+
end
|
90
|
+
else
|
91
|
+
get_until_sep(sep, limit)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def get_until_sep(sep, limit)
|
86
98
|
sep = "\n\n" if sep == ''
|
87
99
|
# This allows the method signature to be (sep) or (limit)
|
88
100
|
(limit = sep; sep="\n") if sep.is_a? Integer
|
@@ -96,8 +108,6 @@ class Serial
|
|
96
108
|
bytes.map { |e| e.chr }.join
|
97
109
|
end
|
98
110
|
|
99
|
-
private
|
100
|
-
|
101
111
|
def build_config(baude_rate, data_bits)
|
102
112
|
config = RubySerial::Posix::Termios.new
|
103
113
|
|
data/lib/rubyserial/version.rb
CHANGED
data/lib/rubyserial/windows.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2014-2016 The Hybrid Group
|
2
2
|
|
3
3
|
class Serial
|
4
4
|
def initialize(address, baude_rate=9600, data_bits=8)
|
@@ -76,17 +76,13 @@ class Serial
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def gets(sep=$/, limit=nil)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
bytes << current_byte unless current_byte.nil?
|
86
|
-
break if (bytes.last(sep.bytes.to_a.size) == sep.bytes.to_a) || ((bytes.size == limit) if limit)
|
79
|
+
if block_given?
|
80
|
+
loop do
|
81
|
+
yield(get_until_sep(sep, limit))
|
82
|
+
end
|
83
|
+
else
|
84
|
+
get_until_sep(sep, limit)
|
87
85
|
end
|
88
|
-
|
89
|
-
bytes.map { |e| e.chr }.join
|
90
86
|
end
|
91
87
|
|
92
88
|
def close
|
@@ -101,4 +97,20 @@ class Serial
|
|
101
97
|
def closed?
|
102
98
|
!@open
|
103
99
|
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def get_until_sep(sep, limit)
|
104
|
+
sep = "\n\n" if sep == ''
|
105
|
+
# This allows the method signature to be (sep) or (limit)
|
106
|
+
(limit = sep; sep="\n") if sep.is_a? Integer
|
107
|
+
bytes = []
|
108
|
+
loop do
|
109
|
+
current_byte = getbyte
|
110
|
+
bytes << current_byte unless current_byte.nil?
|
111
|
+
break if (bytes.last(sep.bytes.to_a.size) == sep.bytes.to_a) || ((bytes.size == limit) if limit)
|
112
|
+
end
|
113
|
+
|
114
|
+
bytes.map { |e| e.chr }.join
|
115
|
+
end
|
104
116
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2014-2016 The Hybrid Group
|
2
2
|
|
3
3
|
module RubySerial
|
4
4
|
module Win32
|
@@ -11,223 +11,223 @@ module RubySerial
|
|
11
11
|
OPEN_EXISTING = 3
|
12
12
|
|
13
13
|
ERROR_CODES = {
|
14
|
-
5 => "ERROR_ACCESS_DENIED",
|
15
|
-
57 => "ERROR_ADAP_HDW_ERR",
|
16
|
-
85 => "ERROR_ALREADY_ASSIGNED",
|
17
|
-
183 => "ERROR_ALREADY_EXISTS",
|
18
|
-
7 => "ERROR_ARENA_TRASHED",
|
19
|
-
174 => "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED",
|
20
|
-
199 => "ERROR_AUTODATASEG_EXCEEDS_64k",
|
21
|
-
160 => "ERROR_BAD_ARGUMENTS",
|
22
|
-
22 => "ERROR_BAD_COMMAND",
|
23
|
-
66 => "ERROR_BAD_DEV_TYPE",
|
24
|
-
119 => "ERROR_BAD_DRIVER_LEVEL",
|
25
|
-
10 => "ERROR_BAD_ENVIRONMENT",
|
26
|
-
193 => "ERROR_BAD_EXE_FORMAT",
|
27
|
-
222 => "ERROR_BAD_FILE_TYPE",
|
28
|
-
11 => "ERROR_BAD_FORMAT",
|
29
|
-
24 => "ERROR_BAD_LENGTH",
|
30
|
-
67 => "ERROR_BAD_NET_NAME",
|
31
|
-
58 => "ERROR_BAD_NET_RESP",
|
32
|
-
53 => "ERROR_BAD_NETPATH",
|
33
|
-
161 => "ERROR_BAD_PATHNAME",
|
34
|
-
230 => "ERROR_BAD_PIPE",
|
35
|
-
60 => "ERROR_BAD_REM_ADAP",
|
36
|
-
159 => "ERROR_BAD_THREADID_ADDR",
|
37
|
-
20 => "ERROR_BAD_UNIT",
|
38
|
-
109 => "ERROR_BROKEN_PIPE",
|
39
|
-
111 => "ERROR_BUFFER_OVERFLOW",
|
40
|
-
142 => "ERROR_BUSY_DRIVE",
|
41
|
-
170 => "ERROR_BUSY",
|
42
|
-
120 => "ERROR_CALL_NOT_IMPLEMENTED",
|
43
|
-
173 => "ERROR_CANCEL_VIOLATION",
|
44
|
-
266 => "ERROR_CANNOT_COPY",
|
45
|
-
82 => "ERROR_CANNOT_MAKE",
|
46
|
-
221 => "ERROR_CHECKOUT_REQUIRED",
|
47
|
-
129 => "ERROR_CHILD_NOT_COMPLETE",
|
48
|
-
23 => "ERROR_CRC",
|
49
|
-
16 => "ERROR_CURRENT_DIRECTORY",
|
50
|
-
303 => "ERROR_DELETE_PENDING",
|
51
|
-
55 => "ERROR_DEV_NOT_EXIST",
|
52
|
-
145 => "ERROR_DIR_NOT_EMPTY",
|
53
|
-
144 => "ERROR_DIR_NOT_ROOT",
|
54
|
-
130 => "ERROR_DIRECT_ACCESS_HANDLE",
|
55
|
-
267 => "ERROR_DIRECTORY",
|
56
|
-
157 => "ERROR_DISCARDED",
|
57
|
-
107 => "ERROR_DISK_CHANGE",
|
58
|
-
112 => "ERROR_DISK_FULL",
|
59
|
-
302 => "ERROR_DISK_TOO_FRAGMENTED",
|
60
|
-
108 => "ERROR_DRIVE_LOCKED",
|
61
|
-
52 => "ERROR_DUP_NAME",
|
62
|
-
196 => "ERROR_DYNLINK_FROM_INVALID_RING",
|
63
|
-
276 => "ERROR_EA_FILE_CORRUPT",
|
64
|
-
255 => "ERROR_EA_LIST_INCONSISTENT",
|
65
|
-
277 => "ERROR_EA_TABLE_FULL",
|
66
|
-
275 => "ERROR_EAS_DIDNT_FIT",
|
67
|
-
282 => "ERROR_EAS_NOT_SUPPORTED",
|
68
|
-
203 => "ERROR_ENVVAR_NOT_FOUND",
|
69
|
-
101 => "ERROR_EXCL_SEM_ALREADY_OWNED",
|
70
|
-
217 => "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY",
|
71
|
-
218 => "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY",
|
72
|
-
216 => "ERROR_EXE_MACHINE_TYPE_MISMATCH",
|
73
|
-
192 => "ERROR_EXE_MARKED_INVALID",
|
74
|
-
83 => "ERROR_FAIL_I24",
|
75
|
-
350 => "ERROR_FAIL_NOACTION_REBOOT",
|
76
|
-
352 => "ERROR_FAIL_RESTART",
|
77
|
-
351 => "ERROR_FAIL_SHUTDOWN",
|
78
|
-
220 => "ERROR_FILE_CHECKED_OUT",
|
79
|
-
80 => "ERROR_FILE_EXISTS",
|
80
|
-
2 => "ERROR_FILE_NOT_FOUND",
|
81
|
-
223 => "ERROR_FILE_TOO_LARGE",
|
82
|
-
206 => "ERROR_FILENAME_EXCED_RANGE",
|
83
|
-
224 => "ERROR_FORMS_AUTH_REQUIRED",
|
84
|
-
31 => "ERROR_GEN_FAILURE",
|
85
|
-
39 => "ERROR_HANDLE_DISK_FULL",
|
86
|
-
38 => "ERROR_HANDLE_EOF",
|
87
|
-
308 => "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT",
|
88
|
-
304 => "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING",
|
89
|
-
202 => "ERROR_INFLOOP_IN_RELOC_CHAIN",
|
90
|
-
122 => "ERROR_INSUFFICIENT_BUFFER",
|
91
|
-
12 => "ERROR_INVALID_ACCESS",
|
92
|
-
487 => "ERROR_INVALID_ADDRESS",
|
93
|
-
104 => "ERROR_INVALID_AT_INTERRUPT_TIME",
|
94
|
-
9 => "ERROR_INVALID_BLOCK",
|
95
|
-
117 => "ERROR_INVALID_CATEGORY",
|
96
|
-
13 => "ERROR_INVALID_DATA",
|
97
|
-
15 => "ERROR_INVALID_DRIVE",
|
98
|
-
278 => "ERROR_INVALID_EA_HANDLE",
|
99
|
-
254 => "ERROR_INVALID_EA_NAME",
|
100
|
-
151 => "ERROR_INVALID_EVENT_COUNT",
|
101
|
-
191 => "ERROR_INVALID_EXE_SIGNATURE",
|
102
|
-
186 => "ERROR_INVALID_FLAG_NUMBER",
|
103
|
-
1 => "ERROR_INVALID_FUNCTION",
|
104
|
-
6 => "ERROR_INVALID_HANDLE",
|
105
|
-
124 => "ERROR_INVALID_LEVEL",
|
106
|
-
153 => "ERROR_INVALID_LIST_FORMAT",
|
107
|
-
307 => "ERROR_INVALID_LOCK_RANGE",
|
108
|
-
195 => "ERROR_INVALID_MINALLOCSIZE",
|
109
|
-
190 => "ERROR_INVALID_MODULETYPE",
|
110
|
-
123 => "ERROR_INVALID_NAME",
|
111
|
-
301 => "ERROR_INVALID_OPLOCK_PROTOCOL",
|
112
|
-
182 => "ERROR_INVALID_ORDINAL",
|
113
|
-
87 => "ERROR_INVALID_PARAMETER",
|
114
|
-
86 => "ERROR_INVALID_PASSWORD",
|
115
|
-
198 => "ERROR_INVALID_SEGDPL",
|
116
|
-
180 => "ERROR_INVALID_SEGMENT_NUMBER",
|
117
|
-
209 => "ERROR_INVALID_SIGNAL_NUMBER",
|
118
|
-
189 => "ERROR_INVALID_STACKSEG",
|
119
|
-
188 => "ERROR_INVALID_STARTING_CODESEG",
|
120
|
-
114 => "ERROR_INVALID_TARGET_HANDLE",
|
121
|
-
118 => "ERROR_INVALID_VERIFY_SWITCH",
|
122
|
-
197 => "ERROR_IOPL_NOT_ENABLED",
|
123
|
-
147 => "ERROR_IS_JOIN_PATH",
|
124
|
-
133 => "ERROR_IS_JOIN_TARGET",
|
125
|
-
134 => "ERROR_IS_JOINED",
|
126
|
-
146 => "ERROR_IS_SUBST_PATH",
|
127
|
-
149 => "ERROR_IS_SUBST_TARGET",
|
128
|
-
135 => "ERROR_IS_SUBSTED",
|
129
|
-
194 => "ERROR_ITERATED_DATA_EXCEEDS_64k",
|
130
|
-
138 => "ERROR_JOIN_TO_JOIN",
|
131
|
-
140 => "ERROR_JOIN_TO_SUBST",
|
132
|
-
154 => "ERROR_LABEL_TOO_LONG",
|
133
|
-
167 => "ERROR_LOCK_FAILED",
|
134
|
-
33 => "ERROR_LOCK_VIOLATION",
|
135
|
-
212 => "ERROR_LOCKED",
|
136
|
-
353 => "ERROR_MAX_SESSIONS_REACHED",
|
137
|
-
164 => "ERROR_MAX_THRDS_REACHED",
|
138
|
-
208 => "ERROR_META_EXPANSION_TOO_LONG",
|
139
|
-
126 => "ERROR_MOD_NOT_FOUND",
|
140
|
-
234 => "ERROR_MORE_DATA",
|
141
|
-
317 => "ERROR_MR_MID_NOT_FOUND",
|
142
|
-
131 => "ERROR_NEGATIVE_SEEK",
|
143
|
-
215 => "ERROR_NESTING_NOT_ALLOWED",
|
144
|
-
88 => "ERROR_NET_WRITE_FAULT",
|
145
|
-
64 => "ERROR_NETNAME_DELETED",
|
146
|
-
65 => "ERROR_NETWORK_ACCESS_DENIED",
|
147
|
-
54 => "ERROR_NETWORK_BUSY",
|
148
|
-
232 => "ERROR_NO_DATA",
|
149
|
-
18 => "ERROR_NO_MORE_FILES",
|
150
|
-
259 => "ERROR_NO_MORE_ITEMS",
|
151
|
-
113 => "ERROR_NO_MORE_SEARCH_HANDLES",
|
152
|
-
89 => "ERROR_NO_PROC_SLOTS",
|
153
|
-
205 => "ERROR_NO_SIGNAL_SENT",
|
154
|
-
62 => "ERROR_NO_SPOOL_SPACE",
|
155
|
-
125 => "ERROR_NO_VOLUME_LABEL",
|
156
|
-
26 => "ERROR_NOT_DOS_DISK",
|
157
|
-
8 => "ERROR_NOT_ENOUGH_MEMORY",
|
158
|
-
136 => "ERROR_NOT_JOINED",
|
159
|
-
158 => "ERROR_NOT_LOCKED",
|
160
|
-
288 => "ERROR_NOT_OWNER",
|
161
|
-
21 => "ERROR_NOT_READY",
|
162
|
-
17 => "ERROR_NOT_SAME_DEVICE",
|
163
|
-
137 => "ERROR_NOT_SUBSTED",
|
164
|
-
50 => "ERROR_NOT_SUPPORTED",
|
165
|
-
309 => "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED",
|
166
|
-
110 => "ERROR_OPEN_FAILED",
|
167
|
-
300 => "ERROR_OPLOCK_NOT_GRANTED",
|
168
|
-
28 => "ERROR_OUT_OF_PAPER",
|
169
|
-
84 => "ERROR_OUT_OF_STRUCTURES",
|
170
|
-
14 => "ERROR_OUTOFMEMORY",
|
171
|
-
299 => "ERROR_PARTIAL_COPY",
|
172
|
-
148 => "ERROR_PATH_BUSY",
|
173
|
-
3 => "ERROR_PATH_NOT_FOUND",
|
174
|
-
231 => "ERROR_PIPE_BUSY",
|
175
|
-
229 => "ERROR_PIPE_LOCAL",
|
176
|
-
233 => "ERROR_PIPE_NOT_CONNECTED",
|
177
|
-
63 => "ERROR_PRINT_CANCELLED",
|
178
|
-
61 => "ERROR_PRINTQ_FULL",
|
179
|
-
127 => "ERROR_PROC_NOT_FOUND",
|
180
|
-
402 => "ERROR_PROCESS_MODE_ALREADY_BACKGROUND",
|
181
|
-
403 => "ERROR_PROCESS_MODE_NOT_BACKGROUND",
|
182
|
-
30 => "ERROR_READ_FAULT",
|
183
|
-
72 => "ERROR_REDIR_PAUSED",
|
184
|
-
201 => "ERROR_RELOC_CHAIN_XEEDS_SEGLIM",
|
185
|
-
51 => "ERROR_REM_NOT_LIST",
|
186
|
-
71 => "ERROR_REQ_NOT_ACCEP",
|
187
|
-
207 => "ERROR_RING2_STACK_IN_USE",
|
188
|
-
200 => "ERROR_RING2SEG_MUST_BE_MOVABLE",
|
189
|
-
143 => "ERROR_SAME_DRIVE",
|
190
|
-
318 => "ERROR_SCOPE_NOT_FOUND",
|
191
|
-
27 => "ERROR_SECTOR_NOT_FOUND",
|
192
|
-
306 => "ERROR_SECURITY_STREAM_IS_INCONSISTENT",
|
193
|
-
132 => "ERROR_SEEK_ON_DEVICE",
|
194
|
-
25 => "ERROR_SEEK",
|
195
|
-
102 => "ERROR_SEM_IS_SET",
|
196
|
-
187 => "ERROR_SEM_NOT_FOUND",
|
197
|
-
105 => "ERROR_SEM_OWNER_DIED",
|
198
|
-
121 => "ERROR_SEM_TIMEOUT",
|
199
|
-
106 => "ERROR_SEM_USER_LIMIT",
|
200
|
-
36 => "ERROR_SHARING_BUFFER_EXCEEDED",
|
201
|
-
70 => "ERROR_SHARING_PAUSED",
|
202
|
-
32 => "ERROR_SHARING_VIOLATION",
|
203
|
-
305 => "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME",
|
204
|
-
162 => "ERROR_SIGNAL_PENDING",
|
205
|
-
156 => "ERROR_SIGNAL_REFUSED",
|
206
|
-
141 => "ERROR_SUBST_TO_JOIN",
|
207
|
-
139 => "ERROR_SUBST_TO_SUBST",
|
208
|
-
0 => "ERROR_SUCCESS",
|
209
|
-
150 => "ERROR_SYSTEM_TRACE",
|
210
|
-
210 => "ERROR_THREAD_1_INACTIVE",
|
211
|
-
400 => "ERROR_THREAD_MODE_ALREADY_BACKGROUND",
|
212
|
-
401 => "ERROR_THREAD_MODE_NOT_BACKGROUND",
|
213
|
-
56 => "ERROR_TOO_MANY_CMDS",
|
214
|
-
214 => "ERROR_TOO_MANY_MODULES",
|
215
|
-
152 => "ERROR_TOO_MANY_MUXWAITERS",
|
216
|
-
68 => "ERROR_TOO_MANY_NAMES",
|
217
|
-
4 => "ERROR_TOO_MANY_OPEN_FILES",
|
218
|
-
298 => "ERROR_TOO_MANY_POSTS",
|
219
|
-
103 => "ERROR_TOO_MANY_SEM_REQUESTS",
|
220
|
-
100 => "ERROR_TOO_MANY_SEMAPHORES",
|
221
|
-
69 => "ERROR_TOO_MANY_SESS",
|
222
|
-
155 => "ERROR_TOO_MANY_TCBS",
|
223
|
-
59 => "ERROR_UNEXP_NET_ERR",
|
224
|
-
240 => "ERROR_VC_DISCONNECTED",
|
225
|
-
226 => "ERROR_VIRUS_DELETED",
|
226
|
-
225 => "ERROR_VIRUS_INFECTED",
|
227
|
-
128 => "ERROR_WAIT_NO_CHILDREN",
|
228
|
-
29 => "ERROR_WRITE_FAULT",
|
229
|
-
19 => "ERROR_WRITE_PROTECT",
|
230
|
-
34 => "ERROR_WRONG_DISK",
|
14
|
+
5 => "ERROR_ACCESS_DENIED",
|
15
|
+
57 => "ERROR_ADAP_HDW_ERR",
|
16
|
+
85 => "ERROR_ALREADY_ASSIGNED",
|
17
|
+
183 => "ERROR_ALREADY_EXISTS",
|
18
|
+
7 => "ERROR_ARENA_TRASHED",
|
19
|
+
174 => "ERROR_ATOMIC_LOCKS_NOT_SUPPORTED",
|
20
|
+
199 => "ERROR_AUTODATASEG_EXCEEDS_64k",
|
21
|
+
160 => "ERROR_BAD_ARGUMENTS",
|
22
|
+
22 => "ERROR_BAD_COMMAND",
|
23
|
+
66 => "ERROR_BAD_DEV_TYPE",
|
24
|
+
119 => "ERROR_BAD_DRIVER_LEVEL",
|
25
|
+
10 => "ERROR_BAD_ENVIRONMENT",
|
26
|
+
193 => "ERROR_BAD_EXE_FORMAT",
|
27
|
+
222 => "ERROR_BAD_FILE_TYPE",
|
28
|
+
11 => "ERROR_BAD_FORMAT",
|
29
|
+
24 => "ERROR_BAD_LENGTH",
|
30
|
+
67 => "ERROR_BAD_NET_NAME",
|
31
|
+
58 => "ERROR_BAD_NET_RESP",
|
32
|
+
53 => "ERROR_BAD_NETPATH",
|
33
|
+
161 => "ERROR_BAD_PATHNAME",
|
34
|
+
230 => "ERROR_BAD_PIPE",
|
35
|
+
60 => "ERROR_BAD_REM_ADAP",
|
36
|
+
159 => "ERROR_BAD_THREADID_ADDR",
|
37
|
+
20 => "ERROR_BAD_UNIT",
|
38
|
+
109 => "ERROR_BROKEN_PIPE",
|
39
|
+
111 => "ERROR_BUFFER_OVERFLOW",
|
40
|
+
142 => "ERROR_BUSY_DRIVE",
|
41
|
+
170 => "ERROR_BUSY",
|
42
|
+
120 => "ERROR_CALL_NOT_IMPLEMENTED",
|
43
|
+
173 => "ERROR_CANCEL_VIOLATION",
|
44
|
+
266 => "ERROR_CANNOT_COPY",
|
45
|
+
82 => "ERROR_CANNOT_MAKE",
|
46
|
+
221 => "ERROR_CHECKOUT_REQUIRED",
|
47
|
+
129 => "ERROR_CHILD_NOT_COMPLETE",
|
48
|
+
23 => "ERROR_CRC",
|
49
|
+
16 => "ERROR_CURRENT_DIRECTORY",
|
50
|
+
303 => "ERROR_DELETE_PENDING",
|
51
|
+
55 => "ERROR_DEV_NOT_EXIST",
|
52
|
+
145 => "ERROR_DIR_NOT_EMPTY",
|
53
|
+
144 => "ERROR_DIR_NOT_ROOT",
|
54
|
+
130 => "ERROR_DIRECT_ACCESS_HANDLE",
|
55
|
+
267 => "ERROR_DIRECTORY",
|
56
|
+
157 => "ERROR_DISCARDED",
|
57
|
+
107 => "ERROR_DISK_CHANGE",
|
58
|
+
112 => "ERROR_DISK_FULL",
|
59
|
+
302 => "ERROR_DISK_TOO_FRAGMENTED",
|
60
|
+
108 => "ERROR_DRIVE_LOCKED",
|
61
|
+
52 => "ERROR_DUP_NAME",
|
62
|
+
196 => "ERROR_DYNLINK_FROM_INVALID_RING",
|
63
|
+
276 => "ERROR_EA_FILE_CORRUPT",
|
64
|
+
255 => "ERROR_EA_LIST_INCONSISTENT",
|
65
|
+
277 => "ERROR_EA_TABLE_FULL",
|
66
|
+
275 => "ERROR_EAS_DIDNT_FIT",
|
67
|
+
282 => "ERROR_EAS_NOT_SUPPORTED",
|
68
|
+
203 => "ERROR_ENVVAR_NOT_FOUND",
|
69
|
+
101 => "ERROR_EXCL_SEM_ALREADY_OWNED",
|
70
|
+
217 => "ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY",
|
71
|
+
218 => "ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY",
|
72
|
+
216 => "ERROR_EXE_MACHINE_TYPE_MISMATCH",
|
73
|
+
192 => "ERROR_EXE_MARKED_INVALID",
|
74
|
+
83 => "ERROR_FAIL_I24",
|
75
|
+
350 => "ERROR_FAIL_NOACTION_REBOOT",
|
76
|
+
352 => "ERROR_FAIL_RESTART",
|
77
|
+
351 => "ERROR_FAIL_SHUTDOWN",
|
78
|
+
220 => "ERROR_FILE_CHECKED_OUT",
|
79
|
+
80 => "ERROR_FILE_EXISTS",
|
80
|
+
2 => "ERROR_FILE_NOT_FOUND",
|
81
|
+
223 => "ERROR_FILE_TOO_LARGE",
|
82
|
+
206 => "ERROR_FILENAME_EXCED_RANGE",
|
83
|
+
224 => "ERROR_FORMS_AUTH_REQUIRED",
|
84
|
+
31 => "ERROR_GEN_FAILURE",
|
85
|
+
39 => "ERROR_HANDLE_DISK_FULL",
|
86
|
+
38 => "ERROR_HANDLE_EOF",
|
87
|
+
308 => "ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT",
|
88
|
+
304 => "ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING",
|
89
|
+
202 => "ERROR_INFLOOP_IN_RELOC_CHAIN",
|
90
|
+
122 => "ERROR_INSUFFICIENT_BUFFER",
|
91
|
+
12 => "ERROR_INVALID_ACCESS",
|
92
|
+
487 => "ERROR_INVALID_ADDRESS",
|
93
|
+
104 => "ERROR_INVALID_AT_INTERRUPT_TIME",
|
94
|
+
9 => "ERROR_INVALID_BLOCK",
|
95
|
+
117 => "ERROR_INVALID_CATEGORY",
|
96
|
+
13 => "ERROR_INVALID_DATA",
|
97
|
+
15 => "ERROR_INVALID_DRIVE",
|
98
|
+
278 => "ERROR_INVALID_EA_HANDLE",
|
99
|
+
254 => "ERROR_INVALID_EA_NAME",
|
100
|
+
151 => "ERROR_INVALID_EVENT_COUNT",
|
101
|
+
191 => "ERROR_INVALID_EXE_SIGNATURE",
|
102
|
+
186 => "ERROR_INVALID_FLAG_NUMBER",
|
103
|
+
1 => "ERROR_INVALID_FUNCTION",
|
104
|
+
6 => "ERROR_INVALID_HANDLE",
|
105
|
+
124 => "ERROR_INVALID_LEVEL",
|
106
|
+
153 => "ERROR_INVALID_LIST_FORMAT",
|
107
|
+
307 => "ERROR_INVALID_LOCK_RANGE",
|
108
|
+
195 => "ERROR_INVALID_MINALLOCSIZE",
|
109
|
+
190 => "ERROR_INVALID_MODULETYPE",
|
110
|
+
123 => "ERROR_INVALID_NAME",
|
111
|
+
301 => "ERROR_INVALID_OPLOCK_PROTOCOL",
|
112
|
+
182 => "ERROR_INVALID_ORDINAL",
|
113
|
+
87 => "ERROR_INVALID_PARAMETER",
|
114
|
+
86 => "ERROR_INVALID_PASSWORD",
|
115
|
+
198 => "ERROR_INVALID_SEGDPL",
|
116
|
+
180 => "ERROR_INVALID_SEGMENT_NUMBER",
|
117
|
+
209 => "ERROR_INVALID_SIGNAL_NUMBER",
|
118
|
+
189 => "ERROR_INVALID_STACKSEG",
|
119
|
+
188 => "ERROR_INVALID_STARTING_CODESEG",
|
120
|
+
114 => "ERROR_INVALID_TARGET_HANDLE",
|
121
|
+
118 => "ERROR_INVALID_VERIFY_SWITCH",
|
122
|
+
197 => "ERROR_IOPL_NOT_ENABLED",
|
123
|
+
147 => "ERROR_IS_JOIN_PATH",
|
124
|
+
133 => "ERROR_IS_JOIN_TARGET",
|
125
|
+
134 => "ERROR_IS_JOINED",
|
126
|
+
146 => "ERROR_IS_SUBST_PATH",
|
127
|
+
149 => "ERROR_IS_SUBST_TARGET",
|
128
|
+
135 => "ERROR_IS_SUBSTED",
|
129
|
+
194 => "ERROR_ITERATED_DATA_EXCEEDS_64k",
|
130
|
+
138 => "ERROR_JOIN_TO_JOIN",
|
131
|
+
140 => "ERROR_JOIN_TO_SUBST",
|
132
|
+
154 => "ERROR_LABEL_TOO_LONG",
|
133
|
+
167 => "ERROR_LOCK_FAILED",
|
134
|
+
33 => "ERROR_LOCK_VIOLATION",
|
135
|
+
212 => "ERROR_LOCKED",
|
136
|
+
353 => "ERROR_MAX_SESSIONS_REACHED",
|
137
|
+
164 => "ERROR_MAX_THRDS_REACHED",
|
138
|
+
208 => "ERROR_META_EXPANSION_TOO_LONG",
|
139
|
+
126 => "ERROR_MOD_NOT_FOUND",
|
140
|
+
234 => "ERROR_MORE_DATA",
|
141
|
+
317 => "ERROR_MR_MID_NOT_FOUND",
|
142
|
+
131 => "ERROR_NEGATIVE_SEEK",
|
143
|
+
215 => "ERROR_NESTING_NOT_ALLOWED",
|
144
|
+
88 => "ERROR_NET_WRITE_FAULT",
|
145
|
+
64 => "ERROR_NETNAME_DELETED",
|
146
|
+
65 => "ERROR_NETWORK_ACCESS_DENIED",
|
147
|
+
54 => "ERROR_NETWORK_BUSY",
|
148
|
+
232 => "ERROR_NO_DATA",
|
149
|
+
18 => "ERROR_NO_MORE_FILES",
|
150
|
+
259 => "ERROR_NO_MORE_ITEMS",
|
151
|
+
113 => "ERROR_NO_MORE_SEARCH_HANDLES",
|
152
|
+
89 => "ERROR_NO_PROC_SLOTS",
|
153
|
+
205 => "ERROR_NO_SIGNAL_SENT",
|
154
|
+
62 => "ERROR_NO_SPOOL_SPACE",
|
155
|
+
125 => "ERROR_NO_VOLUME_LABEL",
|
156
|
+
26 => "ERROR_NOT_DOS_DISK",
|
157
|
+
8 => "ERROR_NOT_ENOUGH_MEMORY",
|
158
|
+
136 => "ERROR_NOT_JOINED",
|
159
|
+
158 => "ERROR_NOT_LOCKED",
|
160
|
+
288 => "ERROR_NOT_OWNER",
|
161
|
+
21 => "ERROR_NOT_READY",
|
162
|
+
17 => "ERROR_NOT_SAME_DEVICE",
|
163
|
+
137 => "ERROR_NOT_SUBSTED",
|
164
|
+
50 => "ERROR_NOT_SUPPORTED",
|
165
|
+
309 => "ERROR_NOTIFICATION_GUID_ALREADY_DEFINED",
|
166
|
+
110 => "ERROR_OPEN_FAILED",
|
167
|
+
300 => "ERROR_OPLOCK_NOT_GRANTED",
|
168
|
+
28 => "ERROR_OUT_OF_PAPER",
|
169
|
+
84 => "ERROR_OUT_OF_STRUCTURES",
|
170
|
+
14 => "ERROR_OUTOFMEMORY",
|
171
|
+
299 => "ERROR_PARTIAL_COPY",
|
172
|
+
148 => "ERROR_PATH_BUSY",
|
173
|
+
3 => "ERROR_PATH_NOT_FOUND",
|
174
|
+
231 => "ERROR_PIPE_BUSY",
|
175
|
+
229 => "ERROR_PIPE_LOCAL",
|
176
|
+
233 => "ERROR_PIPE_NOT_CONNECTED",
|
177
|
+
63 => "ERROR_PRINT_CANCELLED",
|
178
|
+
61 => "ERROR_PRINTQ_FULL",
|
179
|
+
127 => "ERROR_PROC_NOT_FOUND",
|
180
|
+
402 => "ERROR_PROCESS_MODE_ALREADY_BACKGROUND",
|
181
|
+
403 => "ERROR_PROCESS_MODE_NOT_BACKGROUND",
|
182
|
+
30 => "ERROR_READ_FAULT",
|
183
|
+
72 => "ERROR_REDIR_PAUSED",
|
184
|
+
201 => "ERROR_RELOC_CHAIN_XEEDS_SEGLIM",
|
185
|
+
51 => "ERROR_REM_NOT_LIST",
|
186
|
+
71 => "ERROR_REQ_NOT_ACCEP",
|
187
|
+
207 => "ERROR_RING2_STACK_IN_USE",
|
188
|
+
200 => "ERROR_RING2SEG_MUST_BE_MOVABLE",
|
189
|
+
143 => "ERROR_SAME_DRIVE",
|
190
|
+
318 => "ERROR_SCOPE_NOT_FOUND",
|
191
|
+
27 => "ERROR_SECTOR_NOT_FOUND",
|
192
|
+
306 => "ERROR_SECURITY_STREAM_IS_INCONSISTENT",
|
193
|
+
132 => "ERROR_SEEK_ON_DEVICE",
|
194
|
+
25 => "ERROR_SEEK",
|
195
|
+
102 => "ERROR_SEM_IS_SET",
|
196
|
+
187 => "ERROR_SEM_NOT_FOUND",
|
197
|
+
105 => "ERROR_SEM_OWNER_DIED",
|
198
|
+
121 => "ERROR_SEM_TIMEOUT",
|
199
|
+
106 => "ERROR_SEM_USER_LIMIT",
|
200
|
+
36 => "ERROR_SHARING_BUFFER_EXCEEDED",
|
201
|
+
70 => "ERROR_SHARING_PAUSED",
|
202
|
+
32 => "ERROR_SHARING_VIOLATION",
|
203
|
+
305 => "ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME",
|
204
|
+
162 => "ERROR_SIGNAL_PENDING",
|
205
|
+
156 => "ERROR_SIGNAL_REFUSED",
|
206
|
+
141 => "ERROR_SUBST_TO_JOIN",
|
207
|
+
139 => "ERROR_SUBST_TO_SUBST",
|
208
|
+
0 => "ERROR_SUCCESS",
|
209
|
+
150 => "ERROR_SYSTEM_TRACE",
|
210
|
+
210 => "ERROR_THREAD_1_INACTIVE",
|
211
|
+
400 => "ERROR_THREAD_MODE_ALREADY_BACKGROUND",
|
212
|
+
401 => "ERROR_THREAD_MODE_NOT_BACKGROUND",
|
213
|
+
56 => "ERROR_TOO_MANY_CMDS",
|
214
|
+
214 => "ERROR_TOO_MANY_MODULES",
|
215
|
+
152 => "ERROR_TOO_MANY_MUXWAITERS",
|
216
|
+
68 => "ERROR_TOO_MANY_NAMES",
|
217
|
+
4 => "ERROR_TOO_MANY_OPEN_FILES",
|
218
|
+
298 => "ERROR_TOO_MANY_POSTS",
|
219
|
+
103 => "ERROR_TOO_MANY_SEM_REQUESTS",
|
220
|
+
100 => "ERROR_TOO_MANY_SEMAPHORES",
|
221
|
+
69 => "ERROR_TOO_MANY_SESS",
|
222
|
+
155 => "ERROR_TOO_MANY_TCBS",
|
223
|
+
59 => "ERROR_UNEXP_NET_ERR",
|
224
|
+
240 => "ERROR_VC_DISCONNECTED",
|
225
|
+
226 => "ERROR_VIRUS_DELETED",
|
226
|
+
225 => "ERROR_VIRUS_INFECTED",
|
227
|
+
128 => "ERROR_WAIT_NO_CHILDREN",
|
228
|
+
29 => "ERROR_WRITE_FAULT",
|
229
|
+
19 => "ERROR_WRITE_PROTECT",
|
230
|
+
34 => "ERROR_WRONG_DISK",
|
231
231
|
258 => "WAIT_TIMEOUT"
|
232
232
|
}
|
233
233
|
|
@@ -250,8 +250,8 @@ module RubySerial
|
|
250
250
|
# uint32 fRtsControl :2;
|
251
251
|
# uint32 fAbortOnError :1;
|
252
252
|
# uint32 fDummy2 :17;
|
253
|
-
Sizeof = 28
|
254
|
-
ONESTOPBIT = 0
|
253
|
+
Sizeof = 28
|
254
|
+
ONESTOPBIT = 0
|
255
255
|
NOPARITY = 0
|
256
256
|
end
|
257
257
|
|
@@ -272,4 +272,4 @@ module RubySerial
|
|
272
272
|
attach_function :GetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32
|
273
273
|
attach_function :SetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32
|
274
274
|
end
|
275
|
-
end
|
275
|
+
end
|
data/rubyserial.gemspec
CHANGED
data/spec/rubyserial_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe "rubyserial" do
|
|
5
5
|
@ports = []
|
6
6
|
require 'rbconfig'
|
7
7
|
if RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
|
8
|
-
# NOTE: Tests on windows require com0com
|
8
|
+
# NOTE: Tests on windows require com0com
|
9
9
|
# https://github.com/hybridgroup/rubyserial/raw/appveyor_deps/setup_com0com_W7_x64_signed.exe
|
10
10
|
@ports[0] = "\\\\.\\CNCA0"
|
11
11
|
@ports[1] = "\\\\.\\CNCB0"
|
@@ -84,7 +84,6 @@ describe "rubyserial" do
|
|
84
84
|
expect([check].pack('C')).to eql('h')
|
85
85
|
end
|
86
86
|
|
87
|
-
|
88
87
|
describe "giving me lines" do
|
89
88
|
it "should give me a line" do
|
90
89
|
@sp.write("no yes \n hello")
|
@@ -92,6 +91,17 @@ describe "rubyserial" do
|
|
92
91
|
expect(@sp2.gets).to eql("no yes \n")
|
93
92
|
end
|
94
93
|
|
94
|
+
it "should give me a line with block" do
|
95
|
+
@sp.write("no yes \n hello")
|
96
|
+
sleep 0.1
|
97
|
+
result = ""
|
98
|
+
@sp2.gets do |line|
|
99
|
+
result = line
|
100
|
+
break if !result.empty?
|
101
|
+
end
|
102
|
+
expect(result).to eql("no yes \n")
|
103
|
+
end
|
104
|
+
|
95
105
|
it "should accept a sep param" do
|
96
106
|
@sp.write('no yes END bleh')
|
97
107
|
sleep 0.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyserial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Zankich
|
@@ -10,13 +10,16 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ffi
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.9'
|
22
|
+
- - ">="
|
20
23
|
- !ruby/object:Gem::Version
|
21
24
|
version: 1.9.3
|
22
25
|
type: :runtime
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
29
|
- - "~>"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '1.9'
|
32
|
+
- - ">="
|
27
33
|
- !ruby/object:Gem::Version
|
28
34
|
version: 1.9.3
|
29
35
|
description: FFI Ruby library for RS-232 serial port communication
|
@@ -70,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
76
|
version: '0'
|
71
77
|
requirements: []
|
72
78
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.4.
|
79
|
+
rubygems_version: 2.4.8
|
74
80
|
signing_key:
|
75
81
|
specification_version: 4
|
76
82
|
summary: FFI Ruby library for RS-232 serial port communication
|