procon_bypass_man 0.1.20.1 → 0.1.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +3 -3
- data/docs/getting_started.md +30 -2
- data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +10 -0
- data/lib/procon_bypass_man/background.rb +1 -0
- data/lib/procon_bypass_man/bypass/bypass_mode.rb +8 -0
- data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -21
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +6 -0
- data/lib/procon_bypass_man/device_connector.rb +6 -9
- data/lib/procon_bypass_man/device_procon_finder.rb +0 -20
- data/lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb +4 -0
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb +4 -0
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb +4 -0
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb +4 -0
- data/lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb +4 -0
- data/lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb +4 -0
- data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +4 -1
- data/lib/procon_bypass_man/usb_device_controller.rb +53 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/pbm_job_client.rb +13 -3
- data/lib/procon_bypass_man.rb +4 -6
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +10 -2
- data/project_template/systemd_units/pbm.service +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b74bbbe94f6c14a8e8cfbabb306e7229cab042ea9d5fae34ddfe134df0911528
|
4
|
+
data.tar.gz: b42ea9a421add0181270f5c957c9d10079598871634f5f20da8e7101349c981e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df4ce5c1fc721fe5aa06236a0909c143f49b3616b4c02ca4202f0de7519206a22f5de864e58e50390e47dfe631475cdf1a04c3b4e99ed492913825cf0315039f
|
7
|
+
data.tar.gz: 8fed8f7f1181bfb51b6b214984af09b0bc1d8b83573174fa276e97e857a0569affb14148aeabf52f0ba3b90cc30083548c191346649e8c534832fcba3b6aee25
|
data/.circleci/config.yml
CHANGED
@@ -34,6 +34,19 @@ commands: &commands
|
|
34
34
|
- vendor/bundle
|
35
35
|
|
36
36
|
jobs:
|
37
|
+
syntax_check:
|
38
|
+
parameters:
|
39
|
+
ruby-version:
|
40
|
+
type: string
|
41
|
+
executor:
|
42
|
+
name: ruby
|
43
|
+
tag: << parameters.ruby-version >>
|
44
|
+
steps:
|
45
|
+
- checkout
|
46
|
+
- run: ruby -cw project_template/app.rb
|
47
|
+
- run: ruby -cw project_template/web.rb
|
48
|
+
- run: ruby -ryaml -e 'puts YAML.load_file("./project_template/setting.yml")["setting"]' > /tmp/content_of_setting.rb && ruby -cw /tmp/content_of_setting.rb
|
49
|
+
|
37
50
|
bundle_install:
|
38
51
|
parameters:
|
39
52
|
ruby-version:
|
@@ -79,6 +92,14 @@ jobs:
|
|
79
92
|
- run: bundle exec rspec
|
80
93
|
|
81
94
|
build_jobs: &build_jobs
|
95
|
+
- syntax_check:
|
96
|
+
matrix:
|
97
|
+
parameters:
|
98
|
+
ruby-version:
|
99
|
+
- "2.7"
|
100
|
+
- "3.0.1"
|
101
|
+
- "3.0.2"
|
102
|
+
- "3.1.1"
|
82
103
|
- bundle_install:
|
83
104
|
matrix:
|
84
105
|
parameters:
|
@@ -86,7 +107,7 @@ build_jobs: &build_jobs
|
|
86
107
|
- "2.7"
|
87
108
|
- "3.0.1"
|
88
109
|
- "3.0.2"
|
89
|
-
- "3.1.
|
110
|
+
- "3.1.1"
|
90
111
|
- lint:
|
91
112
|
matrix:
|
92
113
|
parameters:
|
@@ -94,7 +115,7 @@ build_jobs: &build_jobs
|
|
94
115
|
- "2.7"
|
95
116
|
- "3.0.1"
|
96
117
|
- "3.0.2"
|
97
|
-
- "3.1.
|
118
|
+
- "3.1.1"
|
98
119
|
requires:
|
99
120
|
- bundle_install
|
100
121
|
- type_check:
|
@@ -104,7 +125,7 @@ build_jobs: &build_jobs
|
|
104
125
|
- "2.7"
|
105
126
|
# - "3.0.1" # たまにSEGVするので
|
106
127
|
- "3.0.2"
|
107
|
-
- "3.1.
|
128
|
+
- "3.1.1"
|
108
129
|
requires:
|
109
130
|
- bundle_install
|
110
131
|
- rspec:
|
@@ -114,7 +135,7 @@ build_jobs: &build_jobs
|
|
114
135
|
- "2.7"
|
115
136
|
- "3.0.1"
|
116
137
|
- "3.0.2"
|
117
|
-
- "3.1.
|
138
|
+
- "3.1.1"
|
118
139
|
requires:
|
119
140
|
- bundle_install
|
120
141
|
workflows:
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
## [0.1.20.2] - 2022-2-18
|
2
|
+
- 起動時にreniceするようにしました
|
3
|
+
- 起動時にusb gadgetモードを有効にするようにしました
|
4
|
+
- pbm-cloudからprocon_bypass_manをアップグレードできるようになりました
|
5
|
+
|
1
6
|
## [0.1.20.1] - 2022-02-13
|
2
|
-
- Switch
|
7
|
+
- Switchからプロコンへ送信するバイパスのインターバルを設定できるようにしました(切断・フリーズ対策)
|
3
8
|
|
4
9
|
## [0.1.20] - 2022-02-13
|
5
10
|
- pbm-cloudから再起動・設定ファイルの適用指示があったときにackイベントを返すようになりました
|
6
11
|
- 起動オプションにnever_exit_accidentallyを追加しました。これを有効にすると想定外のエラーが起きたときにプロセスが停止しなくなります。デフォルトで無効です。
|
7
12
|
- pbm-cloudから設定ファイルの適用に失敗したときにファイルへの書き込みをしないようになりました
|
8
13
|
- まだadd_procon_gadget.shを実行していないときに、接続処理をする前に処理を停止するようにしました
|
9
|
-
-
|
14
|
+
- ラズパイに複数のUSBデバイスが刺さっていてもプロコンのデバイスを選択できるようにしました
|
10
15
|
- Switchからプロコンへ送信するバイパスを動かし続けるようにしました(切断対策)
|
11
16
|
|
12
17
|
## [0.1.19.1] - 2022-02-09
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.1.20.
|
4
|
+
procon_bypass_man (0.1.20.2)
|
5
5
|
action_cable_client
|
6
|
-
pbmenv
|
6
|
+
pbmenv (>= 0.1.9)
|
7
7
|
sorted_set
|
8
8
|
|
9
9
|
GEM
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
parallel (1.21.0)
|
37
37
|
parser (3.0.3.2)
|
38
38
|
ast (~> 2.4.1)
|
39
|
-
pbmenv (0.1.
|
39
|
+
pbmenv (0.1.9)
|
40
40
|
pry (0.14.1)
|
41
41
|
coderay (~> 1.1)
|
42
42
|
method_source (~> 1.0)
|
data/docs/getting_started.md
CHANGED
@@ -14,10 +14,9 @@
|
|
14
14
|
* マクロ
|
15
15
|
* 左スティックの感度調整
|
16
16
|
* 設定ファイルの書き方
|
17
|
-
* layer
|
18
17
|
* プラグインの書き方
|
19
18
|
* 設定ファイルの書き方がわからない、エラーが起きるとき
|
20
|
-
* procon_bypass_manのアップグレード方法
|
19
|
+
* [procon_bypass_manのアップグレード方法](#procon_bypass_manのアップグレード方法)
|
21
20
|
* procon_bypass_man_cloudについて
|
22
21
|
|
23
22
|
## はじめに
|
@@ -86,3 +85,32 @@ sudo systemctl enable pbm.service
|
|
86
85
|
pbmenvを使っていない場合は、 https://github.com/splaplapla/procon_bypass_man/blob/master/project_template/systemd_units/pbm.service をダウンロードして、 `systemctl link` をしてください。
|
87
86
|
|
88
87
|
ゲームをやめたくなったらSwitchはそのままスリープに入って問題ないです。このときにRaspberry Piも一緒に電源が切れてしまいますが故障することはありません。
|
88
|
+
|
89
|
+
## レイヤー
|
90
|
+
* 後で書きます
|
91
|
+
|
92
|
+
## モード
|
93
|
+
* 後で書きます
|
94
|
+
|
95
|
+
## マクロ
|
96
|
+
* 後で書きます
|
97
|
+
|
98
|
+
## 左スティックの感度調整
|
99
|
+
* 後で書きます
|
100
|
+
|
101
|
+
## 設定ファイルの書き方
|
102
|
+
* 後で書きます
|
103
|
+
|
104
|
+
## プラグインの書き方
|
105
|
+
* 後で書きます
|
106
|
+
|
107
|
+
## 設定ファイルの書き方がわからない、エラーが起きるとき
|
108
|
+
|
109
|
+
設定部分は、Rubyスクリプトになっているので構文エラーが起きることがあります。
|
110
|
+
discordで質問してみてください。
|
111
|
+
|
112
|
+
## procon_bypass_manのアップグレード方法
|
113
|
+
[/docs/upgrade_pbm.md](/docs/upgrade_pbm.md)
|
114
|
+
|
115
|
+
## procon_bypass_man_cloudについて
|
116
|
+
* 後で書きます
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class ProconBypassMan::ReportCompletedUpgradePbmJob < ProconBypassMan::ReportEventBaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
def self.perform
|
5
|
+
ProconBypassMan::ReportHttpClient.new(
|
6
|
+
path: path,
|
7
|
+
server_pool: server_pool,
|
8
|
+
).post(body: nil, event_type: :completed_upgrade_pbm)
|
9
|
+
end
|
10
|
+
end
|
@@ -12,4 +12,5 @@ require "procon_bypass_man/background/jobs/report_error_reload_config_job"
|
|
12
12
|
require "procon_bypass_man/background/jobs/report_load_config_job"
|
13
13
|
require "procon_bypass_man/background/jobs/report_error_job"
|
14
14
|
require "procon_bypass_man/background/jobs/report_pressed_buttons_job"
|
15
|
+
require "procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job"
|
15
16
|
require "procon_bypass_man/background/jobs/sync_device_stats_job"
|
@@ -3,26 +3,16 @@ class ProconBypassMan::ConnectDeviceCommand
|
|
3
3
|
|
4
4
|
# @return [void]
|
5
5
|
def self.execute!
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
18
|
-
ProconBypassMan.logger.error "デバイスとの通信でタイムアウトが起きて接続ができませんでした。"
|
19
|
-
gadget&.close
|
20
|
-
procon&.close
|
21
|
-
raise ProconBypassMan::EternalConnectionError
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.has_required_files?
|
26
|
-
Dir.exist?("/sys/kernel/config/usb_gadget/procon")
|
6
|
+
gadget, procon = ProconBypassMan::DeviceConnector.connect
|
7
|
+
rescue ProconBypassMan::DeviceConnector::NotFoundProconError => e
|
8
|
+
ProconBypassMan.logger.error e
|
9
|
+
gadget&.close
|
10
|
+
procon&.close
|
11
|
+
raise ProconBypassMan::ConnectDeviceCommand::NotFoundProconError
|
12
|
+
rescue ProconBypassMan::SafeTimeout::Timeout
|
13
|
+
ProconBypassMan.logger.error "デバイスとの通信でタイムアウトが起きて接続ができませんでした。"
|
14
|
+
gadget&.close
|
15
|
+
procon&.close
|
16
|
+
raise ProconBypassMan::EternalConnectionError
|
27
17
|
end
|
28
18
|
end
|
@@ -4,6 +4,7 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
4
4
|
@table = {}
|
5
5
|
@table[:ruby_version] = RUBY_VERSION
|
6
6
|
@table[:pbm_version] = ProconBypassMan::VERSION
|
7
|
+
@table[:pbmenv_version] = Pbmenv::VERSION
|
7
8
|
@table[:pid] = $$
|
8
9
|
@table[:root_path] = ProconBypassMan.root
|
9
10
|
@table[:pid_path] = ProconBypassMan.pid_path
|
@@ -12,6 +13,9 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
12
13
|
@table[:use_pbmenv] = !(!!`which pbmenv`.empty?)
|
13
14
|
@table[:session_id] = ProconBypassMan.session_id
|
14
15
|
@table[:device_id] = ProconBypassMan.device_id
|
16
|
+
@table[:bypass_mode] = ProconBypassMan.config.bypass_mode.to_s
|
17
|
+
@table[:never_exit_accidentally] = ProconBypassMan.config.never_exit_accidentally
|
18
|
+
@table[:uname] = `uname -a`.chomp
|
15
19
|
|
16
20
|
# 開発中のHEADを取りたかったけど、Gem::Specification経由から取得する必要がありそう
|
17
21
|
# build_version = `git rev-parse --short HEAD`.chomp
|
@@ -30,6 +34,7 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
30
34
|
----
|
31
35
|
RUBY_VERSION: #{@table[:ruby_version]}
|
32
36
|
ProconBypassMan::VERSION: #{@table[:pbm_version]}
|
37
|
+
Pbmenv::VERSION: #{@table[:pbmenv_version]}
|
33
38
|
pid: #{@table[:pid]}
|
34
39
|
root: #{@table[:root_path]}
|
35
40
|
pid_path: #{@table[:pid_path]}
|
@@ -38,6 +43,7 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
38
43
|
use_pbmenv: #{@table[:use_pbmenv]}
|
39
44
|
session_id: #{ProconBypassMan.session_id}
|
40
45
|
device_id: #{ProconBypassMan.device_id}
|
46
|
+
bypass_mode: #{ProconBypassMan.config.bypass_mode}
|
41
47
|
----
|
42
48
|
EOF
|
43
49
|
end
|
@@ -61,9 +61,9 @@ class ProconBypassMan::DeviceConnector
|
|
61
61
|
begin
|
62
62
|
timer.throw_if_timeout!
|
63
63
|
data = from_device(item).read_nonblock(64)
|
64
|
-
debug_log_buffer << "read_from(#{item.read_from}): #{data}"
|
64
|
+
debug_log_buffer << "read_from(#{item.read_from}): #{data.unpack("H*")}"
|
65
65
|
rescue IO::EAGAINWaitReadable
|
66
|
-
debug_log_buffer << "read_from(#{item.read_from}): IO::EAGAINWaitReadable"
|
66
|
+
# debug_log_buffer << "read_from(#{item.read_from}): IO::EAGAINWaitReadable"
|
67
67
|
retry
|
68
68
|
end
|
69
69
|
|
@@ -267,6 +267,7 @@ class ProconBypassMan::DeviceConnector
|
|
267
267
|
if @initialized_devices
|
268
268
|
return
|
269
269
|
end
|
270
|
+
ProconBypassMan::UsbDeviceController.init
|
270
271
|
|
271
272
|
if path = ProconBypassMan::DeviceProconFinder.find
|
272
273
|
@procon = File.open(path, "w+b")
|
@@ -276,9 +277,7 @@ class ProconBypassMan::DeviceConnector
|
|
276
277
|
end
|
277
278
|
@gadget = File.open('/dev/hidg0', "w+b")
|
278
279
|
|
279
|
-
|
280
|
-
system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
|
281
|
-
sleep 0.5
|
280
|
+
ProconBypassMan::UsbDeviceController.reset
|
282
281
|
|
283
282
|
@initialized_devices = true
|
284
283
|
|
@@ -290,10 +289,8 @@ class ProconBypassMan::DeviceConnector
|
|
290
289
|
end
|
291
290
|
rescue Errno::ENXIO => e
|
292
291
|
# /dev/hidg0 をopenできないときがある
|
293
|
-
ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIO (No such device or address @ rb_sysopen - /dev/hidg0)が起きました。reset
|
294
|
-
|
295
|
-
system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
|
296
|
-
sleep 0.5
|
292
|
+
ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIO (No such device or address @ rb_sysopen - /dev/hidg0)が起きました。resetします.\n #{e.full_message}")
|
293
|
+
ProconBypassMan::UsbDeviceController.reset
|
297
294
|
retry
|
298
295
|
end
|
299
296
|
end
|
@@ -42,24 +42,4 @@ class ProconBypassMan::DeviceProconFinder
|
|
42
42
|
done
|
43
43
|
SHELL
|
44
44
|
end
|
45
|
-
|
46
|
-
# これいる?
|
47
|
-
def is_available_device?(path)
|
48
|
-
return false if !File.exist?(path)
|
49
|
-
|
50
|
-
system('echo > /sys/kernel/config/usb_gadget/procon/UDC')
|
51
|
-
system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
|
52
|
-
sleep 0.5
|
53
|
-
|
54
|
-
file = File.open(path, "w+")
|
55
|
-
begin
|
56
|
-
file.read_nonblock(64)
|
57
|
-
rescue EOFError
|
58
|
-
file.close
|
59
|
-
return false
|
60
|
-
rescue IO::EAGAINWaitReadable
|
61
|
-
file.close
|
62
|
-
return true
|
63
|
-
end
|
64
|
-
end
|
65
45
|
end
|
@@ -3,6 +3,10 @@ module ProconBypassMan
|
|
3
3
|
module Splatoon2
|
4
4
|
module Mode
|
5
5
|
module Guruguru
|
6
|
+
def self.description
|
7
|
+
'適当に動きます'
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.binaries
|
7
11
|
[ "309481408000362d684658750968f71cfe2c0e51000001480053f71ffedf0d4b000a013d00caf6ecfd4c0d480003011c00000000000000000000000000000000",
|
8
12
|
"30978140800037dd6748687509fdf6adfded0d6d0081005d00eef68dfdef0d6d00830059001bf791fd140e720090005400000000000000000000000000000000",
|
@@ -6,8 +6,11 @@ module ProconBypassMan
|
|
6
6
|
require "pbmenv"
|
7
7
|
ProconBypassMan.logger.info "execute ChangePbmVersionAction!"
|
8
8
|
pbm_version = args["pbm_version"] or raise(ProconBypassMan::RemotePbmAction::NeedPbmVersionError, "pbm_versionが必要です, #{args.inspect}")
|
9
|
-
Pbmenv.
|
9
|
+
Pbmenv.uninstall(pbm_version) # 途中でシャットダウンしてしまった、とか状態が途中の状態かもしれないので一旦消す
|
10
|
+
Pbmenv.install(pbm_version, enable_pbm_cloud: true)
|
10
11
|
Pbmenv.use(pbm_version)
|
12
|
+
ProconBypassMan.logger.info "#{pbm_version}へアップグレードしました"
|
13
|
+
ProconBypassMan::ReportCompletedUpgradePbmJob.perform
|
11
14
|
`reboot` # symlinkの参照先が変わるのでrebootする必要がある
|
12
15
|
end
|
13
16
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class ProconBypassMan::UsbDeviceController
|
2
|
+
class << self
|
3
|
+
def reset
|
4
|
+
system('echo > /sys/kernel/config/usb_gadget/procon/UDC')
|
5
|
+
system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
|
6
|
+
sleep 0.5
|
7
|
+
end
|
8
|
+
|
9
|
+
def init
|
10
|
+
return if initialized?
|
11
|
+
|
12
|
+
shell = <<~EOH
|
13
|
+
#!/bin/bash
|
14
|
+
|
15
|
+
cd /sys/kernel/config/usb_gadget/
|
16
|
+
mkdir -p procon
|
17
|
+
cd procon
|
18
|
+
echo 0x057e > idVendor
|
19
|
+
echo 0x2009 > idProduct
|
20
|
+
echo 0x0200 > bcdDevice
|
21
|
+
echo 0x0200 > bcdUSB
|
22
|
+
echo 0x00 > bDeviceClass
|
23
|
+
echo 0x00 > bDeviceSubClass
|
24
|
+
echo 0x00 > bDeviceProtocol
|
25
|
+
|
26
|
+
mkdir -p strings/0x409
|
27
|
+
echo "000000000001" > strings/0x409/serialnumber
|
28
|
+
echo "Nintendo Co., Ltd." > strings/0x409/manufacturer
|
29
|
+
echo "Pro Controller" > strings/0x409/product
|
30
|
+
|
31
|
+
mkdir -p configs/c.1/strings/0x409
|
32
|
+
echo "Nintendo Switch Pro Controller" > configs/c.1/strings/0x409/configuration
|
33
|
+
echo 500 > configs/c.1/MaxPower
|
34
|
+
echo 0xa0 > configs/c.1/bmAttributes
|
35
|
+
|
36
|
+
mkdir -p functions/hid.usb0
|
37
|
+
echo 0 > functions/hid.usb0/protocol
|
38
|
+
echo 0 > functions/hid.usb0/subclass
|
39
|
+
echo 64 > functions/hid.usb0/report_length
|
40
|
+
echo 050115000904A1018530050105091901290A150025017501950A5500650081020509190B290E150025017501950481027501950281030B01000100A1000B300001000B310001000B320001000B35000100150027FFFF0000751095048102C00B39000100150025073500463B0165147504950181020509190F2912150025017501950481027508953481030600FF852109017508953F8103858109027508953F8103850109037508953F9183851009047508953F9183858009057508953F9183858209067508953F9183C0 | xxd -r -ps > functions/hid.usb0/report_desc
|
41
|
+
|
42
|
+
ln -s functions/hid.usb0 configs/c.1/
|
43
|
+
ls /sys/class/udc > UDC
|
44
|
+
EOH
|
45
|
+
|
46
|
+
`bash -c '#{shell}'`
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialized?
|
50
|
+
Dir.exist?("/sys/kernel/config/usb_gadget/procon")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -9,7 +9,8 @@ module ProconBypassMan
|
|
9
9
|
Thread.start do
|
10
10
|
loop do
|
11
11
|
run
|
12
|
-
rescue
|
12
|
+
rescue => e
|
13
|
+
ProconBypassMan.logger.error("websocket client: #{e.full_message}")
|
13
14
|
retry
|
14
15
|
end
|
15
16
|
end
|
@@ -24,14 +25,16 @@ module ProconBypassMan
|
|
24
25
|
)
|
25
26
|
|
26
27
|
client.connected {
|
27
|
-
ProconBypassMan.logger.info('successfully connected in ProconBypassMan::Websocket::PbmJobClient')
|
28
|
+
ProconBypassMan.logger.info('websocket client: successfully connected in ProconBypassMan::Websocket::PbmJobClient')
|
28
29
|
}
|
29
30
|
client.subscribed { |msg|
|
31
|
+
ProconBypassMan.logger.info('websocket client: subscribed')
|
30
32
|
puts({ event: :subscribed, msg: msg })
|
31
33
|
ProconBypassMan::SyncDeviceStatsJob.perform(ProconBypassMan::DeviceStatus.current)
|
32
34
|
}
|
33
35
|
|
34
36
|
client.received do |data|
|
37
|
+
ProconBypassMan.logger.info('websocket client: received!!')
|
35
38
|
ProconBypassMan.logger.info(data)
|
36
39
|
|
37
40
|
dispatch(data: data, client: client)
|
@@ -40,13 +43,20 @@ module ProconBypassMan
|
|
40
43
|
end
|
41
44
|
|
42
45
|
client.disconnected {
|
46
|
+
ProconBypassMan.logger.info('websocket client: disconnected!!')
|
43
47
|
puts :disconnected
|
44
48
|
client.reconnect!
|
45
49
|
sleep 2
|
46
50
|
}
|
47
|
-
client.errored { |msg|
|
51
|
+
client.errored { |msg|
|
52
|
+
ProconBypassMan.logger.error("websocket client: errored!!, #{msg}")
|
53
|
+
puts :errored
|
54
|
+
client.reconnect!
|
55
|
+
sleep 2
|
56
|
+
}
|
48
57
|
client.pinged { |msg|
|
49
58
|
ProconBypassMan.cache.fetch key: 'ws_pinged', expires_in: 10 do
|
59
|
+
ProconBypassMan.logger.info('websocket client: pinged!!')
|
50
60
|
ProconBypassMan.logger.info(msg)
|
51
61
|
end
|
52
62
|
}
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -8,6 +8,8 @@ require 'em/pure_ruby'
|
|
8
8
|
require "action_cable_client"
|
9
9
|
require "ext/em_pure_ruby"
|
10
10
|
require "ext/module"
|
11
|
+
require "resolv-replace"
|
12
|
+
require "pbmenv"
|
11
13
|
|
12
14
|
require_relative "procon_bypass_man/version"
|
13
15
|
require_relative "procon_bypass_man/remote_pbm_action"
|
@@ -31,6 +33,7 @@ require_relative "procon_bypass_man/never_exit_accidentally"
|
|
31
33
|
require_relative "procon_bypass_man/device_connector"
|
32
34
|
require_relative "procon_bypass_man/device_procon_finder"
|
33
35
|
require_relative "procon_bypass_man/device_status"
|
36
|
+
require_relative "procon_bypass_man/usb_device_controller"
|
34
37
|
require_relative "procon_bypass_man/runner"
|
35
38
|
require_relative "procon_bypass_man/processor"
|
36
39
|
require_relative "procon_bypass_man/configuration"
|
@@ -54,7 +57,6 @@ module ProconBypassMan
|
|
54
57
|
|
55
58
|
class CouldNotLoadConfigError < StandardError; end
|
56
59
|
class ConnectionError < StandardError; end
|
57
|
-
class NotFoundRequiredFilesError < StandardError; end
|
58
60
|
class FirstConnectionError < ConnectionError; end
|
59
61
|
class EternalConnectionError < ConnectionError; end
|
60
62
|
|
@@ -71,11 +73,6 @@ module ProconBypassMan
|
|
71
73
|
Runner.new(gadget: gadget, procon: procon).run # ここでblockingする
|
72
74
|
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
73
75
|
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
74
|
-
rescue ProconBypassMan::NotFoundRequiredFilesError
|
75
|
-
ProconBypassMan::SendErrorCommand.execute(error: "/sys/kernel/config/usb_gadget/proconディレクトリがありませんでした。処理を終了します。")
|
76
|
-
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
77
|
-
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
78
|
-
exit 1 # 前提条件を満たしていないので絶対に落とす
|
79
76
|
rescue ProconBypassMan::CouldNotLoadConfigError
|
80
77
|
ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
|
81
78
|
ProconBypassMan::DeviceStatus.change_to_setting_syntax_error_and_shutdown!
|
@@ -127,6 +124,7 @@ module ProconBypassMan
|
|
127
124
|
def self.initialize_pbm
|
128
125
|
ProconBypassMan::WriteDeviceIdCommand.execute
|
129
126
|
ProconBypassMan::WriteSessionIdCommand.execute
|
127
|
+
system("renice -n -20 -p #{$$}")
|
130
128
|
File.write(pid_path, $$)
|
131
129
|
ProconBypassMan::DeviceStatus.change_to_running!
|
132
130
|
end
|
data/procon_bypass_man.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
# Uncomment to register a new dependency of your gem
|
31
|
-
spec.add_dependency "pbmenv"
|
31
|
+
spec.add_dependency "pbmenv", ">= 0.1.9" # Pbmenv.installでのenable_pbm_cloudに依存している
|
32
32
|
spec.add_dependency "action_cable_client"
|
33
33
|
spec.add_dependency "sorted_set"
|
34
34
|
|
data/project_template/app.rb
CHANGED
@@ -5,20 +5,28 @@ require 'bundler/inline'
|
|
5
5
|
gemfile do
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
-
gem 'procon_bypass_man', '0.1.20.
|
8
|
+
gem 'procon_bypass_man', '0.1.20.2'
|
9
9
|
end
|
10
10
|
|
11
11
|
ProconBypassMan.configure do |config|
|
12
12
|
config.root = File.expand_path(__dir__)
|
13
13
|
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
14
14
|
config.logger.level = :debug
|
15
|
+
|
16
|
+
# バイパスするログを全部app.logに流すか
|
17
|
+
config.verbose_bypass_log = false
|
18
|
+
|
15
19
|
# webからProconBypassManを操作できるwebサービス
|
16
20
|
# config.api_servers = ['https://pbm-cloud.herokuapp.com']
|
21
|
+
|
22
|
+
# エラーが起きたらerror.logに書き込みます
|
17
23
|
config.enable_critical_error_logging = true
|
24
|
+
|
18
25
|
# pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
|
19
26
|
config.never_exit_accidentally = true
|
27
|
+
|
20
28
|
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値は大きくしてください
|
21
|
-
config.bypass_mode = { mode: :normal, gadget_to_procon_interval:
|
29
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 5 }
|
22
30
|
end
|
23
31
|
|
24
32
|
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.20.
|
4
|
+
version: 0.1.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: action_cable_client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
|
97
97
|
- lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
|
98
98
|
- lib/procon_bypass_man/background/jobs/report_boot_job.rb
|
99
|
+
- lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
|
99
100
|
- lib/procon_bypass_man/background/jobs/report_error_job.rb
|
100
101
|
- lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
|
101
102
|
- lib/procon_bypass_man/background/jobs/report_event_base_job.rb
|
@@ -179,6 +180,7 @@ files:
|
|
179
180
|
- lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
|
180
181
|
- lib/procon_bypass_man/support/uptime.rb
|
181
182
|
- lib/procon_bypass_man/support/yaml_writer.rb
|
183
|
+
- lib/procon_bypass_man/usb_device_controller.rb
|
182
184
|
- lib/procon_bypass_man/version.rb
|
183
185
|
- lib/procon_bypass_man/websocket/pbm_job_client.rb
|
184
186
|
- procon_bypass_man.gemspec
|