Skip to content

Commit

Permalink
Adds deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrn committed Aug 8, 2022
1 parent 15f35ea commit fa1363b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.2.3] - 2022-08-08
### Added:
- Deprecation messages for substituted/altered functions

## [1.2.2] - 2022-07-28
### Added:
- Error messages for BSMP return errors (0xE_)
Expand Down
4 changes: 2 additions & 2 deletions src/pydrs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .pydrs import EthDRS, SerialDRS, GenericDRS

__version__ = "1.2.2"
__date__ = "28/07/2022"
__version__ = "1.2.3"
__date__ = "08/08/2022"
31 changes: 26 additions & 5 deletions src/pydrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
import math
import os
from pprint import pprint
import struct
import time

Expand Down Expand Up @@ -165,6 +166,18 @@ def slave_addr(self) -> int:
def slave_addr(self, address: int):
self._slave_addr = struct.pack("B", address).decode("ISO-8859-1")

def set_slave_add(self, address: int):
print(
f"From 2.0.0 onwards, the slave address will be a property. Use 'slave_addr = {address}' instead"
)
self.slave_addr = address

def get_slave_add(self) -> int:
print(
"From 2.0.0 onwards, the slave address will be a property. Use 'slave_addr' instead"
)
return self.slave_addr

"""
======================================================================
Funções Internas da Classe
Expand Down Expand Up @@ -1409,7 +1422,10 @@ def decode_interlocks(self, reg_interlocks, list_interlocks: list) -> list:
return active_interlocks

def read_vars_fbp(self, n: int = 1, dt: float = 0.5):
vars_list = []
vars = {}
print(
"From 2.0.0, read_vars_fbp will not loop or print implicitly. It will only return a dictionary."
)
for _ in range(n):
self.read_vars_common()

Expand Down Expand Up @@ -1446,13 +1462,16 @@ def read_vars_fbp(self, n: int = 1, dt: float = 0.5):
+ " %",
}

vars_list.append(self._include_interlocks(vars))
pprint(vars)

time.sleep(dt)
return vars_list
return vars

def read_vars_fbp_dclink(self, n: int = 1, dt: float = 0.5) -> list:
vars_list = []
vars = {}
print(
"From 2.0.0, read_vars_fbp_dclink will not loop or print implicitly. It will only return a dictionary."
)
try:
for i in range(n):
self.read_vars_common()
Expand All @@ -1479,12 +1498,14 @@ def read_vars_fbp_dclink(self, n: int = 1, dt: float = 0.5) -> list:
hard_itlks, list_fbp_dclink_hard_interlocks
)

vars_list.append(vars)
pprint(vars)
time.sleep(dt)

except Exception:
pass

return vars

def read_vars_fac_acdc(self, n=1, dt: float = 0.5, iib: bool = True):
for i in range(n):

Expand Down
2 changes: 1 addition & 1 deletion src/pydrs/pydrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _get_reply(self, size: int = None) -> bytes:
except IndexError:
self._reset_input_buffer()
raise SerialErrPckgLen(
"Received empty response, check if the controller is on and connected"
"Received empty response, check if the controller is on and connected. If you receive garbled output, try disconnecting and reconnecting."
)

return payload
Expand Down
10 changes: 6 additions & 4 deletions src/pydrs/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ def wrapper(*args, **kwargs):
if len(reply) == 0 or (len(reply) == 1 and reply[0] == ETH_ANSWER_NOQUEUE):
args[0]._reset_input_buffer()
raise SerialErrPckgLen(
"Received empty response, check if the controller is on and connected"
"Received empty response, check if the controller is on and connected. If you receive garbled output, try disconnecting and reconnecting."
)

reply = reply[1:] if len(reply) - 1 == args[2] else reply
check_serial_error(reply)

if len(reply) != args[2] or (len(reply)-1 != args[2] and reply[0] == 0x21):
offset = 1 if reply[0] == 0x21 else 0
if len(reply) != args[2] or (len(reply) - 1 != args[2] and reply[0] == 0x21):
offset = 1 if reply[0] == 0x21 else 0
if len(reply) > 5:
check_serial_error(reply[offset:])

args[0]._reset_input_buffer()
raise SerialErrPckgLen(
"Expected {} bytes, received {} bytes".format(args[2], len(reply) - offset)
"Expected {} bytes, received {} bytes".format(
args[2], len(reply) - offset
)
)

if reply != checksum(reply[:-1]):
Expand Down

0 comments on commit fa1363b

Please sign in to comment.