Skip to content

Commit

Permalink
Corrigindo metodo print_data e argumento timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
JN513 committed Nov 26, 2024
1 parent 9b903b9 commit 2b33aab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def read_data(self, size: int = 4) -> bytes:
"""
return self.serial.read(size)

def print_data(self, data: bytes) -> None:
def print_data(self, data: int) -> None:
"""
Prints the received data in hexadecimal format.
Args:
data (bytes): Data to be printed.
data (int): Data to be printed.
"""
data = data.to_bytes(4, 'big')

for byte in data:
print(f'{byte:02x}', end='')
print()
Expand Down
2 changes: 2 additions & 0 deletions core/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ProcessorCIInterfaceShell(cmd.Cmd, ProcessorCIInterface):
such as clock control, memory read and write, accumulator manipulation, and more.
"""

prompt = 'ProcessorCIInterface> '

def __init__(self, port: str, baudrate: int, timeout: int = 1) -> None:
"""
Initializes the communication interface with the processor and the interactive shell.
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def main():
'--baudrate',
help='Baud rate for communication with the controller',
default=115200,
type=int,
)
parser.add_argument(
'-t',
'--timeout',
help='Timeout for communication with the controller',
default=1,
type=int,
)
parser.add_argument(
'-s',
Expand All @@ -52,7 +54,7 @@ def main():

if args.shell:
shell = ProcessorCIInterfaceShell(
args.port, args.baudrate, args.timeout
args.port, args.baudrate, int(args.timeout)
)
shell.cmdloop()

Expand Down

0 comments on commit 2b33aab

Please sign in to comment.