Skip to content

Commit 8f1516e

Browse files
committed
1.3.0 configtools updates for rt linux
1 parent 8c35117 commit 8f1516e

File tree

8 files changed

+166
-65
lines changed

8 files changed

+166
-65
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2021, Bloomy Controls Inc.
3+
Copyright (c) 2023, Bloomy Controls Inc.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "BS1200_driver"
3-
version = "1.2.13"
3+
version = "1.3.0"
44
authors = [{ name = "Mikhail Kharitonov", email = "[email protected]"}]
55
description= "Python interface to the Bloomy BS1200"
66
readme = "README.md"

src/bs1200/can_frames.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,10 @@ def ai_get_5_8(box_id: int) -> Message:
428428
except ValueError as e:
429429
print("Error constructing AI_Readback_5_8 frame", e)
430430

431-
431+
#CAN Frame
432+
#ui32 4 bytes
433+
#bool 1 byte
434+
#U8 1 byte
435+
#ARRAY_U8[8] 8 bytes
436+
# length: 14 bytes
432437

src/bs1200/cfg_tools.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from ftplib import FTP
22
from dataclasses import dataclass
3-
from paramiko import SSHClient
3+
from paramiko import SSHClient, AutoAddPolicy
44
from scp import SCPClient
55

66
class FtpHelper(object):
@@ -12,7 +12,7 @@ def __init__(self, tgt: str, user: str, password : str):
1212
self.username = user
1313
self.password = password
1414

15-
def getFile(self, tgt_path, dest_path) -> str:
15+
def get_file(self, tgt_path, dest_path) -> str:
1616
try:
1717
with FTP(self.tgt_address, self.username, self.password) as f:
1818
with open(dest_path, "wb") as file:
@@ -22,7 +22,7 @@ def getFile(self, tgt_path, dest_path) -> str:
2222
except Exception as e:
2323
raise e
2424

25-
def uploadFile(self, src_path, tgt_path):
25+
def upload_file(self, src_path, tgt_path):
2626
try:
2727
with FTP(self.tgt_address, self.username, self.password) as f:
2828
with open(src_path, "rb") as file:
@@ -32,27 +32,32 @@ def uploadFile(self, src_path, tgt_path):
3232

3333
class ScpHelper(object):
3434
"""
35-
Class used to wrap SSH and SCP file transfer for sbRIO 9603 controllers. Call using 'with' statements, or call open
35+
Class used to wrap SSH and SCP file transfer for sbRIO 9603 controllers.
36+
Call using 'with' statements, or call open
3637
"""
3738
def __init__(self, tgt: str, user: str, password : str):
3839
self.tgt_address = tgt
3940
self.username = user
4041
self.password = password
4142

42-
def __enter__(self):
43+
def __enter__(self, *args, **kwargs):
4344
try:
4445
self.open()
4546
except Exception as e:
4647
print(e)
48+
return self
4749

48-
def __exit__(self):
50+
def __exit__(self, *args, **kwargs):
4951
self.close()
5052

5153
def open(self):
5254
"""Open """
5355
self.ssh = SSHClient()
5456
self.ssh.load_system_host_keys()
55-
self.ssh.connect(self.tgt_address)
57+
self.ssh.set_missing_host_key_policy(AutoAddPolicy())
58+
self.ssh.connect(self.tgt_address,
59+
username=self.username,
60+
password=self.password)
5661
# SCPCLient takes a paramiko transport as an argument
5762
self.scp = SCPClient(self.ssh.get_transport())
5863

@@ -61,15 +66,15 @@ def close(self):
6166
self.scp.close()
6267
self.ssh.close()
6368

64-
def getFile(self, tgt_path, dest_path) -> str:
69+
def get_file(self, tgt_path, dest_path) -> str:
6570
try:
6671
with self.scp as s:
6772
s.get(remote_path=tgt_path, local_path=dest_path)
6873
return dest_path
6974
except Exception as e:
7075
print(e)
7176

72-
def uploadFile(self, src_path, tgt_path):
77+
def upload_file(self, src_path, tgt_path):
7378
try:
7479
with self.scp as s:
7580
s.put(files=src_path, remote_path=tgt_path)

0 commit comments

Comments
 (0)