Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Update error message to be its own collumn
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitri-mcguckin committed May 23, 2021
1 parent 7a4270b commit e4eed5b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion canopen_monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAJOR = 3
MINOR = 3
PATCH = 2
PATCH = 3

APP_NAME = 'canopen-monitor'
APP_DESCRIPTION = 'An NCurses-based TUI application for tracking activity' \
Expand Down
6 changes: 4 additions & 2 deletions canopen_monitor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def __enter__(self: App) -> App:
style=curses.color_pair(1))
self.hb_pane = MessagePane(cols={'Node ID': ('node_name', 0),
'State': ('state', 0),
'Status': ('message', 0)},
'Status': ('message', 0),
'Error': ('error', 0)},
types=[MessageType.HEARTBEAT],
parent=self.screen,
height=int(height / 2) - 1,
Expand All @@ -192,7 +193,8 @@ def __enter__(self: App) -> App:
'Node Name': ('node_name', 0),
'Type': ('type', 0),
'Age': ('age', 0),
'Message': ('message', 0)},
'Message': ('message', 0),
'Error': ('error', 0)},
types=[MessageType.NMT,
MessageType.SYNC,
MessageType.TIME,
Expand Down
2 changes: 1 addition & 1 deletion canopen_monitor/can/message_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self: MessageTable, parser=None):
def __add__(self: MessageTable, message: Message) -> MessageTable:
if(self.parser is not None):
message.node_name = self.parser.get_name(message)
message.message = self.parser.parse(message)
message.message, message.error = self.parser.parse(message)
self.table[message.arb_id] = message
return self

Expand Down
9 changes: 5 additions & 4 deletions canopen_monitor/parse/canopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_name(self, message: Message) -> Union[str, None]:
return parser.device_commissioning.node_name \
if parser else hex(message.node_id)

def parse(self, message: Message) -> str:
def parse(self, message: Message) -> (str, str):
"""
Detect the type of the given message and return the parsed version
Expand Down Expand Up @@ -64,8 +64,9 @@ def parse(self, message: Message) -> str:
parsed_message = parse_function(message.arb_id,
message.data,
eds_config)
error = ""
except (FailedValidationError, TypeError) as exception:
parsed_message = f"{format_bytes(message.data)} " \
f"Parse Error: {str(exception)}"
parsed_message = format_bytes(message.data)
error = str(exception)

return parsed_message
return parsed_message, error

0 comments on commit e4eed5b

Please sign in to comment.