Skip to content

Commit

Permalink
Installable script for moteping.
Browse files Browse the repository at this point in the history
  • Loading branch information
raidoz committed Jul 21, 2016
1 parent d1f7591 commit a9b763b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 72 deletions.
63 changes: 4 additions & 59 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1,4 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
*.pyc
.idea
dist
moteping.egg-info
3 changes: 3 additions & 0 deletions bin/moteping
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
from moteping.moteping import main
main()
4 changes: 4 additions & 0 deletions moteping/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
"""__init__.py: moteping init."""

__author__ = "Raido Pahtma"
__license__ = "MIT"

version = "0.2.0"
13 changes: 8 additions & 5 deletions moteping/moteping.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os

from moteconnection.connection import Connection
from moteconnection.message import MessageDispatcher, Message
from moteconnection.message import MessageDispatcher, Message, AM_BROADCAST_ADDR
from serdepa import SerdepaPacket, List, nx_uint8, nx_uint32

import logging
Expand Down Expand Up @@ -256,7 +256,10 @@ def receive(self, packet):
p.ping_size, p.pong_size, p.pong_size_max,
rtt, delay, p.uptime_s, str(p.padding.serialize()).encode("hex").upper())

print(out)
if packet.source != self._destination and self._destination != AM_BROADCAST_ADDR:
log.debug(out)
else:
print(out)

except ValueError as e:
print_red("{} pong {}".format(self._ts_now(), e.message))
Expand All @@ -271,9 +274,9 @@ def main():
parser.add_argument("destination", default=1, type=arg_hex2int, help="Ping destination")

parser.add_argument("--count", default=0, type=int, help="Ping count, 0 for unlimited")
parser.add_argument("--interval", default=5.0, type=float, help="Ping interval (seconds, float)")
parser.add_argument("--interval", default=10.0, type=float, help="Ping interval (seconds, float)")

parser.add_argument("--pongs", default=7, type=int, help="Pong count, >= 1")
parser.add_argument("--pongs", default=1, type=int, help="Pong count, >= 1")
parser.add_argument("--delay", default=100, type=int, help="Subsequent pong delay")

parser.add_argument("--ping-size", default=len(PingPacket().serialize()), type=int, help="Ping size, can't be smaller than default")
Expand All @@ -283,7 +286,7 @@ def main():
parser.add_argument("--address", default=0xFFFE, type=arg_hex2int, help="Local address")
parser.add_argument("--group", default=0x22, type=arg_hex2int, help="Local group")

parser.add_argument("--channel", default=None, type=int, help="Radio channel")
#parser.add_argument("--channel", default=None, type=int, help="Radio channel")

args = parser.parse_args()

Expand Down
26 changes: 18 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
from setuptools import setup
"""
moteping: moteping application.
Python application for pinging smart-dust motes.
"""

from setuptools import setup, find_packages
from os.path import join as pjoin

import moteping

doclines = __doc__.split("\n")

setup(name='moteping',
version='0.1.0',
version=moteping.version,
description='Python application for pinging smart-dust motes',
long_description='\n'.join(doclines[2:]),
url='http://github.com/proactivity-lab/python-moteping',
author='Raido Pahtma',
author_email='[email protected]',
license='MIT',
install_requires=[
"moteconnection",
"argconfparse",
"serdepa",
],
packages=['moteping'],
platforms=["any"],
packages=find_packages(),
install_requires=['moteconnection', 'argconfparse', 'serdepa'],
scripts=[pjoin('bin', 'moteping')],
zip_safe=False)

0 comments on commit a9b763b

Please sign in to comment.