Skip to content

Commit

Permalink
有線経由の場合を追加+REAMDE修正
Browse files Browse the repository at this point in the history
  • Loading branch information
helenwangjia committed Jun 7, 2024
1 parent f1b2af4 commit 61d2ddd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
3 changes: 3 additions & 0 deletions osect_sensor/Application/edge_cron/common/common_config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@

SEND_REQUST_TIMEOUT = 180
""" ログ送信時のタイムアウト値 """

IS_CLOSED_NETWORK = True
""" ログ送信時のタイムアウト値 """
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
API_URL,
LABEL_ID,
CLIENT_CERTIFICATE_PATH,
IS_CLOSED_NETWORK,
)

# from common.common_function import pcap2log
Expand Down Expand Up @@ -147,17 +148,21 @@ def handle(self, *args, **options):
# logger.info("sleep " + str(sleep_time) + "s")

try:
# コア網チェック
with serial.Serial('/dev/ttyUSB1', baudrate=115200, timeout=1) as sara:
sara.write(b'at\r\n')
b=sara.read(16)
cnum=b.decode().split("\n")

if "OK\r" in cnum:
if IS_CLOSED_NETWORK:
# コア網チェック
with serial.Serial('/dev/ttyUSB1', baudrate=115200, timeout=1) as sara:
sara.write(b'at\r\n')
b=sara.read(16)
cnum=b.decode().split("\n")

if "OK\r" in cnum:
# ログ送信
send_server(tar_list)
else:
logger.error("can not send compressed file. Unable to connect to closed network. ")
else:
# ログ送信
send_server(tar_list)
else:
logger.error("can not send compressed file. Unable to connect to closed network. ")
except Exception as e:
logger.error("can not send compressed file. " + str(e))

Expand Down
33 changes: 33 additions & 0 deletions osect_sensor/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,39 @@ NTT Comから提供されたクライアント証明書を以下に格納しま
$ ~/osect_sensor/keys/client.pem
```

### 3.5. ログ送信方式の設定

有線経由でログを送信する場合は以下の設定をします。

設定ファイル:

```bash
$ vi Application/edge_cron/common/common_config.py
```

変更箇所:

```python
IS_CLOSED_NETWORK = True
IS_CLOSED_NETWORK = False
```

設定ファイル:

```bash
$ vi docker-compose.yml
```

変更箇所:

```yml
devices:
- "/dev/ttyUSB1:/dev/ttyUSB1"
(削除)
```

## 4. コンテナの構築・起動

コンテナを構築、起動します。
Expand Down

0 comments on commit 61d2ddd

Please sign in to comment.