phaserunner 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rdoc_options +23 -0
- data/CODE-OF-CONDUCT.md +74 -0
- data/README.md +136 -0
- data/lib/phaserunner/modbus.rb +26 -21
- data/lib/phaserunner/version.rb +1 -1
- data/phaserunner.gemspec +2 -2
- metadata +7 -6
- data/README.rdoc +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2f46afec661bbb08bb41df2e8e68328fde4dc81
|
4
|
+
data.tar.gz: c3510f359bd9f0056cd60f952ae5034c8ba986f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8b871c2747b949df465c823aa289e76bf33b941bea4833b8d1b503016bc10ddafeb3164b94e328c483437a66bac426300f02de424d1cb30dc1638cca68869a
|
7
|
+
data.tar.gz: a23c73c8500f3d30cec1708264629376d06ac14508a7c57f2bfcc0503004abc7ed8a4f5810ad5c296fd60cc1d76b888a2172863e19b7e2222ef57a2e478e5de7
|
data/.rdoc_options
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
--- !ruby/object:RDoc::Options
|
2
|
+
encoding: UTF-8
|
3
|
+
static_path: []
|
4
|
+
rdoc_include:
|
5
|
+
- "."
|
6
|
+
- "/Users/rberger/Documents/Trike/bike-pi/phaserunner"
|
7
|
+
charset: UTF-8
|
8
|
+
exclude:
|
9
|
+
hyperlink_all: false
|
10
|
+
line_numbers: false
|
11
|
+
locale:
|
12
|
+
locale_dir: locale
|
13
|
+
locale_name:
|
14
|
+
main_page:
|
15
|
+
markup: markdown
|
16
|
+
output_decoration: true
|
17
|
+
page_dir:
|
18
|
+
show_hash: false
|
19
|
+
tab_width: 8
|
20
|
+
template_stylesheets: []
|
21
|
+
title:
|
22
|
+
visibility: :protected
|
23
|
+
webcvs:
|
data/CODE-OF-CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
education, socio-economic status, nationality, personal appearance, race,
|
10
|
+
religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at _rberger at ibd dot com_. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
data/README.md
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# phaserunner
|
2
|
+
|
3
|
+
Read values from the Grin PhaseRunner Controller for logging
|
4
|
+
|
5
|
+
[](https://badge.fury.io/rb/phaserunner)
|
6
|
+
|
7
|
+
## Getting Started
|
8
|
+
|
9
|
+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
|
10
|
+
|
11
|
+
### Prerequisites
|
12
|
+
|
13
|
+
* Ruby ~2.4 or ~2.5
|
14
|
+
* Bundler
|
15
|
+
|
16
|
+
Bundler / Gemspec automatically pulls in all the dependencies
|
17
|
+
|
18
|
+
### Installing for doing development
|
19
|
+
|
20
|
+
The usual Ruby install from github
|
21
|
+
|
22
|
+
```
|
23
|
+
git clone git@github.com:rberger/phaserunner.git
|
24
|
+
cd phaserunner
|
25
|
+
bundle install
|
26
|
+
```
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
|
30
|
+
To get help:
|
31
|
+
|
32
|
+
```
|
33
|
+
bundle exec exe/phaserunner help
|
34
|
+
NAME
|
35
|
+
phaserunner - Read values from the Grin PhaseRunner Controller primarily for logging
|
36
|
+
|
37
|
+
SYNOPSIS
|
38
|
+
phaserunner [global options] command [command options] [arguments...]
|
39
|
+
|
40
|
+
VERSION
|
41
|
+
0.2.0
|
42
|
+
|
43
|
+
GLOBAL OPTIONS
|
44
|
+
-t, --tty=arg - Serial (USB) device (default: /dev/ttyUSB0)
|
45
|
+
-b, --baudrate=arg - Serial port baudrate (default: 115200)
|
46
|
+
-s, --slave_id=arg - Modbus slave ID (default: 1)
|
47
|
+
-d, --dictionary_file=arg - Path to json file that contains Grin Modbus Dictionary (default:
|
48
|
+
/Users/rberger/.rvm/gems/ruby-2.4.1/gems/asi_bod-0.1.5/BODm.json)
|
49
|
+
-l, --loop_count=arg - Loop the command n times (default: forever)
|
50
|
+
--version - Display the program version
|
51
|
+
-q, --[no-]quiet - Do not output to stdout
|
52
|
+
--help - Show this message
|
53
|
+
|
54
|
+
COMMANDS
|
55
|
+
help - Shows a list of commands or help for one command
|
56
|
+
read_register - Read a single or multiple adjacent registers from and address
|
57
|
+
log - Logs interesting Phaserunner registers to stdout and file
|
58
|
+
```
|
59
|
+
|
60
|
+
### Phaserunner Registers logged
|
61
|
+
|
62
|
+
At this time the scaling factors are __NOT__ applied to the log output.
|
63
|
+
|
64
|
+
|Name|Index|Desc|Scale|Units|
|
65
|
+
|---|---|---|---|---|
|
66
|
+
|Timestamp | | ISO 8601 Timestamp| 1 | Time |
|
67
|
+
|Faults| 258 | Faults Bitmap|1|Bitmap
|
68
|
+
|Controller Temperature|259|Base plate temperature|1|deg Celsius|
|
69
|
+
|Vehicle Speed|260|Calculated vehicle speed|256|Km/hour|
|
70
|
+
|Motor Temperature|261|Motor temperature |1|deg Celsius|
|
71
|
+
|Motor Current|262|Motor peak current |32|Amps|
|
72
|
+
|Motor RPM|263|Motor speed |1|RPM|
|
73
|
+
|Motor Speed|264|Motor speed|40.96|% of rated rpm|
|
74
|
+
|Battery Voltage|265|Measured battery voltage|32|Volts|
|
75
|
+
|Battery Current|266|Measured battery amperage|32|Amps|
|
76
|
+
|Battery State of Charge|267|Remaining battery capacity|32|%|
|
77
|
+
|Battery Power|268|Calculated battery output power|1|Watts|
|
78
|
+
|Last Fault|269|Last Fault Bitmap|1|Bitmap|
|
79
|
+
|Throttle Voltage|270|Filtered throttle voltage|4096|Volts|
|
80
|
+
|Brake 1 Voltage|271|Filtered brake 1 voltage|4096|Volts|
|
81
|
+
|Brake 2 Voltage|272|Filtered brake 2 voltage|4096|Volts|
|
82
|
+
|Raw Controller Temperature Sensor Voltage|273|Unfiltered controller temperature sensor voltage|4096|Volts|
|
83
|
+
|Digital Inputs|276|Digital Inputs Bitmap|1|Bitmap|
|
84
|
+
|Warnings|277|Warnings Bitmap|1|Bitmap|
|
85
|
+
|Phase A Current|282|Measured motor phase A current|32|Amps|
|
86
|
+
|Phase B Current|283|Calculated motor phase B current|32|Amps|
|
87
|
+
|Phase C Current|284|Measured motor phase C current|32|Amps|
|
88
|
+
|Phase A Voltage|285|Measured instantaneous motor phase A voltage|32|Volts|
|
89
|
+
|Phase B Voltage|286|Measured instantaneous motor phase B voltage|32|Volts|
|
90
|
+
|Phase C Voltage|287|Measured instantaneous motor phase C voltage|32|Volts|
|
91
|
+
|Motor Input Power|334|Motor input power in Watts|1|W|
|
92
|
+
|Torque Command|335|Requested motor torque from sensors before rate limiting|4096|pu|
|
93
|
+
|Torque Reference|336|Requested motor torque after rate limiting|4096|pu|
|
94
|
+
|Speed (Ref/Limit) Command|337|Speed limit in local mode|4096|pu|
|
95
|
+
|
96
|
+
## Running the tests
|
97
|
+
|
98
|
+
Unfortunately there are no real tests (yet, Pull Requests Welcome!)
|
99
|
+
|
100
|
+
## Deployment
|
101
|
+
|
102
|
+
Deploy as usual. If you are not doing it from a git clone just want to install from Rubygems:
|
103
|
+
|
104
|
+
```
|
105
|
+
gem install phaserunner
|
106
|
+
```
|
107
|
+
|
108
|
+
## Built With
|
109
|
+
|
110
|
+
* [Ruby](https://www.ruby-lang.org/) - Language
|
111
|
+
* [Bundler](http://bundler.io) - Package / Dependency Management
|
112
|
+
* [asi_bod](https://rubygems.org/gems/asi_bod) - Grin Phaserunner / [Accelerated System](http://accelerated-systems.com) Register Defs
|
113
|
+
* [Grin Tech Phaserunner](http://www.ebikes.ca/product-info/phaserunner.html) - Controller were interfacing to
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rberger/rmodbus_cli.
|
118
|
+
|
119
|
+
|
120
|
+
### Code of Conduct in Contriubing
|
121
|
+
|
122
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
|
123
|
+
|
124
|
+
## Versioning
|
125
|
+
|
126
|
+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/rberger/phaserunner/tags).
|
127
|
+
|
128
|
+
## Authors
|
129
|
+
|
130
|
+
* **[Robert Berger](https://github.com/rberger)**
|
131
|
+
|
132
|
+
## License and Copyright
|
133
|
+
|
134
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE.txt) file for details
|
135
|
+
|
136
|
+
* Copyright (c) 2018 Robert J. Berger
|
data/lib/phaserunner/modbus.rb
CHANGED
@@ -6,11 +6,21 @@ module Phaserunner
|
|
6
6
|
# Methods for communicating with the Modbus interface to the Phaserunner
|
7
7
|
class Modbus
|
8
8
|
|
9
|
+
# Struct to represent a run length encode set of registers
|
10
|
+
RegistersRunLength = Struct.new(:start, :count)
|
11
|
+
|
9
12
|
# Returns the path to the default BODm.json file
|
10
13
|
def self.default_file_path
|
11
14
|
AsiBod::Bod.default_file_path
|
12
15
|
end
|
13
16
|
|
17
|
+
# Build up an array of RegistersRunLength structs that represent the ranges
|
18
|
+
# of registers to log
|
19
|
+
register_list = [RegistersRunLength.new(258, 18)]
|
20
|
+
register_list << RegistersRunLength.new(276, 2)
|
21
|
+
register_list << RegistersRunLength.new(282, 6)
|
22
|
+
register_list << RegistersRunLength.new(334, 4)
|
23
|
+
|
14
24
|
DEFAULTS = {
|
15
25
|
tty: '/dev/ttyUSB0',
|
16
26
|
baudrate: 115200,
|
@@ -18,6 +28,7 @@ module Phaserunner
|
|
18
28
|
dictionary_file: default_file_path,
|
19
29
|
loop_count: :forever,
|
20
30
|
quiet: false,
|
31
|
+
register_list: register_list,
|
21
32
|
registers_start_address: 258,
|
22
33
|
registers_count: 15,
|
23
34
|
registers_misc: [276, 277, 334]
|
@@ -31,11 +42,10 @@ module Phaserunner
|
|
31
42
|
attr_reader :quiet
|
32
43
|
|
33
44
|
# The registers of interest for logging
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
attr_reader :registers_misc
|
45
|
+
# @paramds [Array<RegistersRunLength>] register_list
|
46
|
+
# @option register_list [Integer] :start Starting register Index
|
47
|
+
# @option register_list [Integer] :count Number of registers to return
|
48
|
+
attr_reader :register_list
|
39
49
|
|
40
50
|
# Contains the Grin Phaesrunner Modbus Dictionary
|
41
51
|
# @params [Hash<Integer, Hash>] dict The Dictionary with a key for each register address
|
@@ -101,27 +111,22 @@ module Phaserunner
|
|
101
111
|
end
|
102
112
|
end
|
103
113
|
|
104
|
-
# More optimized data fetch. Gets an address range
|
105
|
-
# @param
|
106
|
-
# @param count [Integer] Count of addresses in range. Optional, has a default
|
107
|
-
# @param misc_addresses [Array<Integer>] List of misc individual addresses. Optional, has a default
|
114
|
+
# More optimized data fetch. Gets an array of address range structs
|
115
|
+
# @param register_list [Array<RegistersRunLength] Register ranges to log. Optional, has a default
|
108
116
|
# @return [Array<Integer>] List of the register values in the order requested
|
109
|
-
def bulk_log_data(
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
def bulk_log_data(registers = register_list)
|
118
|
+
registers.map do |reg|
|
119
|
+
read_raw_range(reg.start, reg.count)
|
120
|
+
end
|
113
121
|
end
|
114
122
|
|
115
123
|
# Get the headers for the bulk_log data
|
116
|
-
# @param
|
117
|
-
# @param count [Integer] Count of addresses in range. Optional, has a default
|
118
|
-
# @param misc_addresses [Array<Integer>] List of misc individual addresses. Optional, has a default
|
124
|
+
# @param register_list [Array<RegistersRunLength] Register ranges to log. Optional, has a default
|
119
125
|
# @return [Array<String>] Array of the headers
|
120
|
-
def bulk_log_header(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
bulk_addresses_header(misc_addresses)
|
126
|
+
def bulk_log_header(registers = register_list)
|
127
|
+
registers.map do |reg|
|
128
|
+
range_address_header(reg.start, reg.count)
|
129
|
+
end
|
125
130
|
end
|
126
131
|
end
|
127
132
|
end
|
data/lib/phaserunner/version.rb
CHANGED
data/phaserunner.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = '~> 2'
|
24
24
|
|
25
25
|
spec.has_rdoc = true
|
26
|
-
spec.extra_rdoc_files = ['README.
|
27
|
-
spec.rdoc_options << '--title' << 'phaserunner' << '--main' << 'README.
|
26
|
+
spec.extra_rdoc_files = ['README.md']
|
27
|
+
spec.rdoc_options << '--title' << 'phaserunner' << '--main' << 'README.md' << '-ri'
|
28
28
|
|
29
29
|
spec.add_runtime_dependency 'gli', '~> 2.17'
|
30
30
|
spec.add_runtime_dependency 'rmodbus', '~> 1.3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phaserunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -158,13 +158,14 @@ executables:
|
|
158
158
|
- phaserunner
|
159
159
|
extensions: []
|
160
160
|
extra_rdoc_files:
|
161
|
-
- README.
|
162
|
-
- phaserunner.rdoc
|
161
|
+
- README.md
|
163
162
|
files:
|
164
163
|
- ".gitignore"
|
164
|
+
- ".rdoc_options"
|
165
|
+
- CODE-OF-CONDUCT.md
|
165
166
|
- Gemfile
|
166
167
|
- LICENSE.txt
|
167
|
-
- README.
|
168
|
+
- README.md
|
168
169
|
- Rakefile
|
169
170
|
- exe/phaserunner
|
170
171
|
- lib/phaserunner.rb
|
@@ -184,7 +185,7 @@ rdoc_options:
|
|
184
185
|
- "--title"
|
185
186
|
- phaserunner
|
186
187
|
- "--main"
|
187
|
-
- README.
|
188
|
+
- README.md
|
188
189
|
- "-ri"
|
189
190
|
require_paths:
|
190
191
|
- lib
|
data/README.rdoc
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
== NAME
|
2
|
-
phaserunner - Read values from the Grin PhaseRunner Controller for logging
|
3
|
-
|
4
|
-
{<img src="https://badge.fury.io/rb/phaserunner.svg" alt="Gem Version" />}[https://badge.fury.io/rb/phaserunner]
|
5
|
-
|
6
|
-
== SYNOPSIS
|
7
|
-
phaserunner [global options] command [command options] [arguments...]
|
8
|
-
phaserunner [global options] log [command options]
|
9
|
-
|
10
|
-
== VERSION
|
11
|
-
0.1.0
|
12
|
-
|
13
|
-
== GLOBAL OPTIONS
|
14
|
-
-t, --tty=arg - Serial (USB) device (default: /dev/ttyUSB0)
|
15
|
-
-b, --baudrate=arg - Serial port baudrate (default: 115200)
|
16
|
-
-s, --slave_id=arg - Modbus slave ID (default: 1)
|
17
|
-
-d, --dictionary_file=arg - Path to json file that contains Grin Modbus Dictionary (default: /Users/rberger/.rvm/gems/ruby-2.4.1/gems/asi_bod-0.1.4/BODm.json)
|
18
|
-
-l, --loop=arg - Loop the command n times (default: 10)
|
19
|
-
--version - Display the program version
|
20
|
-
--help - Show this message
|
21
|
-
|
22
|
-
== COMMANDS
|
23
|
-
help - Shows a list of commands or help for one command
|
24
|
-
read_register - Read a single or multiple adjacent registers from and address
|
25
|
-
log - Logs a range plus bulk sparse set of registers with multiple addresses to stdout and file
|
26
|
-
|
27
|
-
=== Attributes that are Logged
|
28
|
-
|
29
|
-
* Timestamp
|
30
|
-
* Phaserunner Faults ()
|
31
|
-
* Phaserunner Controller Temperature (deg Celsius)
|
32
|
-
* Phaserunner Vehicle Speed (Km/hour)
|
33
|
-
* Phaserunner Motor Temperature (deg Celsius)
|
34
|
-
* Phaserunner Motor Current (Amps)
|
35
|
-
* Phaserunner Motor RPM (RPM)
|
36
|
-
* Phaserunner Motor Speed (% of rated rpm)
|
37
|
-
* Phaserunner Battery Voltage (Volts)
|
38
|
-
* Phaserunner Battery Current (Amps)
|
39
|
-
* Phaserunner Battery State of Charge (%)
|
40
|
-
* Phaserunner Battery Power (Watts)
|
41
|
-
* Phaserunner Last Fault ()
|
42
|
-
* Phaserunner Warnings ()
|
43
|
-
* Phaserunner Motor Input Power (W)
|
44
|
-
|
45
|
-
== License and Copyright
|
46
|
-
|
47
|
-
* Copyright (c) 2018 Robert J. Berger
|
48
|
-
* License: MIT
|
49
|
-
|
50
|
-
:include:phaserunner.rdoc
|