serialport 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjQyZmY0M2ZiNGMzNjAzNjBmNDRjM2FlMTAwNDA5ZmJhYzc2MWU1YQ==
4
+ NGJmNWI3ZWM5ODgyNWFmMTMzM2ViNGQ4M2VkZTAwMzkwMTRiZTViMA==
5
5
  data.tar.gz: !binary |-
6
- NmY1ZTRmNzEyOTM2ZWNiOWJjODJkZTkwYjNlMTk2NzliNmIyOWM3Mw==
6
+ OGFhNWNiZTAyMjM0NjNjZDY0MTc5NGUxNWFjMWU2OWMyM2ZiNDdmNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2U0NTJkYzM2Y2JiZGU2ODhlMjVhNDcyMTNkZTNmNTM5Yjc4ODRlMzE3ZDFj
10
- YjBlNWY0Y2ZhYjc3ZGZkMmRmZjgzZTllOWIwOGEwYzQ5N2IzN2NhMjY5YjIz
11
- MjQ0YjM0ZWRiMDU3YzdmNzkzYzE5MzBkYmVkMWE5ZTJkZDJmNjE=
9
+ YmE4Yjc3MDJmZWMwODBiMzkwZGVjMWZlNDgwZjcyNmFiMDU1NmY3MGVhNjcx
10
+ YmMyMjEyYjAxNzMzZDZmMTg5NTlkNTIxZWEzMDVlZTc1ZWFiZDRmYmEwM2Rm
11
+ YzY5ZGQzN2Q4NDI4YzMwN2QwNzI4NDcwN2JjYWRlZDFjZmZjNjI=
12
12
  data.tar.gz: !binary |-
13
- YjZhNzNlYjJiNDJiZWVjMWIwNTQzYzc5ZjNjYzRhNmE2MDA1OWY3ZTljNWU3
14
- ODIwN2QzMzA3ZjM5ZTUxMDcxNDE0YTc5ZjJlNjc0ZGZiNjFlMGJhNGVhYWFj
15
- OTE4NjVlNjkwOTFlZDM3NTQ4NDM5OTUzMDhlNTgyOTIzOGNjZWQ=
13
+ YmNhNWUwZDYzZDIzMDk3YWM5MDMxNDY4ODkxZDVmN2Q5ZmMwZTZiNWEwZTJl
14
+ MzcwNTE4YTRhOGYwNGUzNjQ5MzZmYWE4OWQ5YTdjNDUwNzE1Zjg4ZmI3Yzk0
15
+ MWJiOTE2MzkxNTJkMTVkNzNjN2ZmNmNhYjFjM2MxMTMxMDk1OTY=
data/.gitignore CHANGED
@@ -12,3 +12,4 @@ tags
12
12
  *.gem
13
13
  *.bundle
14
14
  Gemfile.lock
15
+ .yardoc
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 1.2.3 => 11/04/2013: [FIXED] Improved documentation (yard)
2
+
1
3
  1.2.2 => 11/03/2013: [FIXED] warning: already initialized constant VERSION
2
4
 
3
5
  1.2.1 => 10/25/2013: [FIXED] removed absurd circular dependency
data/MANIFEST CHANGED
@@ -1,9 +1,8 @@
1
1
  CHANGELOG
2
2
  MANIFEST
3
- README
3
+ README.md
4
4
  Rakefile
5
5
  serialport.gemspec
6
- VERSION
7
6
  ext/native/extconf.rb
8
7
  ext/native/posix_serialport_impl.c
9
8
  ext/native/serialport.c
@@ -0,0 +1,37 @@
1
+ # Ruby/SerialPort
2
+
3
+ [![Build Status](https://travis-ci.org/hparra/ruby-serialport.png?branch=v1.2.2)](https://travis-ci.org/hparra/ruby-serialport)
4
+
5
+ ## Description
6
+
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
+
9
+ The native Windows version of this library supports the Microsoft Visual C++, Borland C++, and MinGW compilers.
10
+
11
+ ## Installation
12
+
13
+ Install the gem as normal: `sudo gem install serialport`
14
+
15
+ ## Testing
16
+
17
+ Use Ruby's version of miniterm: `ruby test/miniterm.rb`
18
+
19
+ ## API
20
+
21
+ See <http://rubydoc.info/gems/serialport/SerialPort> or run `yard`
22
+
23
+ ## Issues
24
+
25
+ See <https://github.com/hparra/ruby-serialport/issues>
26
+
27
+ ## License
28
+
29
+ GPL
30
+
31
+ ## Authors
32
+
33
+ * Guillaume Pierronnet <moumar@netcourrier.com>
34
+ * Alan Stern <stern@rowland.harvard.edu>
35
+ * Tobin Richard <tobin.richard@gmail.com>
36
+ * Hector Parra <hector@hectorparra.com>
37
+ * Ryan C. Payne <rpayne-oss@bullittsystems.com>
@@ -11,11 +11,6 @@
11
11
  * You should have received a copy of the GNU General Public License
12
12
  * along with this program; if not, write to the Free Software
13
13
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14
- *
15
- * For documentation on serial programming, see the excellent:
16
- * "Serial Programming Guide for POSIX Operating Systems"
17
- * written Michael R. Sweet.
18
- * http://www.easysw.com/~mike/serial/
19
14
  */
20
15
 
21
16
  #include "serialport.h"
@@ -26,7 +21,10 @@ VALUE sBaud, sDataBits, sStopBits, sParity; /* strings */
26
21
  VALUE sRts, sDtr, sCts, sDsr, sDcd, sRi;
27
22
 
28
23
  /*
29
- * :nodoc: This method is private and will be called by SerialPort#new or SerialPort#open.
24
+ * @api private
25
+ *
26
+ * @see SerialPort#new
27
+ * @see SerialPort#open
30
28
  */
31
29
  static VALUE sp_create(class, _port)
32
30
  VALUE class, _port;
@@ -40,16 +38,26 @@ static VALUE sp_create(class, _port)
40
38
  * an ArgumentError.
41
39
  *
42
40
  * When using a hash the following keys are recognized:
43
- * ["baud"] Integer from 50 to 256000, depends on platform
41
+ * ["baud"] Integer from 50 to 256000, depending on platform
44
42
  * ["data_bits"] Integer from 5 to 8 (4 is allowed on Windows too)
45
- * ["stop_bits"] An integer, only allowed values are 1 or 2 (1.5 is not supported)
43
+ * ["stop_bits"] Integer, only allowed values are 1 or 2 (1.5 is not supported)
46
44
  * ["parity"] One of the constants NONE, EVEN or ODD (Windows allows also MARK and SPACE)
47
45
  *
48
46
  * When using separate arguments, they are interpreted as:
49
- * (baud, data_bits = 8, stop_bits = 1, parity = (previous_databits==8 ? NONE : EVEN))
47
+ * (baud, data_bits = 8, stop_bits = 1, parity = (previous_databits == 8 ? NONE : EVEN))
48
+ * A baudrate of nil will keep the old value.
49
+ * The default parity depends on the number of databits configured before this function call.
50
+ *
51
+ * @overload set_modem_params(baud, data_bits, stop_bits, parity)
52
+ * @param baud [Integer] the baud rate
53
+ * @param data_bits [Integer] the number of data bits
54
+ * @param stop_bits [Integer] the number of stop bits
55
+ * @param parity [Integer] the type of parity checking
56
+ * @overload set_modem_params(hash)
57
+ * @param opts [Hash] the options to configure port
50
58
  *
51
- * Nota: A baudrate of nil will keep the old value. The default parity depends on the
52
- * number of databits configured before this function call.
59
+ * @return [Hash] the original paramters
60
+ * @raise [ArgumentError] if values are invalide or unsupported
53
61
  */
54
62
  static VALUE sp_set_modem_params(argc, argv, self)
55
63
  int argc;
@@ -59,11 +67,11 @@ static VALUE sp_set_modem_params(argc, argv, self)
59
67
  }
60
68
 
61
69
  /*
62
- * Send a break for the given time.
70
+ * Send a break for the given time
63
71
  *
64
- * <tt>time</tt> is an integer of tenths-of-a-second for the break.
65
- *
66
- * Note: Under Posix, this value is very approximate.
72
+ * @param time [Integer] break time in tenths-of-a-second
73
+ * @return [nil]
74
+ * @note (POSIX) this value is very approximate
67
75
  */
68
76
  static VALUE sp_break(self, time)
69
77
  VALUE self, time;
@@ -72,7 +80,10 @@ static VALUE sp_break(self, time)
72
80
  }
73
81
 
74
82
  /*
75
- * Get the state (0 or 1) of the DTR line (not available on Windows)
83
+ * Get the state of the DTR line
84
+ *
85
+ * @note (Windows) DTR is not available
86
+ * @return [Integer] the state of DTR line, 0 or 1
76
87
  */
77
88
  static VALUE sp_get_dtr(self)
78
89
  VALUE self;
@@ -81,7 +92,10 @@ static VALUE sp_get_dtr(self)
81
92
  }
82
93
 
83
94
  /*
84
- * Get the flow control. The result is either NONE, HARD, SOFT or (HARD | SOFT)
95
+ * Get the flow control flag
96
+ *
97
+ * @return [Integer] the flow control flag
98
+ * @see SerialPort#set_flow_control
85
99
  */
86
100
  static VALUE sp_get_flow_control(self)
87
101
  VALUE self;
@@ -90,8 +104,10 @@ static VALUE sp_get_flow_control(self)
90
104
  }
91
105
 
92
106
  /*
93
- * Get the timeout value (in milliseconds) for reading.
94
- * See SerialPort#set_read_timeout for details.
107
+ * Get the read timeout value
108
+ *
109
+ * @return [Integer] the read timeout, in milliseconds
110
+ * @see SerialPort#set_read_timeout
95
111
  */
96
112
  static VALUE sp_get_read_timeout(self)
97
113
  VALUE self;
@@ -100,7 +116,10 @@ static VALUE sp_get_read_timeout(self)
100
116
  }
101
117
 
102
118
  /*
103
- * Get the state (0 or 1) of the RTS line (not available on Windows)
119
+ * Get the state of the RTS line
120
+ *
121
+ * @return [Integer] the state of RTS line, 0 or 1
122
+ * @note (Windows) RTS is not available
104
123
  */
105
124
  static VALUE sp_get_rts(self)
106
125
  VALUE self;
@@ -109,9 +128,10 @@ static VALUE sp_get_rts(self)
109
128
  }
110
129
 
111
130
  /*
112
- * Get the write timeout (in milliseconds)
131
+ * Get the write timeout
113
132
  *
114
- * Note: Under Posix, write timeouts are not implemented.
133
+ * @return [Integer] the write timeout, in milliseconds
134
+ * @note (POSIX) write timeouts are not implemented
115
135
  */
116
136
  static VALUE sp_get_write_timeout(self)
117
137
  VALUE self;
@@ -120,7 +140,10 @@ static VALUE sp_get_write_timeout(self)
120
140
  }
121
141
 
122
142
  /*
123
- * Set the state (0 or 1) of the DTR line
143
+ * Set the state of the DTR line
144
+ *
145
+ * @param val [Integer] the desired state of the DTR line, 0 or 1
146
+ * @return [Integer] the original +val+ parameter
124
147
  */
125
148
  static VALUE sp_set_dtr(self, val)
126
149
  VALUE self, val;
@@ -129,11 +152,14 @@ static VALUE sp_set_dtr(self, val)
129
152
  }
130
153
 
131
154
  /*
132
- * Set the flow control to either NONE, HARD, SOFT or (HARD | SOFT)
155
+ * Set the flow control
133
156
  *
134
- * Note: SerialPort::HARD mode is not supported on all platforms.
135
- * SerialPort::HARD uses RTS/CTS handshaking; DSR/DTR is not
136
- * supported.
157
+ * @param val [Integer] the flow control flag,
158
+ * +NONE+, +HARD+, +SOFT+, or (+HARD+ | +SOFT+)
159
+ * @return [Integer] the original +val+ parameter
160
+ * @note SerialPort::HARD mode is not supported on all platforms.
161
+ * @note SerialPort::HARD uses RTS/CTS handshaking.
162
+ * DSR/DTR is not supported.
137
163
  */
138
164
  static VALUE sp_set_flow_control(self, val)
139
165
  VALUE self, val;
@@ -149,7 +175,9 @@ static VALUE sp_set_flow_control(self, val)
149
175
  * requested number of bytes is available or the interval between the
150
176
  * arrival of two bytes exceeds the timeout value.
151
177
  *
152
- * Note: Read timeouts don't mix well with multi-threading.
178
+ * @param timeout [Integer] the read timeout in milliseconds
179
+ * @return [Integer] the original +timeout+ parameter
180
+ * @note Read timeouts don't mix well with multi-threading
153
181
  */
154
182
  static VALUE sp_set_read_timeout(self, val)
155
183
  VALUE self, val;
@@ -158,7 +186,10 @@ static VALUE sp_set_read_timeout(self, val)
158
186
  }
159
187
 
160
188
  /*
161
- * Set the state (0 or 1) of the RTS line
189
+ * Set the state of the RTS line
190
+ *
191
+ * @param val [Integer] the state of RTS line, 0 or 1
192
+ * @return [Integer] the original +val+ parameter
162
193
  */
163
194
  static VALUE sp_set_rts(self, val)
164
195
  VALUE self, val;
@@ -167,9 +198,11 @@ static VALUE sp_set_rts(self, val)
167
198
  }
168
199
 
169
200
  /*
170
- * Set a write timeout (in milliseconds)
201
+ * Set a write timeout
171
202
  *
172
- * Note: Under Posix, write timeouts are not implemented.
203
+ * @param val [Integer] the write timeout in milliseconds
204
+ * @return [Integer] the original +val+ parameter
205
+ * @note (POSIX) write timeouts are not implemented
173
206
  */
174
207
  static VALUE sp_set_write_timeout(self, val)
175
208
  VALUE self, val;
@@ -178,6 +211,7 @@ static VALUE sp_set_write_timeout(self, val)
178
211
  }
179
212
 
180
213
  /*
214
+ * @private helper
181
215
  */
182
216
  static void get_modem_params(self, mp)
183
217
  VALUE self;
@@ -187,7 +221,11 @@ static void get_modem_params(self, mp)
187
221
  }
188
222
 
189
223
  /*
190
- * Set the baud rate, see SerialPort#set_modem_params for details.
224
+ * Set the baud rate
225
+ *
226
+ * @param data_rate [Integer] the baud rate
227
+ * @return [Integer] the original +data_rate+ parameter
228
+ * @see SerialPort#set_modem_params
191
229
  */
192
230
  static VALUE sp_set_data_rate(self, data_rate)
193
231
  VALUE self, data_rate;
@@ -202,7 +240,11 @@ static VALUE sp_set_data_rate(self, data_rate)
202
240
  }
203
241
 
204
242
  /*
205
- * Set the data bits, see SerialPort#set_modem_params for details.
243
+ * Set the data bits
244
+ *
245
+ * @param data_bits [Integer] the number of data bits
246
+ * @return [Integer] the original +data_bits+ parameter
247
+ * @see SerialPort#set_modem_params
206
248
  */
207
249
  static VALUE sp_set_data_bits(self, data_bits)
208
250
  VALUE self, data_bits;
@@ -217,7 +259,11 @@ static VALUE sp_set_data_bits(self, data_bits)
217
259
  }
218
260
 
219
261
  /*
220
- * Set the stop bits, see SerialPort#set_modem_params for details.
262
+ * Set the stop bits
263
+ *
264
+ * @param stop_bits [Integer] the number of stop bits
265
+ * @return [Integer] the original +stop_bits+ parameter
266
+ * @see SerialPort#set_modem_params
221
267
  */
222
268
  static VALUE sp_set_stop_bits(self, stop_bits)
223
269
  VALUE self, stop_bits;
@@ -232,7 +278,11 @@ static VALUE sp_set_stop_bits(self, stop_bits)
232
278
  }
233
279
 
234
280
  /*
235
- * Set the parity, see SerialPort#set_modem_params for details.
281
+ * Set the parity
282
+ *
283
+ * @param parity [Integer] the parity type
284
+ * @return [Integer] the original +parity+ parameter
285
+ * @see SerialPort#set_modem_params
236
286
  */
237
287
  static VALUE sp_set_parity(self, parity)
238
288
  VALUE self, parity;
@@ -247,7 +297,10 @@ static VALUE sp_set_parity(self, parity)
247
297
  }
248
298
 
249
299
  /*
250
- * Get the current baud rate, see SerialPort#get_modem_params for details.
300
+ * Get the current baud rate
301
+ *
302
+ * @return [Integer] the current baud rate
303
+ * @see SerialPort#set_modem_params
251
304
  */
252
305
  static VALUE sp_get_data_rate(self)
253
306
  VALUE self;
@@ -260,7 +313,10 @@ static VALUE sp_get_data_rate(self)
260
313
  }
261
314
 
262
315
  /*
263
- * Get the current data bits, see SerialPort#get_modem_params for details.
316
+ * Get the current data bits
317
+ *
318
+ * @return [Integer] the current number of data bits
319
+ * @see SerialPort#set_modem_params
264
320
  */
265
321
  static VALUE sp_get_data_bits(self)
266
322
  VALUE self;
@@ -273,7 +329,10 @@ static VALUE sp_get_data_bits(self)
273
329
  }
274
330
 
275
331
  /*
276
- * Get the current stop bits, see SerialPort#get_modem_params for details.
332
+ * Get the current stop bits
333
+ *
334
+ * @return [Integer] the current number of stop bits
335
+ * @see SerialPort#set_modem_params for details
277
336
  */
278
337
  static VALUE sp_get_stop_bits(self)
279
338
  VALUE self;
@@ -286,7 +345,10 @@ static VALUE sp_get_stop_bits(self)
286
345
  }
287
346
 
288
347
  /*
289
- * Get the current parity, see SerialPort#get_modem_params for details.
348
+ * Get the current parity
349
+ *
350
+ * @return [Integer] the current parity
351
+ * @see SerialPort#set_modem_params
290
352
  */
291
353
  static VALUE sp_get_parity(self)
292
354
  VALUE self;
@@ -299,13 +361,10 @@ static VALUE sp_get_parity(self)
299
361
  }
300
362
 
301
363
  /*
302
- * Get the configure of the serial port.
364
+ * Get the configure of the serial port
303
365
  *
304
- * Returned is a hash with the following keys:
305
- * ["baud"] Integer with the baud rate
306
- * ["data_bits"] Integer from 5 to 8 (4 is possible on Windows too)
307
- * ["stop_bits"] Integer, 1 or 2 (1.5 is not supported)
308
- * ["parity"] One of the constants NONE, EVEN or ODD (on Windows may also MARK or SPACE)
366
+ * @return [Hash] the serial port configuration
367
+ * @see SerialPort#set_modem_params
309
368
  */
310
369
  static VALUE sp_get_modem_params(self)
311
370
  VALUE self;
@@ -325,6 +384,9 @@ static VALUE sp_get_modem_params(self)
325
384
  return hash;
326
385
  }
327
386
 
387
+ /*
388
+ * @api private
389
+ */
328
390
  void get_line_signals_helper(obj, ls)
329
391
  VALUE obj;
330
392
  struct line_signals *ls;
@@ -333,7 +395,10 @@ void get_line_signals_helper(obj, ls)
333
395
  }
334
396
 
335
397
  /*
336
- * Get the state (0 or 1) of the CTS line
398
+ * Get the state of the CTS line
399
+ *
400
+ * @return [Integer] the state of the CTS line, 0 or 1
401
+ * @see SerialPort#get_signals
337
402
  */
338
403
  static VALUE sp_get_cts(self)
339
404
  VALUE self;
@@ -346,7 +411,10 @@ static VALUE sp_get_cts(self)
346
411
  }
347
412
 
348
413
  /*
349
- * Get the state (0 or 1) of the DSR line
414
+ * Get the state of the DSR line
415
+ *
416
+ * @return [Integer] the state of the DSR line, 0 or 1
417
+ * @see SerialPort#get_signals
350
418
  */
351
419
  static VALUE sp_get_dsr(self)
352
420
  VALUE self;
@@ -359,7 +427,10 @@ static VALUE sp_get_dsr(self)
359
427
  }
360
428
 
361
429
  /*
362
- * Get the state (0 or 1) of the DCD line
430
+ * Get the state of the DCD line
431
+ *
432
+ * @return [Integer] the state of the DCD line, 0 or 1
433
+ * @see SerialPort#get_signals
363
434
  */
364
435
  static VALUE sp_get_dcd(self)
365
436
  VALUE self;
@@ -372,7 +443,10 @@ static VALUE sp_get_dcd(self)
372
443
  }
373
444
 
374
445
  /*
375
- * Get the state (0 or 1) of the RI line
446
+ * Get the state of the RI line
447
+ *
448
+ * @return [Integer] the state of the RI line, 0 or 1
449
+ * @see SerialPort#get_signals
376
450
  */
377
451
  static VALUE sp_get_ri(self)
378
452
  VALUE self;
@@ -385,10 +459,13 @@ static VALUE sp_get_ri(self)
385
459
  }
386
460
 
387
461
  /*
388
- * Return a hash with the state of each line status bit. Keys are
389
- * "rts", "dtr", "cts", "dsr", "dcd", and "ri".
462
+ * Return a hash with the state of each line status bit.
463
+ * Keys:
464
+ * "rts", "dtr", "cts", "dsr", "dcd", and "ri".
390
465
  *
391
- * Note: Under Windows, the rts and dtr values are not included.
466
+ * @return [Hash] the state line info
467
+ * @note (Windows) the rts and dtr values are not included
468
+ * @note This method is implemented as both SerialPort#signals and SerialPort#get_signals
392
469
  */
393
470
  static VALUE sp_signals(self)
394
471
  VALUE self;
@@ -412,11 +489,6 @@ static VALUE sp_signals(self)
412
489
  return hash;
413
490
  }
414
491
 
415
- /*
416
- * This class is used for communication over a serial port.
417
- * In addition to the methods here, you can use everything
418
- * Ruby's IO-class provides (read, write, getc, readlines, ...)
419
- */
420
492
  void Init_serialport()
421
493
  {
422
494
  sBaud = rb_str_new2("baud");
@@ -478,12 +550,38 @@ void Init_serialport()
478
550
  rb_define_method(cSerialPort, "dcd", sp_get_dcd, 0);
479
551
  rb_define_method(cSerialPort, "ri", sp_get_ri, 0);
480
552
 
553
+ /*
554
+ * 0
555
+ */
481
556
  rb_define_const(cSerialPort, "NONE", INT2FIX(NONE));
557
+
558
+ /*
559
+ * 1
560
+ */
482
561
  rb_define_const(cSerialPort, "HARD", INT2FIX(HARD));
562
+
563
+ /*
564
+ * 2
565
+ */
483
566
  rb_define_const(cSerialPort, "SOFT", INT2FIX(SOFT));
484
567
 
568
+ /*
569
+ * 0
570
+ */
485
571
  rb_define_const(cSerialPort, "SPACE", INT2FIX(SPACE));
572
+
573
+ /*
574
+ * 1
575
+ */
486
576
  rb_define_const(cSerialPort, "MARK", INT2FIX(MARK));
577
+
578
+ /*
579
+ * 2
580
+ */
487
581
  rb_define_const(cSerialPort, "EVEN", INT2FIX(EVEN));
582
+
583
+ /*
584
+ * 3
585
+ */
488
586
  rb_define_const(cSerialPort, "ODD", INT2FIX(ODD));
489
587
  }
@@ -1,18 +1,26 @@
1
1
  require 'serialport.so'
2
2
  require 'serialport/version'
3
3
 
4
+
5
+ # This class is used for communication over a serial port.
6
+ # In addition to the methods here, you can use Ruby IO methods, e.g. read, write, getc, readlines, etc.
7
+ #
8
+ # @see http://rubydoc.info/stdlib/core/IO Ruby IO class
9
+ # @see http://www.cmrr.umn.edu/~strupp/serial.html "Serial Programming Guide for POSIX Operating Systems"
4
10
  class SerialPort
5
11
  private_class_method(:create)
6
12
 
7
13
  # Creates a serial port object.
14
+ # Accepts the port identifier and a variable list for configuration as paramaters or hash.
15
+ # Please see SerialPort#set_modem_params
8
16
  #
9
- # <tt>port</tt> may be a port number
10
- # or the file name of a defice.
11
- # The number is portable; so 0 is mapped to "COM1" on Windows,
12
- # "/dev/ttyS0" on Linux, "/dev/cuaa0" on Mac OS X, etc.
13
- #
14
- # <tt>params</tt> can be used to configure the serial port.
15
- # See SerialPort#set_modem_params for details
17
+ # @overload new(port, *params)
18
+ # @param port [Integer] the serial port number,
19
+ # where 0 is mapped to "COM1" on Windows, "/dev/ttyS0" on Linux, "/dev/cuaa0" on Mac OS X, etc.
20
+ # @overload new(port, *params)
21
+ # @param port [String] the serial port file e.g. "/dev/ttyS0"
22
+ # @return [SerialPort]
23
+ # @see SerialPort#set_modem_params
16
24
  def SerialPort::new(port, *params)
17
25
  sp = create(port)
18
26
  begin
@@ -27,6 +35,10 @@ class SerialPort
27
35
  # This behaves like SerialPort#new, except that you can pass a block
28
36
  # to which the new serial port object will be passed. In this case
29
37
  # the connection is automaticaly closed when the block has finished.
38
+ #
39
+ # @yield [SerialPort] the serial port number or filename
40
+ # @see SerialPort#new
41
+ # @see SerialPort#set_modem_params
30
42
  def SerialPort::open(port, *params)
31
43
  sp = create(port)
32
44
  begin
@@ -1,3 +1,3 @@
1
1
  class SerialPort
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
@@ -3,6 +3,7 @@ require File.expand_path('../lib/serialport/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "serialport"
6
+ s.license = "GPL-2"
6
7
  s.version = SerialPort::VERSION
7
8
  s.authors = ["Guillaume Pierronnet", "Alan Stern", "Daniel E. Shipton", "Tobin Richard", "Hector Parra", "Ryan C. Payne"]
8
9
  s.summary = "Library for using RS-232 serial ports."
@@ -18,5 +19,5 @@ Gem::Specification.new do |s|
18
19
  s.files = `git ls-files`.split($\)
19
20
  s.extensions = "ext/native/extconf.rb"
20
21
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
- s.extra_rdoc_files = ["LICENSE", "README"]
22
+ s.extra_rdoc_files = ["LICENSE", "README.md"]
22
23
  end
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.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Pierronnet
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-11-04 00:00:00.000000000 Z
16
+ date: 2013-11-05 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -65,7 +65,7 @@ extensions:
65
65
  - ext/native/extconf.rb
66
66
  extra_rdoc_files:
67
67
  - LICENSE
68
- - README
68
+ - README.md
69
69
  files:
70
70
  - .gitignore
71
71
  - .travis.yml
@@ -74,7 +74,7 @@ files:
74
74
  - Gemfile
75
75
  - LICENSE
76
76
  - MANIFEST
77
- - README
77
+ - README.md
78
78
  - Rakefile
79
79
  - ext/native/extconf.rb
80
80
  - ext/native/posix_serialport_impl.c
@@ -87,7 +87,8 @@ files:
87
87
  - test/miniterm.rb
88
88
  - test/set_readtimeout.rb
89
89
  homepage: http://github.com/hparra/ruby-serialport/
90
- licenses: []
90
+ licenses:
91
+ - GPL-2
91
92
  metadata: {}
92
93
  post_install_message:
93
94
  rdoc_options: []
data/README DELETED
@@ -1,153 +0,0 @@
1
- -----Ruby/SerialPort-----
2
-
3
- -- Description --
4
-
5
- Ruby/SerialPort is a Ruby library that provides a class for using
6
- RS-232 serial ports. This class also contains low-level functions to
7
- check and set the current state of the signals on the line.
8
-
9
- The native Windows version of this library supports Microsoft's Visual C++, Borland's C++, and MinGW compilers.
10
-
11
- -- Installation --
12
-
13
- Then you can install the gem as normal:
14
- sudo gem install serialport
15
-
16
- -- Testing --
17
-
18
- * test/miniterm.rb
19
-
20
- Ruby's copy of miniterm.c !
21
-
22
-
23
- -- API --
24
-
25
- **** Class SerialPort, Parent IO ****
26
-
27
- ** Class constants **
28
-
29
- VERSION -> aString (EX: this release is "0.6")
30
- NONE, HARD, SOFT, SPACE, MARK, EVEN, ODD -> anInteger
31
-
32
- ** Class methods **
33
-
34
- * new(port_num [, modem_parameters]) -> aSerialPort
35
- * open(port_num [, modem_parameters]) -> aSerialPort
36
- * open(port_num [, modem_parameters]) {|aSerialPort| block} ->
37
- value of the block
38
-
39
- port_num -> anInteger: port number, 0 for first port which is
40
- "/dev/ttyS0" on GNU/Linux and "COM1" on Windows,
41
- or aString: file name of the device (example: "/dev/ttyS2")
42
-
43
- Optional modem_parameters:
44
-
45
- baud -> anInteger: from 50 to 1000000, depends on platform.
46
-
47
- data_bits -> anInteger: from 5 to 8 (4 is allowed on Windows)
48
-
49
- stop_bits -> anInteger: 1 or 2 (1.5 is not supported)
50
-
51
- parity -> anInteger: SerialPort::NONE, SerialPort::EVEN,
52
- SerialPort::ODD, SerialPort::MARK, SerialPort::SPACE
53
- (MARK and SPACE are not supported on Posix)
54
-
55
- Raise an argError on bad argument.
56
-
57
- SerialPort::new and SerialPort::open without a block return an
58
- instance of SerialPort. SerialPort::open with a block passes
59
- a SerialPort to the block and closes it when the block exits
60
- (like File::open).
61
-
62
-
63
- ** Instance methods **
64
-
65
- * modem_params() -> aHash
66
- * modem_params=(aHash) -> aHash
67
- * get_modem_params() -> aHash
68
- * set_modem_params(aHash) -> aHash
69
- * set_modem_params(baudrate [, databits [, stopbits [, parity]]])
70
-
71
- Get and set the modem parameters. Hash keys are "baud", "data_bits",
72
- "stop_bits", and "parity" (see above).
73
-
74
- Parameters not present in the hash or set to nil remain unchanged.
75
- Default parameter values for the set_modem_params method are:
76
- databits = 8, stopbits = 1, parity = (databits == 8 ?
77
- SerialPort::NONE : SerialPort::EVEN).
78
-
79
- * baud() -> anInteger
80
- * baud=(anInteger) -> anInteger
81
- * data_bits() -> 4, 5, 6, 7, or 8
82
- * data_bits=(anInteger) -> anInteger
83
- * stop_bits() -> 1 or 2
84
- * stop_bits=(anInteger) -> anInteger
85
- * parity() -> anInteger: SerialPort::NONE, SerialPort::EVEN,
86
- SerialPort::ODD, SerialPort::MARK, or SerialPort::SPACE
87
- * parity=(anInteger) -> anInteger
88
-
89
- Get and set the corresponding modem parameter.
90
-
91
- * flow_control() -> anInteger
92
- * flow_control=(anInteger) -> anInteger
93
-
94
- Get and set the flow control: SerialPort::NONE, SerialPort::HARD,
95
- SerialPort::SOFT, or (SerialPort::HARD | SerialPort::SOFT).
96
-
97
- Note: SerialPort::HARD mode is not supported on all platforms.
98
- SerialPort::HARD uses RTS/CTS handshaking; DSR/DTR is not
99
- supported.
100
-
101
- * read_timeout() -> anInteger
102
- * read_timeout=(anInteger) -> anInteger
103
- * write_timeout() -> anInteger
104
- * write_timeout=(anInteger) -> anInteger
105
-
106
- Get and set timeout values (in milliseconds) for reading and writing.
107
- A negative read timeout will return all the available data without
108
- waiting, a zero read timeout will not return until at least one
109
- byte is available, and a positive read timeout returns when the
110
- requested number of bytes is available or the interval between the
111
- arrival of two bytes exceeds the timeout value.
112
-
113
- Note: Read timeouts don't mix well with multi-threading.
114
-
115
- Note: Under Posix, write timeouts are not implemented.
116
-
117
- * break(time) -> nil
118
-
119
- Send a break for the given time.
120
-
121
- time -> anInteger: tenths-of-a-second for the break.
122
- Note: Under Posix, this value is very approximate.
123
-
124
- * signals() -> aHash
125
-
126
- Return a hash with the state of each line status bit. Keys are
127
- "rts", "dtr", "cts", "dsr", "dcd", and "ri".
128
-
129
- Note: Under Windows, the rts and dtr values are not included.
130
-
131
- * rts()
132
- * dtr()
133
- * cts()
134
- * dsr()
135
- * dcd()
136
- * ri() -> 0 or 1
137
-
138
- * rts=(0 or 1)
139
- * dtr=(0 or 1) -> 0 or 1
140
-
141
- Get and set the corresponding line status bit.
142
-
143
- Note: Under Windows, rts() and dtr() are not implemented.
144
-
145
- -- License --
146
-
147
- GPL
148
-
149
- Guillaume Pierronnet <moumar@netcourrier.com>
150
- Alan Stern <stern@rowland.harvard.edu>
151
- Tobin Richard <tobin.richard@gmail.com>
152
- Hector Parra <hector@hectorparra.com>
153
- Ryan C. Payne <rpayne-oss@bullittsystems.com>