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

Commit

Permalink
Add warning for lack of interface
Browse files Browse the repository at this point in the history
Update relevant documentation

Add feature request badge
Version bump

Add version command
  • Loading branch information
dmitri-mcguckin committed Mar 21, 2021
1 parent 51a39a6 commit fa74b09
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![pypi](https://img.shields.io/pypi/v/canopen-monitor)](https://pypi.org/project/canopen-monitor)
[![read the docs](https://readthedocs.org/projects/canopen-monitor/badge/?version=latest)](https://canopen-monitor.readthedocs.io)
[![issues](https://img.shields.io/github/issues/oresat/CANopen-monitor/bug?label=issues)](https://github.com/oresat/CANopen-monitor/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
[![feature requests](https://img.shields.io/github/issues/oresat/CANopen-monitor/feature%20request?color=purple&label=feature%20requests)](https://github.com/oresat/CANopen-monitor/labels/feature%20request)
[![unit tests](https://img.shields.io/github/workflow/status/oresat/CANopen-monitor/Unit%20Tests?label=unit%20tests)](https://github.com/oresat/CANopen-monitor/actions?query=workflow%3A%22Unit+Tests%22)
[![deployment](https://img.shields.io/github/workflow/status/oresat/CANopen-monitor/Deploy%20to%20PyPi?label=deployment)](https://github.com/oresat/CANopen-monitor/actions?query=workflow%3A%22Deploy+to+PyPi%22)

Expand All @@ -19,7 +20,13 @@ An NCurses-based TUI application for tracking activity over the CAN bus and deco

### Run

`$` `canopen-monitor`
**Run the monitor, binding to `can0`**

`$` `canopen-monitor -i can0`

**Use this for an extensive help menu**

`$` `canopen-monitor --help`

***

Expand Down
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 = 2
PATCH = 0
PATCH = 2

APP_NAME = 'canopen-monitor'
APP_DESCRIPTION = 'An NCurses-based TUI application for tracking activity' \
Expand Down
28 changes: 26 additions & 2 deletions canopen_monitor/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import argparse
from . import APP_NAME, APP_DESCRIPTION, CONFIG_DIR, CACHE_DIR
from . import APP_NAME, APP_VERSION, APP_DESCRIPTION, CONFIG_DIR, CACHE_DIR
from .app import App
from .can import MagicCANBus, MessageTable
from .parse import CANOpenParser, load_eds_file
Expand Down Expand Up @@ -28,7 +29,7 @@ def main():
dest='interfaces',
type=str,
nargs='+',
default=['vcan0'],
default=[],
help='A list of interfaces to bind to.')
parser.add_argument('--no-block',
dest='no_block',
Expand All @@ -37,9 +38,32 @@ def main():
help='Disable block-waiting for the Magic CAN Bus.'
' (Warning, this may produce undefined'
' behavior).')
parser.add_argument('-v', '--version',
dest='version',
action='store_true',
default=False,
help='Display the app version then exit.')
args = parser.parse_args()

if(args.version):
print(f'{APP_NAME} v{APP_VERSION}\n\n{APP_DESCRIPTION}')
sys.exit(0)

try:
if(len(args.interfaces) == 0):
print('Warning: no interfaces config was found and you did not'
' specify any interface arguments')
print(f'\t(see {APP_NAME} -h for details)\n')
print('This means the monitor will not be listening to anything.')
while(True):
answer = input('Would you like to continue anyways? [y/N]: ')
if(answer.upper() == 'N' or answer == ''):
sys.exit(0)
elif(answer.upper() == 'Y'):
break
else:
print(f'Invalid response: {answer}')

init_dirs()
eds_configs = load_eds_files()
mt = MessageTable(CANOpenParser(eds_configs))
Expand Down

0 comments on commit fa74b09

Please sign in to comment.