rubyserial 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf9ebb88fab33dab5ecbab092ef61a44e79f68f9
4
- data.tar.gz: 8b87a90c0ea75207abd1a42dc39eb03eed3ed17c
3
+ metadata.gz: 7d014cad0d8238b82bf39b107e4a68c3ff7e2d16
4
+ data.tar.gz: ee8f9b64e23413ebceab097643078f0df1afb2e5
5
5
  SHA512:
6
- metadata.gz: f5e575bf1e75f67c330a72429bb6fa6e2140b03d6af89225eeaeb8258bd36e4b7109340d092eff63fe89587859d299335726075f47fd873fe458f8de99b7a983
7
- data.tar.gz: c6e97c61f1a61ea9f531d056a5b827ce41bd31d1eafba2bfc55d4a1e6919490a765acffb067a0d48457b30d61904da017f1bcf6e36afbe29364d20d48809d4ff
6
+ metadata.gz: c4ca69b2cb366a8a86cfcd898010af66f1fb69c33b4ae53a83d52c9e7cc4e5b56ca45bd3a13bd8bef0c3a511bf7a224a9926a63269c544521d1742a5775c00a3
7
+ data.tar.gz: 22216f7ec08c00d115c1760e104304639a5d86ed721db4cc646b844b64954581e92a350df43343e4edef79d863766542e60088150c811f5bdc4a8804985cadfb
data/.travis.yml CHANGED
@@ -1,20 +1,28 @@
1
+ dist: trusty
2
+ sudo: false
1
3
  language: ruby
4
+ addons:
5
+ apt:
6
+ packages:
7
+ - socat
8
+ env:
9
+ - RUBYOPT=-rbundler/deprecate # workaround for bundler on rbx
2
10
  rvm:
3
- - 2.3.1
11
+ - 2.4
12
+ - 2.3
4
13
  - 2.2
5
14
  - 2.1
6
15
  - jruby-9.1.2.0
7
- - rbx-2
16
+ - rbx-3
8
17
  - ruby-head
9
18
  - jruby-head
10
19
  matrix:
11
20
  allow_failures:
12
- - rvm: jruby-head
21
+ - rvm: rbx-3
13
22
  - rvm: ruby-head
23
+ - rvm: jruby-head
14
24
  before_install:
15
- - gem query -i -n ^bundler$ -v'>=1.12.5' >/dev/null || gem install bundler
16
- install:
17
- - sudo apt-get update && sudo apt-get install --force-yes socat
25
+ - gem install bundler --force
18
26
  script:
19
- - bundle install
20
- - CODECLIMATE_REPO_TOKEN=70754a8aa666790236dbbb910727648f4dbb1f73a28f886d0b0c9e39a36b5a79 bundle exec rspec -fd
27
+ - export CODECLIMATE_REPO_TOKEN=70754a8aa666790236dbbb910727648f4dbb1f73a28f886d0b0c9e39a36b5a79
28
+ - bundle exec ruby -rbundler/deprecate -S rspec -fd && bundle exec ruby -rbundler/deprecate -S codeclimate-test-reporter
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source "http://rubygems.org"
3
3
 
4
4
  gemspec
5
5
  gem 'rspec', '~> 3.0.0'
6
- gem "codeclimate-test-reporter", group: :test, require: nil
6
+ gem 'simplecov', require: false, group: :test
7
+ gem "codeclimate-test-reporter", '~> 1.0', group: :test, require: false
data/README.md CHANGED
@@ -28,22 +28,22 @@ serialport = Serial.new '/dev/ttyACM0', 19200, 8, :even
28
28
  **write(data : String) -> Int**
29
29
 
30
30
  Returns the number of bytes written.
31
- Emits a `RubySerial::Exception` on error.
31
+ Emits a `RubySerial::Error` on error.
32
32
 
33
33
  **read(length : Int) -> String**
34
34
 
35
35
  Returns a string up to `length` long. It is not guaranteed to return the entire
36
36
  length specified, and will return an empty string if no data is
37
- available. Emits a `RubySerial::Exception` on error.
37
+ available. Emits a `RubySerial::Error` on error.
38
38
 
39
39
  **getbyte -> Fixnum or nil**
40
40
 
41
41
  Returns an 8 bit byte or nil if no data is available.
42
- Emits a `RubySerial::Exception` on error.
42
+ Emits a `RubySerial::Error` on error.
43
43
 
44
- **RubySerial::Exception**
44
+ **RubySerial::Error**
45
45
 
46
- A wrapper exception type, that returns the underlying system error code.
46
+ A wrapper error type that returns the underlying system error code and inherits from IOError.
47
47
 
48
48
  ## Running the tests
49
49
 
data/appveyor.yml CHANGED
@@ -4,7 +4,7 @@ platform:
4
4
  install:
5
5
  - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
6
6
  - ruby -v
7
- - gem install bundler
7
+ - gem install bundler --force
8
8
  - bundle install
9
9
  - ps: Start-FileDownload https://github.com/hybridgroup/rubyserial/raw/appveyor_deps/com0com.cer
10
10
  - ps: C:\"Program Files"\"Microsoft SDKs"\Windows\v7.1\Bin\CertMgr.exe /add com0com.cer /s /r localMachine root
@@ -16,13 +16,14 @@ install:
16
16
 
17
17
  test_script:
18
18
  - SET CODECLIMATE_REPO_TOKEN=70754a8aa666790236dbbb910727648f4dbb1f73a28f886d0b0c9e39a36b5a79
19
- - bundle exec rspec -fd
19
+ - bundle exec rspec -fd && bundle exec codeclimate-test-reporter
20
20
 
21
21
  environment:
22
22
  matrix:
23
+ - ruby_version: 24
24
+ - ruby_version: 23
23
25
  - ruby_version: 22
24
26
  - ruby_version: 21
25
27
  - ruby_version: 200
26
- - ruby_version: 193
27
28
 
28
29
  build: off
data/lib/rubyserial.rb CHANGED
@@ -6,7 +6,7 @@ require 'ffi'
6
6
  module RubySerial
7
7
  ON_WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
8
8
  ON_LINUX = RbConfig::CONFIG['host_os'] =~ /linux/i
9
- class Exception < Exception
9
+ class Error < IOError
10
10
  end
11
11
  end
12
12
 
@@ -211,12 +211,12 @@ module RubySerial
211
211
  :c_ospeed, :uint
212
212
  end
213
213
 
214
- attach_function :ioctl, [ :int, :ulong, RubySerial::Posix::Termios], :int
215
- attach_function :tcsetattr, [ :int, :int, RubySerial::Posix::Termios ], :int
216
- attach_function :fcntl, [:int, :int, :varargs], :int
217
- attach_function :open, [:pointer, :int], :int
218
- attach_function :close, [:int], :int
219
- attach_function :write, [:int, :pointer, :int],:int
220
- attach_function :read, [:int, :pointer, :int],:int
214
+ attach_function :ioctl, [ :int, :ulong, RubySerial::Posix::Termios], :int, blocking: true
215
+ attach_function :tcsetattr, [ :int, :int, RubySerial::Posix::Termios ], :int, blocking: true
216
+ attach_function :fcntl, [:int, :int, :varargs], :int, blocking: true
217
+ attach_function :open, [:pointer, :int], :int, blocking: true
218
+ attach_function :close, [:int], :int, blocking: true
219
+ attach_function :write, [:int, :pointer, :int],:int, blocking: true
220
+ attach_function :read, [:int, :pointer, :int],:int, blocking: true
221
221
  end
222
222
  end
@@ -179,11 +179,11 @@ module RubySerial
179
179
  :c_ospeed, :ulong
180
180
  end
181
181
 
182
- attach_function :tcsetattr, [ :int, :int, RubySerial::Posix::Termios ], :int
183
- attach_function :fcntl, [:int, :int, :varargs], :int
184
- attach_function :open, [:pointer, :int], :int
185
- attach_function :close, [:int], :int
186
- attach_function :write, [:int, :pointer, :int],:int
187
- attach_function :read, [:int, :pointer, :int],:int
182
+ attach_function :tcsetattr, [ :int, :int, RubySerial::Posix::Termios ], :int, blocking: true
183
+ attach_function :fcntl, [:int, :int, :varargs], :int, blocking: true
184
+ attach_function :open, [:pointer, :int], :int, blocking: true
185
+ attach_function :close, [:int], :int, blocking: true
186
+ attach_function :write, [:int, :pointer, :int],:int, blocking: true
187
+ attach_function :read, [:int, :pointer, :int],:int, blocking: true
188
188
  end
189
189
  end
@@ -6,26 +6,26 @@ class Serial
6
6
  @fd = RubySerial::Posix.open(address, file_opts)
7
7
 
8
8
  if @fd == -1
9
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
9
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
10
10
  else
11
11
  @open = true
12
12
  end
13
13
 
14
14
  fl = RubySerial::Posix.fcntl(@fd, RubySerial::Posix::F_GETFL, :int, 0)
15
15
  if fl == -1
16
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
16
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
17
17
  end
18
18
 
19
19
  err = RubySerial::Posix.fcntl(@fd, RubySerial::Posix::F_SETFL, :int, ~RubySerial::Posix::O_NONBLOCK & fl)
20
20
  if err == -1
21
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
21
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
22
22
  end
23
23
 
24
24
  @config = build_config(baude_rate, data_bits, parity)
25
25
 
26
26
  err = RubySerial::Posix.tcsetattr(@fd, RubySerial::Posix::TCSANOW, @config)
27
27
  if err == -1
28
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
28
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
29
29
  end
30
30
  end
31
31
 
@@ -36,7 +36,7 @@ class Serial
36
36
  def close
37
37
  err = RubySerial::Posix.close(@fd)
38
38
  if err == -1
39
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
39
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
40
40
  else
41
41
  @open = false
42
42
  end
@@ -49,7 +49,7 @@ class Serial
49
49
  buff = FFI::MemoryPointer.from_string(data[n..-1].to_s)
50
50
  i = RubySerial::Posix.write(@fd, buff, buff.size-1)
51
51
  if i == -1
52
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
52
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
53
53
  else
54
54
  n = n+i
55
55
  end
@@ -63,7 +63,7 @@ class Serial
63
63
  buff = FFI::MemoryPointer.new :char, size
64
64
  i = RubySerial::Posix.read(@fd, buff, size)
65
65
  if i == -1
66
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
66
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
67
67
  end
68
68
  buff.get_bytes(0, i)
69
69
  end
@@ -72,7 +72,7 @@ class Serial
72
72
  buff = FFI::MemoryPointer.new :char, 1
73
73
  i = RubySerial::Posix.read(@fd, buff, 1)
74
74
  if i == -1
75
- raise RubySerial::Exception, RubySerial::Posix::ERROR_CODES[FFI.errno]
75
+ raise RubySerial::Error, RubySerial::Posix::ERROR_CODES[FFI.errno]
76
76
  end
77
77
 
78
78
  if i == 0
@@ -1,7 +1,7 @@
1
- # Copyright (c) 2014-2016 The Hybrid Group
1
+ # Copyright (c) 2014-2017 The Hybrid Group and Friends
2
2
 
3
3
  module RubySerial
4
4
  unless const_defined?('VERSION')
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ class Serial
9
9
  @fd = RubySerial::Win32.CreateFileA("\\\\.\\#{address}", file_opts, 0, nil, RubySerial::Win32::OPEN_EXISTING, 0, nil)
10
10
  err = FFI.errno
11
11
  if err != 0
12
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[err]
12
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[err]
13
13
  else
14
14
  @open = true
15
15
  end
@@ -18,7 +18,7 @@ class Serial
18
18
  dcb[:dcblength] = RubySerial::Win32::DCB::Sizeof
19
19
  err = RubySerial::Win32.GetCommState @fd, dcb
20
20
  if err == 0
21
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
21
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
22
22
  end
23
23
  dcb[:baudrate] = baude_rate
24
24
  dcb[:bytesize] = data_bits
@@ -26,7 +26,7 @@ class Serial
26
26
  dcb[:parity] = RubySerial::Win32::DCB::NOPARITY
27
27
  err = RubySerial::Win32.SetCommState @fd, dcb
28
28
  if err == 0
29
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
29
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
30
30
  end
31
31
  end
32
32
 
@@ -38,7 +38,7 @@ class Serial
38
38
  timeouts[:write_total_timeout_constant] = 10
39
39
  err = RubySerial::Win32.SetCommTimeouts @fd, timeouts
40
40
  if err == 0
41
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
41
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
42
42
  end
43
43
  end
44
44
  end
@@ -48,7 +48,7 @@ class Serial
48
48
  count = FFI::MemoryPointer.new :uint32, 1
49
49
  err = RubySerial::Win32.ReadFile(@fd, buff, size, count, nil)
50
50
  if err == 0
51
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
51
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
52
52
  end
53
53
  buff.get_bytes(0, count.read_int)
54
54
  end
@@ -58,7 +58,7 @@ class Serial
58
58
  count = FFI::MemoryPointer.new :uint32, 1
59
59
  err = RubySerial::Win32.ReadFile(@fd, buff, 1, count, nil)
60
60
  if err == 0
61
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
61
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
62
62
  end
63
63
 
64
64
  if count.read_int == 0
@@ -73,7 +73,7 @@ class Serial
73
73
  count = FFI::MemoryPointer.new :uint32, 1
74
74
  err = RubySerial::Win32.WriteFile(@fd, buff, buff.size-1, count, nil)
75
75
  if err == 0
76
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
76
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
77
77
  end
78
78
  count.read_int
79
79
  end
@@ -91,7 +91,7 @@ class Serial
91
91
  def close
92
92
  err = RubySerial::Win32.CloseHandle(@fd)
93
93
  if err == 0
94
- raise RubySerial::Exception, RubySerial::Win32::ERROR_CODES[FFI.errno]
94
+ raise RubySerial::Error, RubySerial::Win32::ERROR_CODES[FFI.errno]
95
95
  else
96
96
  @open = false
97
97
  end
@@ -263,13 +263,13 @@ module RubySerial
263
263
  :write_total_timeout_constant, :uint32
264
264
  end
265
265
 
266
- attach_function :CreateFileA, [:pointer, :uint32, :uint32, :pointer, :uint32, :uint32, :pointer], :pointer
267
- attach_function :CloseHandle, [:pointer], :int
268
- attach_function :ReadFile, [:pointer, :pointer, :uint32, :pointer, :pointer], :int32
269
- attach_function :WriteFile, [:pointer, :pointer, :uint32, :pointer, :pointer], :int32
270
- attach_function :GetCommState, [:pointer, RubySerial::Win32::DCB], :int32
271
- attach_function :SetCommState, [:pointer, RubySerial::Win32::DCB], :int32
272
- attach_function :GetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32
273
- attach_function :SetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32
266
+ attach_function :CreateFileA, [:pointer, :uint32, :uint32, :pointer, :uint32, :uint32, :pointer], :pointer, blocking: true
267
+ attach_function :CloseHandle, [:pointer], :int, blocking: true
268
+ attach_function :ReadFile, [:pointer, :pointer, :uint32, :pointer, :pointer], :int32, blocking: true
269
+ attach_function :WriteFile, [:pointer, :pointer, :uint32, :pointer, :pointer], :int32, blocking: true
270
+ attach_function :GetCommState, [:pointer, RubySerial::Win32::DCB], :int32, blocking: true
271
+ attach_function :SetCommState, [:pointer, RubySerial::Win32::DCB], :int32, blocking: true
272
+ attach_function :GetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32, blocking: true
273
+ attach_function :SetCommTimeouts, [:pointer, RubySerial::Win32::CommTimeouts], :int32, blocking: true
274
274
  end
275
275
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
3
4
  # This file was generated by the `rspec --init` command. Conventionally, all
4
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
6
  # The generated `.rspec` file contains `--require spec_helper` which will cause this
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Zankich
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-27 00:00:00.000000000 Z
13
+ date: 2017-12-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi