serialport 1.2.3 → 1.3.0

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
- NGJmNWI3ZWM5ODgyNWFmMTMzM2ViNGQ4M2VkZTAwMzkwMTRiZTViMA==
4
+ ZjZlYWM2MWEwMTFiMzQyMTQ4OTI2Y2Q2ZDA2ZmQyMGFiMzdlZmZiMA==
5
5
  data.tar.gz: !binary |-
6
- OGFhNWNiZTAyMjM0NjNjZDY0MTc5NGUxNWFjMWU2OWMyM2ZiNDdmNQ==
6
+ NDcwYjNlODBiMzQ5NTlkYjZmMzMwZTNjN2NkMjEyMDJhMzc4YzhkZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmE4Yjc3MDJmZWMwODBiMzkwZGVjMWZlNDgwZjcyNmFiMDU1NmY3MGVhNjcx
10
- YmMyMjEyYjAxNzMzZDZmMTg5NTlkNTIxZWEzMDVlZTc1ZWFiZDRmYmEwM2Rm
11
- YzY5ZGQzN2Q4NDI4YzMwN2QwNzI4NDcwN2JjYWRlZDFjZmZjNjI=
9
+ Yzk4ZTYxNmY4YjViZDEyYjZjMWRiN2EwZDQ0MWVhNDQxMTFhMWRjZTg0YWY0
10
+ OTM3YmY1NjNlMjU0MGFkOGE1YTZkNTdhMGFhOTgxMDA0MzZjN2VmOGM3MGYy
11
+ ZjE2NjdlM2UzYWYzYzBlMjA4NzlkNjFmNWYzNGY5NDcyYWUwNjk=
12
12
  data.tar.gz: !binary |-
13
- YmNhNWUwZDYzZDIzMDk3YWM5MDMxNDY4ODkxZDVmN2Q5ZmMwZTZiNWEwZTJl
14
- MzcwNTE4YTRhOGYwNGUzNjQ5MzZmYWE4OWQ5YTdjNDUwNzE1Zjg4ZmI3Yzk0
15
- MWJiOTE2MzkxNTJkMTVkNzNjN2ZmNmNhYjFjM2MxMTMxMDk1OTY=
13
+ MjQ3NzM5ZWQ5NTkyZWY2MGEzMmVmNmQzZTA5M2U2NjM1YzU5OGM5MWRiNGQ0
14
+ OTQzZThlNWVlNThhNjc4MDk0OTNmOWI3ZDQxYTg5ZjdkNjJmY2E0ZGZkNDNj
15
+ ZTdjMDAyMjhlZWEyYTkzNWI5YjU4Y2QxZGUxYWYyMjlmMzQ1MmU=
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 1.3.0 => 11/17/2013: [NEW] flush_input() and flush_output() methods [Manuel A. Güílamo (MaG)]
2
+
1
3
  1.2.3 => 11/04/2013: [FIXED] Improved documentation (yard)
2
4
 
3
5
  1.2.2 => 11/03/2013: [FIXED] warning: already initialized constant VERSION
data/CHECKLIST CHANGED
@@ -1,5 +1,12 @@
1
- # Ruby-Serialport Gem Pre-Push Checklist
1
+ # Ruby-Serialport Gem Release Checklist
2
2
 
3
+ * Update documentation
3
4
  * Update lib/serialport/version.rb
4
5
  * Update CHANGELOG
5
6
  * Update README
7
+ * `rake build`
8
+ * `rake install`
9
+ * Test build
10
+ * `git tag -a v{VERSION} -m "v{VERSION}: {ONE-LINE DESCRIPTION}"`
11
+ * Merge and Push
12
+ * `rake release`
@@ -3,6 +3,7 @@
3
3
  * Alan Stern <stern@rowland.harvard.edu>
4
4
  * Daniel E. Shipton <dshipton@redshiptechnologies.com>
5
5
  * Ryan C. Payne <rpayne-oss@bullittsystems.com>
6
+ * Manuel "MaG" A. Güílamo <maguilamo.c@gmail.com>
6
7
  *
7
8
  * This code is hereby licensed for public consumption under either the
8
9
  * GNU GPL v2 or greater.
@@ -730,4 +731,38 @@ VALUE sp_get_dtr_impl(self)
730
731
  return INT2FIX(ls.dtr);
731
732
  }
732
733
 
734
+ VALUE sp_flush_input_data_impl(self)
735
+ VALUE self;
736
+ {
737
+ int fd;
738
+ int ret;
739
+
740
+ fd = get_fd_helper(self);
741
+
742
+ ret = tcflush(fd, TCIFLUSH);
743
+ if(ret<0) {
744
+ return Qfalse;
745
+ }
746
+
747
+ return Qtrue;
748
+ }
749
+
750
+ VALUE sp_flush_output_data_impl(self)
751
+ VALUE self;
752
+ {
753
+ int fd;
754
+ int ret;
755
+
756
+ fd = get_fd_helper(self);
757
+
758
+ ret = tcflush(fd, TCOFLUSH);
759
+ if(ret<0) {
760
+ return Qfalse;
761
+ }
762
+
763
+ return Qtrue;
764
+ }
765
+
766
+
767
+
733
768
  #endif /* !defined(OS_MSWIN) && !defined(OS_BCCWIN) && !defined(OS_MINGW) */
@@ -489,6 +489,29 @@ static VALUE sp_signals(self)
489
489
  return hash;
490
490
  }
491
491
 
492
+ /**
493
+ * Flush data received but not read.
494
+ *
495
+ * @return [Boolean] true on success or false if an error occurs.
496
+ */
497
+ static VALUE sp_flush_input_data(self)
498
+ VALUE self;
499
+ {
500
+ return sp_flush_input_data_impl(self);
501
+ }
502
+
503
+ /**
504
+ * Flush data written but not transmitted.
505
+ *
506
+ * @return [Boolean] true on success or false if an error occurs.
507
+ */
508
+ static VALUE sp_flush_output_data(self)
509
+ VALUE self;
510
+ {
511
+ return sp_flush_output_data_impl(self);
512
+ }
513
+
514
+
492
515
  void Init_serialport()
493
516
  {
494
517
  sBaud = rb_str_new2("baud");
@@ -550,6 +573,9 @@ void Init_serialport()
550
573
  rb_define_method(cSerialPort, "dcd", sp_get_dcd, 0);
551
574
  rb_define_method(cSerialPort, "ri", sp_get_ri, 0);
552
575
 
576
+ rb_define_method(cSerialPort, "flush_input", sp_flush_input_data, 0);
577
+ rb_define_method(cSerialPort, "flush_output", sp_flush_output_data, 0);
578
+
553
579
  /*
554
580
  * 0
555
581
  */
@@ -94,4 +94,7 @@ VALUE RB_SERIAL_EXPORT sp_set_dtr_impl(VALUE self, VALUE val);
94
94
  VALUE RB_SERIAL_EXPORT sp_get_rts_impl(VALUE self);
95
95
  VALUE RB_SERIAL_EXPORT sp_get_dtr_impl(VALUE self);
96
96
 
97
+ VALUE RB_SERIAL_EXPORT sp_flush_input_data_impl(VALUE self);
98
+ VALUE RB_SERIAL_EXPORT sp_flush_output_data_impl(VALUE self);
99
+
97
100
  #endif
@@ -620,4 +620,40 @@ VALUE RB_SERIAL_EXPORT sp_get_dtr_impl(self)
620
620
  return self;
621
621
  }
622
622
 
623
+ #define PURGE_RXABORT 0x02
624
+ #define PURGE_RXCLEAR 0x08
625
+ VALUE RB_SERIAL_EXPORT sp_flush_input_data_impl(self)
626
+ VALUE self;
627
+ {
628
+ BOOL ret;
629
+ HANDLE fh;
630
+
631
+ fh = get_handle_helper(self);
632
+
633
+ ret = PurgeComm(fh, (DWORD)(PURGE_RXCLEAR | PURGE_RXABORT));
634
+ if(!ret) {
635
+ return Qfalse;
636
+ }
637
+ return Qtrue;
638
+ }
639
+
640
+ #define PURGE_TXABORT 0x01
641
+ #define PURGE_TXCLEAR 0x04
642
+ VALUE RB_SERIAL_EXPORT sp_flush_output_data_impl(self)
643
+ VALUE self;
644
+ {
645
+ BOOL ret;
646
+ HANDLE fh;
647
+
648
+ fh = get_handle_helper(self);
649
+
650
+ ret = PurgeComm(fh, (DWORD)(PURGE_TXCLEAR | PURGE_TXABORT));
651
+ if(!ret) {
652
+ return Qfalse;
653
+ }
654
+ return Qtrue;
655
+ }
656
+
657
+
658
+
623
659
  #endif /* defined(OS_MSWIN) || defined(OS_BCCWIN) || defined(OS_MINGW) */
@@ -1,3 +1,3 @@
1
1
  class SerialPort
2
- VERSION = "1.2.3"
2
+ VERSION = "1.3.0"
3
3
  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.3
4
+ version: 1.3.0
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-05 00:00:00.000000000 Z
16
+ date: 2013-11-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -111,3 +111,4 @@ signing_key:
111
111
  specification_version: 4
112
112
  summary: Library for using RS-232 serial ports.
113
113
  test_files: []
114
+ has_rdoc: