Skip to content

Commit 8d51ae2

Browse files
Initial population from old SVN repo. No history imported.
1 parent 6de7266 commit 8d51ae2

File tree

110 files changed

+8683
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+8683
-0
lines changed

INSTALL

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
There are two steps to install the Ruby PCAN extension:
2+
3+
1. Install the ruby gem. The command 'gem install <pcan gem filename>'
4+
will automatically install the gem to your ruby directory.
5+
6+
2. Place the PCAN_USB.dll file in the appropriate directory.
7+
Since the installation software that comes with the PCAN device does
8+
not seem to automatically place the dll in the correct location,
9+
you can either place it in the Windows\System32 directory or you
10+
can place it in the same working directory as your Ruby files that
11+
require the extension. I went ahead and put it in my System32 directory
12+
so that I wouldn't have to worry so much about the location of the
13+
library.
14+
15+
I found the DLL on the PCAN CD in the directory USB\PCAN-Light.

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2006 Atomic Object, LLC
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
Except as contained in this notice, the name(s) of the above
16+
copyright holders shall not be used in advertising or otherwise
17+
to promote the sale, use or other dealings in this Software
18+
without prior written authorization.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27+
OTHER DEALINGS IN THE SOFTWARE.

Rakefile

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
require 'rake'
2+
require 'rake/clean'
3+
require 'rake/testtask'
4+
require 'rubygems'
5+
require 'rake/gempackagetask'
6+
require File.dirname(__FILE__) + "/config/environment"
7+
load APP_ROOT + "/vendor/behaviors/tasks/behaviors_tasks.rake"
8+
Gem::manage_gems
9+
10+
GEM_NAME = "pcan"
11+
GEM_VERSION = "0.9.1"
12+
13+
def get_file_list
14+
files = []
15+
[
16+
FileList['lib/**/*'],
17+
FileList['vendor/behaviors/**/*'],
18+
FileList['vendor/cmock/**/*'],
19+
FileList['test/unit/**/*'],
20+
'config/environment.rb',
21+
'test/test_helper.rb',
22+
'doc/readme.txt',
23+
'LICENSE',
24+
'INSTALL',
25+
].each do |additional_file|
26+
files << additional_file
27+
end
28+
files.flatten
29+
end
30+
31+
gem_spec = Gem::Specification.new do |spec|
32+
spec.name = GEM_NAME
33+
spec.version = GEM_VERSION
34+
spec.author = "Atomic Object, LLC"
35+
spec.email = "[email protected]"
36+
spec.homepage = "http://www.atomicobject.com"
37+
spec.platform = Gem::Platform::CURRENT
38+
spec.summary = "Ruby driver for pCAN USB device"
39+
spec.files = get_file_list
40+
spec.has_rdoc = false
41+
end
42+
43+
Rake::GemPackageTask.new(gem_spec) do
44+
end
45+
46+
# Constants.
47+
CLOBBER.include('Makefile')
48+
CLOBBER.include('mkmf.log')
49+
CLEAN.include('*.def')
50+
51+
NEW_PATH_VARS = [
52+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE',
53+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin'
54+
]
55+
56+
NEW_INCLUDE_VARS = [
57+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include',
58+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include'
59+
]
60+
61+
NEW_LIB_VARS = [
62+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib',
63+
'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib'
64+
]
65+
66+
# Helpers.
67+
def shell_wrapper(command)
68+
original_path = ENV['PATH']
69+
original_include = ENV['INCLUDE']
70+
original_lib = ENV['LIB']
71+
72+
ENV['PATH'] = [NEW_PATH_VARS, ENV['PATH']].flatten.join(';')
73+
ENV['INCLUDE'] = [NEW_INCLUDE_VARS, ENV['INCLUDE']].flatten.join(';')
74+
ENV['LIB'] = [NEW_LIB_VARS, ENV['LIB']].flatten.join(';')
75+
76+
begin
77+
sh command
78+
ensure
79+
ENV['PATH'] = original_path
80+
ENV['INCLUDE'] = original_include
81+
ENV['LIB'] = original_lib
82+
end
83+
end
84+
85+
# Tasks.
86+
desc "Build the PCAN extension Makefile"
87+
file "Makefile" => 'extconf.rb' do
88+
ruby 'extconf.rb --with-pcan-dir=vendor/pcan'
89+
end
90+
91+
desc "Install the pcan extension using Rubygems"
92+
task :install => :gem do
93+
sh "gem.bat install pkg/pcan-#{GEM_VERSION}-i386-mswin32.gem"
94+
end
95+
96+
desc "Uninstall the pcan extension using Rubygems"
97+
task :uninstall do
98+
sh "gem.bat uninstall pcan"
99+
end
100+
101+
desc "Build the PCAN extension"
102+
task :build => "Makefile" do
103+
shell_wrapper 'nmake'
104+
cp 'PcanHardware.so', 'lib'
105+
end
106+
107+
task :clean => "Makefile" do
108+
shell_wrapper 'nmake clean'
109+
end
110+
111+
test = namespace :test do
112+
desc "Run the unit test suite"
113+
Rake::TestTask.new(:units => :build) do |t|
114+
t.pattern = "test/unit/**/*_test.rb"
115+
t.verbose = true
116+
end
117+
118+
desc "Run the system test suite"
119+
task :system => :build do
120+
require 'systir'
121+
require "#{SYSTEST_ROOT}/pcan_driver.rb"
122+
result = Systir::Launcher.new.find_and_run_all_tests(PcanDriver, SYSTEST_ROOT)
123+
raise "SYSTEM TESTS FAILED" unless result.passed?
124+
end
125+
126+
end
127+
128+
desc "Build the PCAN extension and run the test suite"
129+
task :default => [:build, test[:units]]
130+
131+
desc "Clean, build, run unit tests, and run system tests"
132+
task :all => [:clean, :build, test[:units], test[:system]]

config/environment.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
APP_ROOT = File.expand_path(File.dirname(__FILE__) + "/..")
2+
SYSTEST_ROOT = APP_ROOT + "/test/system"
3+
4+
# Setup our load path:
5+
[ 'lib',
6+
'vendor/behaviors/lib',
7+
'vendor/cmock/lib',
8+
'vendor/systir'].each do |dir|
9+
$LOAD_PATH << File.join(APP_ROOT, dir)
10+
end

create_makefile.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exec 'ruby extconf.rb "--with-windows-dir=C:\\Program Files\\Microsoft Visual Studio 8\\VC\\PlatformSDK" "--with-vc-dir=C:\\Program Files\\Microsoft Visual Studio 8\\VC"'

doc/PCAN-USBUS.GID

8.43 KB
Binary file not shown.

doc/PCAN-USBUS.HLP

20.8 KB
Binary file not shown.

doc/PCAN-USB_en-US.pdf

1.01 MB
Binary file not shown.

doc/behaviors.html

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<html>
2+
<head>
3+
<style>
4+
5+
div.title
6+
{
7+
width: 600px;
8+
font: bold 14pt trebuchet ms;
9+
}
10+
11+
div.specification
12+
{
13+
font: bold 12pt trebuchet ms;
14+
border: solid 1px black;
15+
width: 600px;
16+
padding: 5px;
17+
margin: 5px;
18+
}
19+
20+
ul.requirements
21+
{
22+
font: normal 11pt verdana;
23+
padding-left: 0;
24+
margin-left: 0;
25+
border-bottom: 1px solid gray;
26+
width: 600px;
27+
}
28+
29+
ul.requirements li
30+
{
31+
list-style: none;
32+
margin: 0;
33+
padding: 0.25em;
34+
border-top: 1px solid gray;
35+
}
36+
</style>
37+
</head>
38+
<body>
39+
<div class="title">Specifications for pcanusb</div>
40+
41+
<div class="specification">
42+
Pcan Hardware should:
43+
<ul class="requirements">
44+
45+
<li>create class instance with defualt settings</li>
46+
47+
<li>create class instance with specified baud rate</li>
48+
49+
<li>create class instance with specified baud rate and message id type</li>
50+
51+
<li>report version information</li>
52+
53+
<li>send CAN message</li>
54+
55+
<li>receive CAN message</li>
56+
57+
<li>send raise exception when trying to send non-PcanMessage object</li>
58+
59+
</ul>
60+
</div>
61+
62+
<div class="specification">
63+
Pcan Hardware should:
64+
<ul class="requirements">
65+
66+
<li>create class instance with defualt settings</li>
67+
68+
<li>create class instance with specified baud rate</li>
69+
70+
<li>create class instance with specified baud rate and message id type</li>
71+
72+
<li>report version information</li>
73+
74+
<li>send CAN message</li>
75+
76+
<li>receive CAN message</li>
77+
78+
<li>raise exception when trying to send non-PcanMessage object</li>
79+
80+
</ul>
81+
</div>
82+
83+
<div class="specification">
84+
Pcan Message Builder should:
85+
<ul class="requirements">
86+
87+
<li>create CAN message object</li>
88+
89+
<li>derive from CanMessage</li>
90+
91+
<li>create zero length message with all fields initialized to zero as default</li>
92+
93+
<li>have method to create custom bit accessors</li>
94+
95+
<li>throw exception when trying to define bit before specifying length</li>
96+
97+
<li>throw exception when trying to define bit outside of payload bounds</li>
98+
99+
<li>not throw exception when bit defined within message payload</li>
100+
101+
<li>create custom bit accessor methods</li>
102+
103+
<li>get and set bit defined by custom bit definition for bit zero</li>
104+
105+
<li>get and set bit defined by custom bit definition for other bits</li>
106+
107+
<li>accept 0/1 for bit value but report true/false</li>
108+
109+
<li>raise exception upon invalid value being specified for custom bit</li>
110+
111+
<li>have method to create custom field accessors</li>
112+
113+
<li>throw exception when trying to define field before specifying length</li>
114+
115+
<li>throw exception when trying to define field starting outside of payload bounds</li>
116+
117+
<li>not throw exception when defining a field starting and ending within payload bounds</li>
118+
119+
<li>throw exception when trying to define field starting in message payload but extending beyond</li>
120+
121+
<li>create custom field accessor methods</li>
122+
123+
<li>get custom field contents from payload appropriately when passed valid index</li>
124+
125+
<li>set custom field contents in payload appropriately when passed valid value</li>
126+
127+
<li>report field set with custom accessor as assigned</li>
128+
129+
<li>support field overlapping byte boundary</li>
130+
131+
</ul>
132+
</div>
133+
134+
<div class="specification">
135+
Pcan Message should:
136+
<ul class="requirements">
137+
138+
<li>create CAN message object</li>
139+
140+
<li>initialize structure elements to zero</li>
141+
142+
<li>report CAN ID type</li>
143+
144+
<li>set CAN ID type</li>
145+
146+
<li>raise exception upon invalid value passed to set_type</li>
147+
148+
<li>implement get ID</li>
149+
150+
<li>implement set ID</li>
151+
152+
<li>return id set with set_id from get_id</li>
153+
154+
<li>not raise exception upon valid CAN message ID</li>
155+
156+
<li>raise exception upon invalid CAN message ID</li>
157+
158+
<li>implement get DATA[]</li>
159+
160+
<li>implement set DATA[]</li>
161+
162+
<li>raise exception upon invalid message data type (non-array) passed to set_data</li>
163+
164+
<li>raise exception upon invalid array length being passed to set_data</li>
165+
166+
<li>raise exception upon invalid byte value being passed to set_data</li>
167+
168+
<li>return data set with set_data from get_data</li>
169+
170+
<li>format structure into a string</li>
171+
172+
<li>format structure into a string as raw hex byte values</li>
173+
174+
</ul>
175+
</div>
176+
177+
<div class="specification">
178+
Speed From Vmc New should:
179+
<ul class="requirements">
180+
181+
<li>initialize all values appropriately</li>
182+
183+
<li>report formatted message</li>
184+
185+
<li>implement data bit field</li>
186+
187+
<li>implement dir bit field</li>
188+
189+
</ul>
190+
</div>
191+
192+
</body>
193+
</html>

doc/can2spec.pdf

335 KB
Binary file not shown.

0 commit comments

Comments
 (0)