Skip to content

Commit

Permalink
correction on reset_udc fct
Browse files Browse the repository at this point in the history
  • Loading branch information
pnallin committed Nov 21, 2022
1 parent 005ca1f commit a29cce8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
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, GenericDRS, SerialDRS # noqa: F401

__version__ = "2.0.0"
__date__ = "19/08/2022"
__version__ = "2.0.1"
__date__ = "21/11/2022"
2 changes: 2 additions & 0 deletions src/pydrs/consts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 14 additions & 4 deletions src/pydrs/pydrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a29cce8

Please sign in to comment.