alphasign 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +33 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/alphasign.rb +93 -0
- data/test/helper.rb +18 -0
- data/test/test_alphasign.rb +7 -0
- metadata +171 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "serialport","~>1.0"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "shoulda", ">= 0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
gem "jeweler", "~> 1.8.3"
|
15
|
+
gem "rcov", ">= 0"
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Jon Proulx
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= alphasign
|
2
|
+
|
3
|
+
A little gem to put messages on an LED sign, if that sign speak Alpha
|
4
|
+
Sign protocol, and if I don't get my sign taken away before I get this
|
5
|
+
to work.
|
6
|
+
|
7
|
+
== Example code
|
8
|
+
|
9
|
+
#!/usr/bin/env ruby
|
10
|
+
require 'rubygems'
|
11
|
+
require 'alphasign'
|
12
|
+
|
13
|
+
#specify serial port
|
14
|
+
sign=AlphaSign.new('/dev/ttyS0')
|
15
|
+
#write text to sign
|
16
|
+
sign.write("foo")
|
17
|
+
|
18
|
+
|
19
|
+
== Contributing to alphasign
|
20
|
+
|
21
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
22
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
23
|
+
* Fork the project.
|
24
|
+
* Start a feature/bugfix branch.
|
25
|
+
* Commit and push until you are happy with your contribution.
|
26
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
27
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
28
|
+
|
29
|
+
== Copyright
|
30
|
+
|
31
|
+
Copyright (c) 2012 Jon Proulx. See LICENSE.txt for
|
32
|
+
further details.
|
33
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "alphasign"
|
18
|
+
gem.homepage = "http://github.com/jon-proulx/alphasign"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "A gem for communicating with LED signs using Alpha Sign Protocol "
|
21
|
+
gem.description = <<-EOF
|
22
|
+
Alphasign is handles communication with LED signs using the Alpha Sign Protocol.
|
23
|
+
These include Alpha signs and Betabrite signs by Adaptive Micro Systems, maybe
|
24
|
+
others too, YMMV.
|
25
|
+
|
26
|
+
Initial release only handles writing text to the sign over rs232 serial port.
|
27
|
+
EOF
|
28
|
+
gem.email = "jon@jonproulx.com"
|
29
|
+
gem.authors = ["Jon Proulx"]
|
30
|
+
# dependencies defined in Gemfile
|
31
|
+
end
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
33
|
+
|
34
|
+
require 'rake/testtask'
|
35
|
+
Rake::TestTask.new(:test) do |test|
|
36
|
+
test.libs << 'lib' << 'test'
|
37
|
+
test.pattern = 'test/**/test_*.rb'
|
38
|
+
test.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
require 'rcov/rcovtask'
|
42
|
+
Rcov::RcovTask.new do |test|
|
43
|
+
test.libs << 'test'
|
44
|
+
test.pattern = 'test/**/test_*.rb'
|
45
|
+
test.verbose = true
|
46
|
+
test.rcov_opts << '--exclude "gems/*"'
|
47
|
+
end
|
48
|
+
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rdoc/task'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
54
|
+
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "alphasign #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/alphasign.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
class AlphaSign
|
2
|
+
# Require 'serialport' gem
|
3
|
+
require 'serialport'
|
4
|
+
|
5
|
+
#We have a relatively large number of potocol constants
|
6
|
+
|
7
|
+
###Serial config
|
8
|
+
Baud=9600
|
9
|
+
DataBits=7
|
10
|
+
Parity=SerialPort::EVEN
|
11
|
+
StopBits=2
|
12
|
+
###
|
13
|
+
|
14
|
+
#this was much more complex in original, but due to packing spec
|
15
|
+
#effectively reduced to this, and remains voodoo but apparently
|
16
|
+
#necessary voodoo
|
17
|
+
Preamble = [ ']', ']'].pack('x10ax10a')
|
18
|
+
# everything starts with this, nulls are to auto set baud on unit
|
19
|
+
StartHeader = Preamble + [ 0x01 ].pack('x20C')
|
20
|
+
# this is still a bit dubious, docs say "A" for write text file, but
|
21
|
+
# example and experience show "AA" is needed, other codes are as yet
|
22
|
+
# untested YMMV..I simply doubled the char listed in docs. only 'wtxt'
|
23
|
+
# actually works with anything else here
|
24
|
+
StartCMD = {
|
25
|
+
:wtxt => [ 0x02, 'AA' ].pack('CA2'), # write text file
|
26
|
+
:rtxt => [ 0x02, 'BB' ].pack('CA2'), # read text file
|
27
|
+
:wfctn => [ 0x02, 'EE' ].pack('CA2'), # write special function
|
28
|
+
:rfctn => [ 0x02, 'FF' ].pack('CA2'), # read special function
|
29
|
+
:wstr => [ 0x02, 'GG' ].pack('CA2'), # write string file
|
30
|
+
:rstr => [ 0x02, 'HH' ].pack('CA2'), # read string file
|
31
|
+
:wdots => [ 0x02, 'II' ].pack('CA2'), # write DOTS picture file
|
32
|
+
:rdots => [ 0x02, 'JJ' ].pack('CA2'), # read DOTS picture file
|
33
|
+
:wadots => [ 0x02, 'MM' ].pack('CA2'), # write ALPHAVISON DOTS picture file
|
34
|
+
:radots => [ 0x02, 'NN' ].pack('CA2'), # read ALPHAVISON DOTS picture file
|
35
|
+
:bulletin => [ 0x02, 'OO' ].pack('CA2'), # write bulletin message
|
36
|
+
}
|
37
|
+
|
38
|
+
# Marker for start of mode config
|
39
|
+
StartMode = [ 0x1b ].pack('C')
|
40
|
+
|
41
|
+
# Vertical Position
|
42
|
+
Position = {
|
43
|
+
:middle => [ 0x20 ].pack('C'),
|
44
|
+
:top => [ 0x22 ].pack('C'),
|
45
|
+
:bottom => [ 0x26 ].pack('C'),
|
46
|
+
:fill => [ 0x30 ].pack('C'),
|
47
|
+
}
|
48
|
+
# Mode Code, names taken form documentation
|
49
|
+
# since these are ascii probably don't need packing?
|
50
|
+
Mode = {
|
51
|
+
:rotate => ["a"].pack('A'), #scroll right to left
|
52
|
+
:hold => ["b"].pack('A'), # stationary
|
53
|
+
:flash => ["c"].pack('A'), #"flash"
|
54
|
+
# these are all transitions from previous message:
|
55
|
+
:rollup => ["e"].pack('A'),
|
56
|
+
:rolldown => ["f"].pack('A'),
|
57
|
+
:rollleft => ["g"].pack('A'),
|
58
|
+
:rollright => ["h"].pack('A'),
|
59
|
+
:wipeup => ["i"].pack('A'),
|
60
|
+
:wipedown => ["j"].pack('A'),
|
61
|
+
}
|
62
|
+
|
63
|
+
Footer = [0x04].pack("C") # EOT end of transmission
|
64
|
+
|
65
|
+
# @param [String] device the serial device the sign is connected to
|
66
|
+
# for now we only speak rs232
|
67
|
+
def initialize (device = "/dev/ttyS0")
|
68
|
+
@device= device
|
69
|
+
|
70
|
+
# Protocol allows multiple signs on the same port, we are not
|
71
|
+
# going to expose that possibility yet but we will recognize this
|
72
|
+
# as an instance variable Where "Z" all units, "00" first unit or
|
73
|
+
# broadcast?
|
74
|
+
@addr = [ 'Z00' ].pack('A3')
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# we don't have an open yet so this still kludgey and enfoces using
|
79
|
+
# only :wtxt command as thats the only one we know we can do
|
80
|
+
def write (msg, position=:middle, mode=:rotate)
|
81
|
+
@alphaFormat = StartMode + Position[position] + Mode[mode]
|
82
|
+
@alphaHeader = StartHeader + @addr + StartCMD[:wtxt] + @alphaFormat
|
83
|
+
sp=SerialPort.new(@device,
|
84
|
+
Baud, DataBits, StopBits, Parity)
|
85
|
+
sp.write @alphaHeader
|
86
|
+
sp.write msg
|
87
|
+
sp.write Footer
|
88
|
+
sp.close
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'alphasign'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alphasign
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jon Proulx
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-05 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
name: serialport
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 15
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
version: "1.0"
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
name: shoulda
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
name: rdoc
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 31
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 12
|
63
|
+
version: "3.12"
|
64
|
+
requirement: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
name: bundler
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 0
|
78
|
+
- 0
|
79
|
+
version: 1.0.0
|
80
|
+
requirement: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
name: jeweler
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 49
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 8
|
94
|
+
- 3
|
95
|
+
version: 1.8.3
|
96
|
+
requirement: *id005
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
name: rcov
|
101
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
requirement: *id006
|
111
|
+
description: |
|
112
|
+
Alphasign is handles communication with LED signs using the Alpha Sign Protocol.
|
113
|
+
These include Alpha signs and Betabrite signs by Adaptive Micro Systems, maybe
|
114
|
+
others too, YMMV.
|
115
|
+
|
116
|
+
Initial release only handles writing text to the sign over rs232 serial port.
|
117
|
+
|
118
|
+
email: jon@jonproulx.com
|
119
|
+
executables: []
|
120
|
+
|
121
|
+
extensions: []
|
122
|
+
|
123
|
+
extra_rdoc_files:
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.rdoc
|
126
|
+
files:
|
127
|
+
- .document
|
128
|
+
- Gemfile
|
129
|
+
- LICENSE.txt
|
130
|
+
- README.rdoc
|
131
|
+
- Rakefile
|
132
|
+
- VERSION
|
133
|
+
- lib/alphasign.rb
|
134
|
+
- test/helper.rb
|
135
|
+
- test/test_alphasign.rb
|
136
|
+
has_rdoc: true
|
137
|
+
homepage: http://github.com/jon-proulx/alphasign
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 3
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
version: "0"
|
163
|
+
requirements: []
|
164
|
+
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 1.3.7
|
167
|
+
signing_key:
|
168
|
+
specification_version: 3
|
169
|
+
summary: A gem for communicating with LED signs using Alpha Sign Protocol
|
170
|
+
test_files: []
|
171
|
+
|