Added -p to control the HTTP relay port

bug/bundler_fix
Craig Smith 2017-01-31 19:24:45 -08:00
parent 2c57b1f5ed
commit 2d183051f7
1 changed files with 16 additions and 0 deletions

View File

@ -70,6 +70,10 @@ module ELM327HWBridgeRelay
# @return [Integer] Stop bit
attr_accessor :serial_stop_bits
# @!attribute server_port
# @return [Integer] HTTP Relay server port
attr_accessor :server_port
def initialize(info={})
# Set some defaults
self.serial_port = "/dev/ttyUSB0"
@ -81,6 +85,12 @@ module ELM327HWBridgeRelay
exit
end
if @opts.has_key? :server_port
self.server_port = @opts[:server_port]
else
self.server_port = 8080
end
super(update_info(info,
'Name' => 'ELM327/STN1100 HWBridge Relay Server',
'Description' => %q{
@ -100,6 +110,7 @@ module ELM327HWBridgeRelay
'DefaultAction' => 'WebServer',
'DefaultOptions' =>
{
'SRVPORT' => self.server_port,
'URIPATH' => "/"
}))
self.serial_port = @opts[:serial] if @opts.has_key? :serial
@ -369,6 +380,11 @@ module ELM327HWBridgeRelay
options[:serial] = v
end
opt.on('-p', '--port <server_port>',
"(Optional) Sets the listening HTTP server port (Default=8080)") do |v|
options[:server_port] = v
end
opt.on_tail('-h', '--help', 'Show this message') do
$stdout.puts opt
exit