Giter Site home page Giter Site logo

samycookie / python-ant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from donalm/python-ant

12.0 12.0 8.0 306 KB

UNOFICIAL Python implementation of the ANT, ANT+, and ANT-FS protocols. Original work by https://github.com/mvillalba/python-ant.

License: MIT License

Shell 0.80% Python 99.20%

python-ant's People

Contributors

baderj avatar danankers avatar david-hari avatar donalm avatar mvillalba avatar ramunasd avatar samycookie avatar sliwowitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

python-ant's Issues

Dependency issue installing pyusb

When I run python setup.py install, I get an error about pyusb 1.0.0 not found:

Searching for pyusb>=1.0.0
Reading https://pypi.python.org/simple/pyusb/
No local packages or download links found for pyusb>=1.0.0
error: Could not find suitable distribution for Requirement.parse('pyusb>=1.0.0')

Apparently, the only registered version is 1.0.0b2. I had to change this to 'pyusb>=1.0.0b2' to get this to work.

Also (not really related to this project) once I got pyusb 1.0.0b2, I was unable to get it working on Windows. It said it needed a backend installed, but even when I installed libusb it still didn't work.

Updated Six Requirement

I'm trying one of the examples and I'm getting this error for my import:
10: from ant.core import node
I'm using OSX El Capitan and python 2.7
File "/.../myscript.py", line 10, in
from ant.core import node
File "build/bdist.macosx-10.11-intel/egg/ant/core/node.py", line 32, in
File "build/bdist.macosx-10.11-intel/egg/ant/core/event.py", line 37, in
File "build/bdist.macosx-10.11-intel/egg/ant/core/message.py", line 71, in
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
return meta("NewBase", bases, {})
File "build/bdist.macosx-10.11-intel/egg/ant/core/message.py", line 42, in init
AttributeError: type object 'NewBase' has no attribute 'type'

Python3 - TypeError

I have the following code-snippet which runs perfectly fine on python2.7 but fails with an error on python3

network = node.Network(NETKEY, 'N:ANT+')
antnode.setNetworkKey(0, network)

Traceback (most recent call last):
File "...", line ..., in
antnode.setNetworkKey(0, network)
File ".../ant/core/node.py", line 237, in setNetworkKey
File ".../ant/core/message.py", line 48, in call
File ".../ant/core/message.py", line 294, in init
File ".../ant/core/message.py", line 308, in key
TypeError: can assign only bytes, buffers, or iterables of ints in range(0, 256)

USB Timeout on OSX

Hi, under linux the demo script for HR monitor works perfectly, but under OSX I get the following error one second after starting.

Listening for HR monitor events (120 seconds)...
Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(_self.__args, *_self._kwargs)
File "build/bdist.macosx-10.11-intel/egg/ant/core/event.py", line 50, in EventPump
buffer
+= evm.driver.read(20)
File "build/bdist.macosx-10.11-intel/egg/ant/core/driver.py", line 77, in read
data = self._read(count)
File "build/bdist.macosx-10.11-intel/egg/ant/core/driver.py", line 235, in _read
return self._epIn.read(count).tostring()
File "build/bdist.macosx-10.11-intel/egg/usb/core.py", line 402, in read
return self.device.read(self, size_or_buffer, timeout)
File "build/bdist.macosx-10.11-intel/egg/usb/core.py", line 988, in read
self.__get_timeout(timeout))
File "build/bdist.macosx-10.11-intel/egg/usb/backend/libusb1.py", line 833, in bulk_read
timeout)
File "build/bdist.macosx-10.11-intel/egg/usb/backend/libusb1.py", line 936, in __read
_check(retval)
File "build/bdist.macosx-10.11-intel/egg/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 60] Operation timed out

Catch USB Exceptions

Is there a way for me to be able to catch USB Exceptions (for example when unplugging the device)
Its on a diff Thread, and I can't really get it in a try-catch loop. :/ Is there some way I can catch this? Some callback to handle exceptions? Like node.registerErrorHandler()?

Implementing an ANT+ server

Hi,

I'm working on implementing the ANT+ FE-C profile which requires not only being a client (receiving and reacting) but also being a server (sending messages). I originally started working with a downstream fork from David Hari but noticed that you'd implemented most of the event framework, so I've ended up here.

What's not clear is how I can use that framework to EMIT data messages. I haven't looked at all of the profiles, but it seems that at least for the FE-C, the profile requires that data be sent every 250ms. So I was thinking of defining a callback, e.g., 'onSlotTimeout', which would get called when the slot interval expired. That would probably require plumbing down into the guts of the EventPump. I would make the interval configurable, and at least for now only one interval callback duration would be allowed.

I also need to integrate this to control another device via serial port. Originally I was going to have a single event loop servicing both devices, but I don't think that strategy will work well for this framework as-is, because python-ant owns its own event loop. I could run the stuff for the other device in a different thread, but that would require synchronization of data between the two threads. Maybe not the worst thing, but managing everything in one thread is certainly simpler and less error-prone. Any suggestions you might have in this regard would be appreciated.

I'm curious about the "extended_messages" branch that appears to be dormant. It looks like it contains some server-side code and some sort of higher-level event framework. From the name I suspect the branch implements ANT+ extended messages, but it looks like there's other useful stuff in there as well. Can you give me any information on it? Does it work? Why was it abandoned?

Any insights you might have appreciated.

How is network key supposed to be set?

The original code from @mvillalba had a NetworkKey object that held the number and key, and was passed to setNetworkKey.
Your code does away with the object, but setNetworkKey still tries to access properties of the network variable.
If I call setNetworkKey with an integer and a bytearray, I get the error:

'str' object has no attribute 'key'

Is this a mistake in your code (which you've somehow missed all this time), or am I doing something wrong?

Multiple ProductID

I have two ANT+ Sticks, and one uses 0x1009 for the ProductId and the other 0x1008. Is there a way I can write some code which works with any of them without hard-coding the ProductId values in? Can I specify either a list, or just leave it empty to match any device with the Dynastream vendorId?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.