ffi-serial 1.0.4 → 1.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -15
  3. metadata +4 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f14f5fa7b1ce50d9e803e54e5b58973e346f451
4
- data.tar.gz: 626100a1daf9c5116556e7178300e08c0ac99ace
3
+ metadata.gz: 8f95a4e88908eb1b80ae76136b884b2449d6f924
4
+ data.tar.gz: 9524c3c9aa76253182c138d12980a0c795ee7c64
5
5
  SHA512:
6
- metadata.gz: a7f948d7807357304a2d237896287c2a61b488aa01a12a9a5c7682c87dad4738180f4cefd9bc77c32bbd0c8eba896b11b691ef57fdf0848e2691820cf72c22ed
7
- data.tar.gz: ff9f571d42ec5859a97754ee12a8af9d014715169f8eeb38b4b00fefdd7066daa55967ada9d546d3742c1bd22385266c8051f3ade1add937c5f90e0a4a3bb25e
6
+ metadata.gz: 5a33cbeadb87d2d8908a1a714363e2d3ad4f84ad787086440dd015a415f39d6cd512a21cab0937fea91851d96a593de84a4b7f65bab18652f3fcad97ce965676
7
+ data.tar.gz: 58c99d95cb085426e0d5003dbc9edfce064d125ceee721e0d6cd25029ee360e84872b79ee9b56baac01ac30c039831f3cbfbec32bae23f2bc0499537168c3a5b
data/README.md CHANGED
@@ -4,21 +4,18 @@ FFI Serial is a simple OS independent gem to allow access to a serial port
4
4
  ## Why?
5
5
  Other gems exist, why this gem?
6
6
 
7
- 1. Uses FFI to negate the need for native compilation
8
- 2. Simply acts as a configurator for Ruby IO objects
7
+ 1. Opens Serial port as Ruby IO object
8
+ 2. Uses FFI to configure serial port using native operating system functions
9
9
 
10
- ## Why FFI?
11
- FFI is very widely supported at this point.
12
- By making use of FFI a lot of native compilation concerns go away.
10
+ ### Why IO?
11
+ - Serial ports are exposed as files in both Posix(Linux/Mac/BSD/etc) and Windows
12
+ - Ruby IO provides a rich API and it is part of standard library
13
+ - Ruby IO contains a large amount of very efficient and well tested code
14
+ - Reduces gem complexity to only configuring serial port
13
15
 
14
- ## Why IO?
15
- Serial ports are simply files, in both Posix and Windows, that have special API calls to configure the serial port settings.
16
-
17
- Ruby IO provides a rich API and it is part of standard library.
18
- Using IO, this gem benefits from everything Ruby IO provides.
19
- No modification is made to IO nor does this simply emulate IO.
20
-
21
- 99% of the code in this gem is to call the native operating system functions to configure the IO object serial port settings
16
+ ### Why FFI?
17
+ - Removes native compilation concerns
18
+ - FFI is very widely supported (portable)
22
19
 
23
20
  ## Installation
24
21
  gem install ffi-serial
@@ -40,15 +37,25 @@ No modification is made to IO nor does this simply emulate IO.
40
37
  port.is_a?(File) #=> true
41
38
 
42
39
  port.read_nonblock(512) #=> ... <supported in Windows>
43
- port.read #=> ...
44
40
  port.readpartial(512) #=> ...
45
41
  port.write "\n" #=> 1
46
42
  # etc.
47
43
 
44
+ port.read_timeout = 1.5 #=> 1.5 # 1500ms
45
+ port.gets("\n") #=> ... Timeouts after 1.5 seconds
46
+
48
47
  port.close #=> nil
49
48
 
50
49
  # Explicit configuration (and works on Windows)
51
50
  port = Serial.new port: 'COM1', data_bits: 8, stop_bits: 1, parity: :none #=> <Serial:COM1>
51
+ # OR
52
+ port = Serial.new port: 1, data_bits: 8, stop_bits: 1, parity: :none #=> <Serial:COM1>
52
53
 
53
54
  See Ruby standard library IO for complete method list
54
- http://ruby-doc.org/core-1.9.3/IO.html
55
+ http://ruby-doc.org/core-1.9.3/IO.html
56
+
57
+ ## Notes
58
+ IO.read will not behave exactly as described in IO.read but probably not as most developers expect.
59
+ IO.read will read either until read_timeout is reached or EOF is reached.
60
+
61
+ Serial ports are not truly files and will never reach EOF, therefore if read_timeout is 0, IO.read should be expected to block forever.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-serial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan van der Vyver
@@ -30,9 +30,8 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.9.3
33
- description: Yet another Ruby Serial Port implementation using FFI. Returns a Ruby
34
- IO object configured as a serial port to leverage the extensive Ruby IO standard
35
- library functionality
33
+ description: Ruby Serial port library that uses Ruby standard library IO to open a
34
+ connection to a serial port. Then configures the port using FFI
36
35
  email: code@johan.vdvyver.com
37
36
  executables: []
38
37
  extensions: []
@@ -47,7 +46,7 @@ files:
47
46
  - lib/ffi-serial/linux.rb
48
47
  - lib/ffi-serial/posix.rb
49
48
  - lib/ffi-serial/windows.rb
50
- homepage:
49
+ homepage: https://github.com/jovandervyver/ffi-serial
51
50
  licenses:
52
51
  - MIT
53
52
  metadata: {}