pigpio 0.1.10 → 0.1.11

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: 1fa3d31d3fb44ea838005f5a56348e48e5716cbd
4
- data.tar.gz: da12abb9a3d79848a8bd90c522b28640332528e2
3
+ metadata.gz: 030a9cfb8449fc59b223cd96371aa249dbc86876
4
+ data.tar.gz: 8e6aabca541f968cacfa06a08f79739bbc1807a2
5
5
  SHA512:
6
- metadata.gz: 92e28c29a0cc4a88f175d7960ad509356f2aa7b5fd99b6a8a1bf1c03b568ef34ea7df67f17eda4a4bcdaf9f7374095bcd79409ee1931de6f92727637d4bc0c00
7
- data.tar.gz: 9b5e95b0514e08aeb557743274958f7c25c446403b16a56140248922c30e87032a0e0010fe0fb25d0e95eec6a59f1cfb7b4c2fc68ea77b0d406299f3bf0c80a4
6
+ metadata.gz: e79ff833f0475fc2e817f56250def1d4a8d474fce3015ba9a77cb8412f707968e9720825aa686d54dfd2a7db004a0ad1d1fa74c7d55e6ca1a883bd7b1663dd19
7
+ data.tar.gz: e07c2ce1196b00ea32be4fcfc5fe420f10b5a18b3c13b4ed92044c12ae2401904f581d1efebc0b5f670c75454a2a1d7f96d759d94404e24001ad2014a6ac6e9e
data/README.md CHANGED
@@ -63,6 +63,8 @@ $ ruby example_led.rb
63
63
 
64
64
  More sample for this circuit. : [Hare](./example/simple/readme.md)
65
65
 
66
+ More sample for other circuit. : [Hare](./example/readme.md)
67
+
66
68
  More document : [GitHub Pages](https://nak1114.github.io/ruby-extension-pigpio/)
67
69
 
68
70
  ## Development
@@ -7,6 +7,7 @@
7
7
  static VALUE cCallbackID;
8
8
  static VALUE cNativeQueue;
9
9
  static VALUE cCallbackError;
10
+ static VALUE cBuffer;
10
11
 
11
12
  typedef struct{
12
13
  uint32_t tick;
@@ -2359,18 +2360,16 @@ associated with handle and writes them to buf.
2359
2360
  . .
2360
2361
  pi: >=0 (as returned by [*pigpio_start*]).
2361
2362
  handle: >=0, as returned by a call to [*serial_open*].
2362
- buf: an array to receive the read data.
2363
2363
  count: the maximum number of bytes to read.
2364
2364
  . .
2365
2365
 
2366
- Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
2366
+ Returns to buf.ret_code attribute the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
2367
2367
  PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
2368
2368
 
2369
- If no data is ready zero is returned.
2369
+ The received data is get by the buf.to_s method.
2370
2370
 
2371
2371
  :call-seq:
2372
- serial_read(Integer pi,Integer handle, Integer count) -> Integer (When onError)
2373
- serial_read(Integer pi,Integer handle, Integer count) -> String buf (When Success)
2372
+ serial_read(Integer pi,Integer handle, Integer count) -> Pigpio::Buffer buf
2374
2373
 
2375
2374
  See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#serial_read]
2376
2375
  */
@@ -2378,7 +2377,9 @@ VALUE pigpio_rbfn_serial_read(VALUE self, VALUE pi, VALUE handle, VALUE count){
2378
2377
  unsigned countc=NUM2UINT(count);
2379
2378
  VALUE buf=rb_str_new("",countc);//#<Encoding:ASCII-8BIT>;
2380
2379
  int ret=serial_read(NUM2INT(pi), NUM2UINT(handle), (void*)StringValuePtr(buf), countc);
2381
- return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2380
+ return rb_funcall((VALUE)cBuffer, rb_intern("new"), 2,INT2NUM(ret),rb_str_resize(buf,ret));
2381
+
2382
+ //return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2382
2383
  //if(ret < 0){buf=Qnil;}
2383
2384
  //return rb_ary_new_from_args(2,buf,INT2NUM(ret));
2384
2385
  }
@@ -2436,13 +2437,14 @@ bit bang serial cyclic buffer to the buffer starting at buf.
2436
2437
  . .
2437
2438
  pi: >=0 (as returned by [*pigpio_start*]).
2438
2439
  user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
2439
- buf: an array to receive the read bytes.
2440
2440
  bufSize: >=0
2441
2441
  . .
2442
2442
 
2443
- Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
2443
+ Returns to buf.ret_code attribute the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
2444
2444
  or PI_NOT_SERIAL_GPIO.
2445
2445
 
2446
+ The received data is get by the buf.to_s method.
2447
+
2446
2448
  The bytes returned for each character depend upon the number of
2447
2449
  data bits [*data_bits*] specified in the [*bb_serial_read_open*] command.
2448
2450
 
@@ -2451,8 +2453,7 @@ data bits [*data_bits*] specified in the [*bb_serial_read_open*] command.
2451
2453
  * For [*data_bits*] 17-32 there will be four bytes per character.
2452
2454
 
2453
2455
  :call-seq:
2454
- bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> Integer (When onError)
2455
- bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> String (When Success)
2456
+ bb_serial_read(Integer pi,Integer user_gpio, Integer bufSize) -> Pigpio::Buffer buf
2456
2457
 
2457
2458
  See also: {pigpio site}[http://abyz.me.uk/rpi/pigpio/pdif2.html#bb_serial_read]
2458
2459
  */
@@ -2460,7 +2461,8 @@ VALUE pigpio_rbfn_bb_serial_read(VALUE self, VALUE pi, VALUE user_gpio, VALUE bu
2460
2461
  size_t countc=NUM2SIZET(bufSize);
2461
2462
  VALUE buf=rb_str_new("",countc);//#<Encoding:ASCII-8BIT>;
2462
2463
  int ret=bb_serial_read(NUM2INT(pi), NUM2UINT(user_gpio), (void*)StringValuePtr(buf), countc);
2463
- return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2464
+ return rb_funcall((VALUE)cBuffer, rb_intern("new"), 2,INT2NUM(ret),rb_str_resize(buf,ret));
2465
+ //return (ret < 0)?INT2NUM(ret):rb_str_resize(buf,ret);
2464
2466
  //if(ret < 0){buf=Qnil;}
2465
2467
  //return rb_ary_new_from_args(2,buf,INT2NUM(ret));
2466
2468
  }
@@ -3702,9 +3704,6 @@ This class has some constances for pigpio library.
3702
3704
  */
3703
3705
  void Init_pigpio(void){
3704
3706
  VALUE cPulse,cBscXfer,cNativeQueue;
3705
- /*
3706
- This class has some constances for pigpio library.
3707
- */
3708
3707
  VALUE cPigpio = rb_define_class("Pigpio", rb_cObject);
3709
3708
  /*
3710
3709
  This module is a ruby binding to pigpio library.
@@ -3864,4 +3863,10 @@ This class has some constances for pigpio library.
3864
3863
  */
3865
3864
  cCallbackError = rb_define_class_under(cPigpio,"CallbackError", rb_eException);
3866
3865
  rb_gc_register_address(&cCallbackError);
3866
+
3867
+ /*
3868
+ The class of Rx buffer.
3869
+ */
3870
+ cBuffer = rb_define_class_under(cPigpio,"Buffer", rb_cString);
3871
+ rb_gc_register_address(&cBuffer);
3867
3872
  }
@@ -1,5 +1,6 @@
1
1
  require "pigpio/version"
2
2
  require "pigpio/constant"
3
+ require "pigpio/buffer"
3
4
  require "pigpio/pigpio"
4
5
  require "pigpio/gpio"
5
6
  require "pigpio/user_gpio"
@@ -0,0 +1,12 @@
1
+ class Pigpio
2
+ class Buffer < String
3
+ attr_reader :ret_code
4
+ def initialize(ret_code,str=nil)
5
+ super(str)
6
+ @ret_code=ret_code
7
+ end
8
+ def valid?
9
+ @ret_code>=0
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  class Pigpio
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - nak1114
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,6 +95,7 @@ files:
95
95
  - lib/pigpio/bit_bang_serial.rb
96
96
  - lib/pigpio/bit_bang_serial_rx.rb
97
97
  - lib/pigpio/bit_bang_serial_tx.rb
98
+ - lib/pigpio/buffer.rb
98
99
  - lib/pigpio/constant.rb
99
100
  - lib/pigpio/gpio.rb
100
101
  - lib/pigpio/i2c.rb