Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using nan instread of None and updated tests #58

Merged
merged 5 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
log_cli = True
log_cli_date_format = %Y-%m-%d %H:%M:%S
log_cli_format = %(asctime)s %(levelname)-7s %(threadName)-18s %(name)-32s %(message)s
log_cli_format = %(asctime)s %(levelname)-8s %(threadName)-18s %(name)-32s [%(funcName)s-%(lineno)d] %(message)s
log_cli_level = 60

; log_file = logs/pytest-logs.txt
Expand Down
17 changes: 9 additions & 8 deletions roboglia/base/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(self, name='FILEBUS', robot=None, port='', auto=True,
**kwargs)
self.__fp = None
self.__last = {}
logger.debug(f'FileBus {self.name} initialized')
logger.debug(f'FileBus "{self.name}" initialized')

def open(self):
"""Opens the file associated with the ``FileBus``."""
Expand Down Expand Up @@ -228,15 +228,16 @@ def write(self, reg, value):
logger.error(f'attempt to write to closed bus {self.name}')
else:
self.__last[(reg.device.dev_id, reg.address)] = value
text = f'written {value} in register {reg.name} ' + \
f'({reg.address}) of device {reg.device.dev_id}'
text = f'written {value} in register "{reg.name}"" ' + \
f'({reg.address}) of device "{reg.device.name}" ' + \
f'({reg.device.dev_id})'
try:
self.__fp.write(text + '\n')
self.__fp.flush()
except Exception:
logger.error(f'error executing write and flush to file '
f'for bus: {self.name}')
logger.debug(f'FileBus {self.name} {text}')
logger.debug(f'FileBus "{self.name}" {text}')

def read(self, reg):
"""Reads the value from the buffer of ``FileBus`` and logs it.
Expand Down Expand Up @@ -272,15 +273,15 @@ def read(self, reg):
if (reg.device.dev_id, reg.address) not in self.__last:
self.__last[(reg.device.dev_id, reg.address)] = reg.default
val = self.__last[(reg.device.dev_id, reg.address)]
text = f'read {val} from register {reg.name} ){reg.address}) ' + \
f'of device {reg.device.dev_id}'
text = f'read {val} from register "{reg.name}" ({reg.address}) ' +\
f'of device "{reg.device.name}" ({reg.device.dev_id})'
try:
self.__fp.write(text + '\n')
self.__fp.write(text+'\n')
self.__fp.flush()
except Exception:
logger.error(f'error executing write and flush to file '
f'for bus: {self.name}')
logger.debug(f'FileBus {self.name} {text}')
logger.debug(f'FileBus "{self.name}" {text}')
return val

def __str__(self):
Expand Down
Loading