diff --git a/docs/conf.py b/docs/conf.py index bf78d21..6aab04c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,11 +19,11 @@ # -- Project information ----------------------------------------------------- project = "pydrs" -copyright = "2022, Gabriel Brunheira, Allef Araujo, Marcelo Martins, Rogério Marcondelli, Claudio Carneiro, Guilherme Freitas" -author = "Gabriel Brunheira, Allef Araujo, Marcelo Martins, Rogério Marcondelli, Claudio Carneiro, Guilherme Freitas" +copyright = "2022, Gabriel Brunheira, Allef Araujo, Marcelo Martins, Rogério Marcondelli, Claudio Carneiro, Guilherme Freitas, Patricia Nallin" +author = "Gabriel Brunheira, Allef Araujo, Marcelo Martins, Rogério Marcondelli, Claudio Carneiro, Guilherme Freitas, Patricia Nallin" # The full version, including alpha/beta/rc tags -release = "2.0.0" +release = "2.0.1" # -- General configuration --------------------------------------------------- diff --git a/src/pydrs/__init__.py b/src/pydrs/__init__.py index 25522e5..fcd8990 100644 --- a/src/pydrs/__init__.py +++ b/src/pydrs/__init__.py @@ -1,4 +1,4 @@ from .pydrs import EthDRS, GenericDRS, SerialDRS # noqa: F401 -__version__ = "2.0.0" -__date__ = "19/08/2022" +__version__ = "2.0.1" +__date__ = "21/11/2022" diff --git a/src/pydrs/consts/__init__.py b/src/pydrs/consts/__init__.py index e9d2621..0f48291 100644 --- a/src/pydrs/consts/__init__.py +++ b/src/pydrs/consts/__init__.py @@ -6,6 +6,8 @@ NUM_DSP_CLASSES = 7 ETH_CMD_REQUEST = b"\x11" +ETH_CMD_WRITE = b"\x03" + COM_FUNCTION = "\x50" COM_WRITE_VAR = "\x20" diff --git a/src/pydrs/pydrs.py b/src/pydrs/pydrs.py index 08ad15d..b375021 100644 --- a/src/pydrs/pydrs.py +++ b/src/pydrs/pydrs.py @@ -7,10 +7,13 @@ import serial from .base import BaseDRS -from .consts import ETH_ANSWER_ERR, ETH_CMD_REQUEST, ETH_RESET_CMD -from .utils import checksum, get_logger +from .consts import ETH_ANSWER_ERR, ETH_CMD_REQUEST, ETH_RESET_CMD, ETH_CMD_WRITE, common +from .utils import checksum, get_logger, index_to_hex from .validation import SerialErrPckgLen, validate + + + logger = get_logger(name=__file__) @@ -84,7 +87,14 @@ def __init__(self, address: str, port: int = 5000): self.connect(address, port) def _format_message(self, msg: bytes, msg_type: bytes) -> bytes: - msg = msg_type + struct.Struct(">f").pack(self._serial_timeout) + msg + if (msg_type == ETH_CMD_WRITE): + if (msg[4] == common.functions.index("reset_udc")): # Do not wait for a reply + msg = msg_type + struct.Struct(">f").pack(0.0) + msg + else: + msg = msg_type + struct.Struct(">f").pack(self._serial_timeout) + msg + else: + msg = msg_type + struct.Struct(">f").pack(self._serial_timeout) + msg + return msg[0:1] + struct.pack(">I", (len(msg) - 1)) + msg[1:] def reset_input_buffer(self): @@ -124,7 +134,7 @@ def _transfer(self, msg: str, size: int) -> bytes: def _transfer_write(self, msg: str): base_msg = (self._slave_addr + msg).encode("ISO-8859-1") - full_msg = self._format_message(checksum(base_msg), ETH_CMD_REQUEST) + full_msg = self._format_message(checksum(base_msg), ETH_CMD_WRITE) self.socket.sendall(full_msg) try: self._get_reply()