forked from jeffrafter/win32-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
executable file
·63 lines (45 loc) · 1.99 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
== Win32Serial Extension Library (win32-serial)
Simple extension library to access Windows serial ports (COM ports) using the
Windows API. Originally written Apr. 10, 2006 by Travis Whitton
< [email protected] >
Gem conversion, organization and binary releases by Jeff Rafter.
== Example
It is possible to use the library directly:
require 'Win32Serial'
port = 'COM1'
s = Win32Serial.new
s.open(port)
s.config(9600, 8, Win32Serial::NOPARITY, Win32Serial::ONESTOPBIT)
s.timeouts(0, 200, 0, 0, 0)
bytes = s.write("AT+CGMI\r") || "< no bytes >"
puts "#{bytes} bytes written to #{port}"
puts "response " + (s.read(14) || " < no response >")
s.close
A compatibility layer has been added which allows you to access the library
using a SerialPort class as well:
require 'serialport'
sp = SerialPort.new('COM1', 9600, 8, 1, SerialPort::NONE)
sp.write("AT")
sp.read(14)
sp.close
In addition to write and read, getc is implemented for single byte reads. putc
is also implemented for single byte writes.
== Installation
Assuming you have a development environment on the target Windows machine you
can simply install the Gem normally. Alternatively, binary gem releases are
included in the bin folder and can be downloaded. These binary releases are
compiled using mingw and contain the Win32Serial.so, so no compilation on the
target Windows machine is necessary. These releases may not be compatible with
JRuby, Rubinius and other ruby implementations.
== License
Licensed under GPL. See GPL in the release.
== Copying
Original copying:
Win32Serial extension library is copyrighted free software by Travis Whitton
< [email protected] >. You can redistribute it under the terms
specified in the COPYING file of the Ruby distribution.
== Warranty
Original warranty:
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.