ant-plus icon indicating copy to clipboard operation
ant-plus copied to clipboard

Mac compatibility?

Open moretty opened this issue 8 years ago • 8 comments

Hi there! I want to know if there is a way to run this on a Mac? I saw that windows and linux versions uses different kind of usb connectors. Do you know how to do it in a Mac?

moretty avatar Sep 10 '15 12:09 moretty

I'm sorry but I don't have a Mac to test with, but since the library uses node-usb to communicate with the ANT device and node-usb should work on Mac, you shouldn't have any problem. If you have issues when installing node-usb, please refer to https://www.npmjs.com/package/usb for more details. On the other hand, if you find and fix issues with this library on Mac, please submit a pull request and I will accept it :-)

Loghorn avatar Sep 11 '15 09:09 Loghorn

I've been trying to get this working on a Mac and have been running into issues.

My device: Suunto Movestick (same vendor/product id as GarminStick2).

When I try to run this program:

var Ant = require('ant-plus');
var stick = new Ant.GarminStick2();
var sensor = new Ant.HeartRateSensor(stick);
if (!stick.open()) {
  console.log('stick not found');
}

I get this error: warning [darwin_open] USBDeviceOpen: another process has device opened for exclusive access

It looks like it's related to this issue, I'm not sure how to resolve it though.

mattdsteele avatar Nov 15 '15 03:11 mattdsteele

Can you try to comment the line 298 of ant.ts (this.iface.claim();) and see if it fixes the issue on Mac? If it does I will make a permanent change. Thank you

Loghorn avatar Nov 16 '15 17:11 Loghorn

Didn't seem to help, I get a segfault. At debug level 4:

[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 3.131655] [0000050f] libusb: debug [libusb_get_device_list]
[ 3.131729] [0000050f] libusb: debug [discovered_devs_append] need to increase capacity
[ 3.131879] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132020] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132152] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132244] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132306] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132393] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132444] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132509] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132559] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132607] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132671] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132722] [0000050f] libusb: debug [libusb_get_device_descriptor]
[ 3.132963] [0000050f] libusb: debug [libusb_open] open 20.6
[ 3.133027] [0000050f] libusb: warning [darwin_open] USBDeviceOpen: another process has device opened for exclusive access
[ 3.133152] [0000050f] libusb: debug [usbi_add_pollfd] add fd 19 events 1
[ 3.133175] [0000050f] libusb: debug [darwin_open] device open for access
[ 3.133219] [00003e0b] libusb: debug [handle_events] poll() returned 1
[ 3.133239] [00003e0b] libusb: debug [handle_events] caught a fish on the control pipe
[ 3.133262] [00003e0b] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!
[ 3.133270] [00003e0b] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 3.133276] [00003e0b] libusb: debug [handle_events] poll fds modified, reallocating
[ 3.133282] [00003e0b] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms
[ 3.135039] [0000050f] libusb: debug [ep_to_pipeRef] converting ep address 0x81 to pipeRef and interface
[ 3.135064] [0000050f] libusb: warning [ep_to_pipeRef] no pipeRef found with endpoint address 0x81.
[ 3.135072] [0000050f] libusb: error [submit_bulk_transfer] endpoint not found on any open interface
[ 3.135079] [0000050f] libusb: debug [ep_to_pipeRef] converting ep address 0x81 to pipeRef and interface
[ 3.135085] [0000050f] libusb: warning [ep_to_pipeRef] no pipeRef found with endpoint address 0x81.
[ 3.135091] [0000050f] libusb: error [submit_bulk_transfer] endpoint not found on any open interface
[ 3.135783] [0000050f] libusb: debug [libusb_cancel_transfer]
[ 3.135801] [0000050f] libusb: debug [ep_to_pipeRef] converting ep address 0x81 to pipeRef and interface
[ 3.135807] [0000050f] libusb: warning [ep_to_pipeRef] no pipeRef found with endpoint address 0x81.
[ 3.135811] [0000050f] libusb: error [darwin_abort_transfers] endpoint not found on any open interface
[ 3.135821] [0000050f] libusb: debug [libusb_cancel_transfer] cancel transfer failed error -5
[ 3.135843] [0000050f] libusb: debug [libusb_cancel_transfer]
[1]    10774 segmentation fault  node index.js

mattdsteele avatar Nov 17 '15 03:11 mattdsteele

It was a long shot, based on the fact the on the issue you mentioned someone proposed that solution... I guess we'll have to wait for a fix in node-usb :disappointed:

Loghorn avatar Nov 17 '15 08:11 Loghorn

I am using it on a Mac with the Garmin Ant+ stick. Works great. FWIW

designfrontier avatar Jan 02 '16 18:01 designfrontier

FYI I am using it on a Mac with the Suuntu Movestick. I installed libusb using Homebrew. Works fine.

sauy7 avatar Sep 09 '16 16:09 sauy7

While this issue was raised a long time ago, I hit the same thing myself this evening:

$ node multi-scan.js
libusb: warning [darwin_open] USBDeviceOpen: another process has device opened for exclusive access
libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
Stick not found!

The issue for me was that Garmin Express actually had the USB stick open!

Found by running

$ lsof | fgrep -i usb
:
Garmin    18945  user  txt       REG                1,5        40112     234637686 /Applications/Garmin Express.app/Contents/Library/LoginItems/Garmin Express Service.app/Contents/MacOS/libusb-compat.dylib
Garmin    18945  user  txt       REG                1,5       130352     234637685 /Applications/Garmin Express.app/Contents/Library/LoginItems/Garmin Express Service.app/Contents/MacOS/libusb.dylib
Garmin    18945  user  txt       REG                1,5       180880      18867932 /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle/Contents/MacOS/IOUSBLib
:

and of course fixed by quitting Garmin Express from the menu bar (and not letting it run in background).

Then it all works. For example

$ node multi-scan.js
startup
id: 51347
HeartRateScannerState {
  DeviceID: 51347,
  BeatTime: 27559,
  BeatCount: 86,
  ComputedHeartRate: 59 }
id: 51347
HeartRateScannerState {
  DeviceID: 51347,
  BeatTime: 27559,
  BeatCount: 86,
  ComputedHeartRate: 59 }
id: 51347
HeartRateScannerState {
  DeviceID: 51347,
  BeatTime: 27559,
  BeatCount: 86,
  ComputedHeartRate: 59,
  PreviousBeat: 26514 }

cryptocyclist avatar Dec 11 '19 21:12 cryptocyclist