WouterJD / FortiusANT

FortiusANT enables a pre-smart Tacx trainer (usb- or ANT-connected) to communicate with TrainerRoad, Rouvy or Zwift through ANT or Bluetooth LE.
GNU General Public License v3.0
148 stars 78 forks source link

Support iFlow 1932 on Mac OS? #45

Closed iainhay closed 4 years ago

iainhay commented 4 years ago

I'm looking to set up my tacx trainer on my mac - is there something similar for mac? Or can this be run on mac OS?

WouterJD commented 4 years ago

Hi Ian, welcome in the FortiusANT community!

I think FortiusANT will run on Mac and I willl help you in case there are issues, even adjust code if needed.

  1. Install python 3
  2. Download the code
  3. Run the code and see where we get

What Tacx do you have?

iainhay commented 4 years ago

Hey - awesome thanks.

I have a i-Flow with a T1932 Head unit. I was setting up after many years put away and found out the tacx software has been discontinued and mine doesn't work with the desktop app.

So I have x2 ANT+ sticks which arrived so trying to get this set up (ideally with Zwift)

I'll install python 3 and see how I go - not used Python before, it's the FortiusAnt.py I need to run once downloaded correct?

Huge thanks in advance!

WouterJD commented 4 years ago

Indeed, read wiki for instructions Succes!

iainhay commented 4 years ago

Hey!

So got the app working, it tries to calibrate, and I see this error message a few times in the terminal:

18:40:13,839: ReadFromDongle read error: [Errno 60] Operation timed out

And then the error it stops. I see all the dials as if it is sending/receiving.

Screenshot 2020-04-10 at 19 41 58

Is calibration meant to automatically turn the trainer wheel to 20km p/hr? Been so long since I've used it couldn't remember if that was possible?

iainhay commented 4 years ago

Also - if I start without calibrating I get the same error repeatedly (it doesn't stop)

18:40:13,839: ReadFromDongle read error: [Errno 60] Operation timed out

WouterJD commented 4 years ago

There someone else with an i-Flow/1932 and it seems that calibration does not work Use the -n flag (no calibration) and see what happens

iainhay commented 4 years ago

Yes if I start without calibrating I get the same error repeatedly (it doesn't stop)

18:40:13,839: ReadFromDongle read error: [Errno 60] Operation timed out

Screenshot 2020-04-10 at 19 51 20
WouterJD commented 4 years ago

run with -d8 flag and send logfile please

iainhay commented 4 years ago

Sure thing! I noticed someone had a similar issue on mac with antifier but no solution was every posted.

FortiusANT.2020-04-10 21-06-08.log

WouterJD commented 4 years ago

I have checked the logfile:

From 21:06:09 ... 21:06:11 message "[Errno 60] Operation timed out" Then commands are sent (you probably pressed Start) From 21:06:11 ... 21:06:33 als message "[Errno 60] Operation timed out"

But then it appears normal operation; FortiusANT sends command and receives an answer. From 21:06:33 ... 21:06:53

Note that it is all within a minute.

Some questions:

  1. Do the messages continue to appear?
  2. What happens if you start cycling
  3. Could it be that your system needs some time to start?

Sorry that I cannot check myself...please try ans see what happens! Succes

PS. There is another user with an iFlow 1932. So .... fair chance it can work

iainhay commented 4 years ago
  1. Do the messages continue to appear? - Yes, repeatedly
  2. What happens if you start cycling - within the app open I see the speed and power dials (I have a cadence too but not connected)
  3. Could it be that your system needs some time to start? - Not sure what you mean?

I have x2 ANT+ dongles plugged into the mac, along with the USB from the trainer.

If I have only 1 ANT+ dongle connected, I receive the same message repeatedly.

WouterJD commented 4 years ago

The provided logfile shows that the messages stop (see my message from yesterday)

  1. It may be that yoour Tacx needs some time to start and that messages disappear later-on

Provide logfile over more time than just one minute, please. Let's say 10 minutes at least.

iainhay commented 4 years ago

I can see the speed etc immediately when I start pedaling, so the trainer sending the data doesn't seem to be the issue.

10min log file attached - the previous one was a minute because I only ran it for a minute (as it's just repeating over and over) - it just repeats, to end I clck stop (the errors still come through and the close the app and it exist in the terminal.

Thanks!

FortiusANT.2020-04-12 11-34-58.log

WouterJD commented 4 years ago

Sorry * 100

ReadFromDongle has nothing to do with the Tacx trainer, but is generated at the ANT usbDongle side. (As the error message says).

Check in antDongle.py

    except Exception as e:
        if "timeout error" in str(e):
            if debug.on(debug.Data1):
                logfile.Write ("Dongle    timeout")
            pass
        else:
            logfile.Write ("ReadFromDongle read error: " + str(e))

The code expects "timeout error" in the error-message, but (on your system) the message is "ReadFromDongle read error: [Errno 60] Operation timed out" and hence the error is given and not ignored as it should be. Note that the exception handling does not alter any data but only logs the error message.

You may simple ignore the message or replace "timeout error" with "timeout" and see what happens; behaviour should be the same in both cases.

I do not like this construction (checking text in message) and will check how to improve.

Please let me know...

WouterJD commented 4 years ago

The correct code would be: except TimeoutError: pass except Exception as e: logfile.Write ("ReadFromDongle read error: " + str(e))

If you don't mind checking that, then it's confirmed on your platform and I will implement in the baseline. Thanks

iainhay commented 4 years ago

So replacing this:

except Exception as e:
        if "timeout error" in str(e):
            if debug.on(debug.Data1):
                logfile.Write ("Dongle    timeout")
            pass
        else:
            logfile.Write ("ReadFromDongle read error: " + str(e))

with:

except TimeoutError:
      pass
    except Exception as e:
      logfile.Write ("ReadFromDongle read error: " + str(e))

Still gives me:

13:06:22,863: ReadFromDongle read error: [Errno 60] Operation timed out

Repeated.

I also open Zwift with the app running, I can connect via Power Source and ANT+, but it receives no data (e.g. I start peddling but don't move or see any power). In the app I still see Power and Speed - but this is coming via the USB presumably.

iainhay commented 4 years ago

If I change to this:

except Exception as e:
        if "timed out" in str(e):
            if debug.on(debug.Data1):
                logfile.Write ("Dongle    timeout")
            pass
        else:
            logfile.Write ("ReadFromDongle read error: " + str(e))

And just check against 'timed out' then the error goes, but I'm still not receiving any data in Swift - no power etc. So it is like the receiving ANT+ dongle is not receiving the data?

WouterJD commented 4 years ago

OK, you're doing good.

Please run FortiusANT with -d4 this will provide the ANT logging. Sorry for keeping you budy on this sunny easter day :-)

https://github.com/WouterJD/FortiusANT/wiki#values

iainhay commented 4 years ago

Okay cool - attached is the log file (kept on for 10mins).

No worries - thanks for helping me with this!

FortiusANT.2020-04-12 13-54-21.log

WouterJD commented 4 years ago

OK logfile looks good, but indeed - no commands are received from Zwift.

Did you pair Zwift with FortiusANT? Note that a master (the trainer, FortiusANT) is unaware whether a slave (Zwift, ...) is looking at or pairing [with the master]..

Please send screen-shot of pairing-page, something like:

image

iainhay commented 4 years ago

Okay great.

So here is what I am doing - just listing in case I'm missing something:

  1. Plugging in the USB from my trainer
  2. Plugging in both ANT+ dongles
  3. Running the FortiusANT app (skipping calibration)
  4. Opening Zwift

Here is what I see in Zwift:

Screenshot 2020-04-12 at 16 10 07

(This is the only available device)

WouterJD commented 4 years ago

Checking the screen-print from FortiusANT (Trainer detected, Using Dynastream...) the hardware is found correctly and I would expect things to work. The logfile shows that data is transmitted.

What happens when you press SEARCH on cadence and controllable? Both should should be paired with FortiusANT.

iainhay commented 4 years ago

No nothing - I just get the searching screen..

Do I need to do anything to the ANT+ dongles? I read about having master/slave etc?

iainhay commented 4 years ago

For some reason the Heart Rate one picks up an ANT+ device and connects, but not Cadence or Controllable. Power Source connects but receives not data

iainhay commented 4 years ago

Also, if I simulate (with -s) I get the same results

WouterJD commented 4 years ago

No nothing - I just get the searching screen..

Do I need to do anything to the ANT+ dongles? I read about having master/slave etc?

master/slave is decided by software; a trainer is master, Zwift is slave

WouterJD commented 4 years ago

Also, if I simulate (with -s) I get the same results

-s simulates a trainer, this comes handy in this case - you do not need to cycle to test Zwift. Good idea to use it

WouterJD commented 4 years ago

For some reason the Heart Rate one picks up an ANT+ device and connects, but not Cadence or Controllable. Power Source connects but receives not data

What is the deviceID of the heart rate monitor?

iainhay commented 4 years ago

So it's simulating now:

Screenshot 2020-04-12 at 19 35 03

And I can only connect via ANT+ to a power source and HRM in Zwift:

Screenshot 2020-04-12 at 19 34 53

HRM ID:

Screenshot 2020-04-12 at 19 34 44
iainhay commented 4 years ago

But no watts or BPM received either

WouterJD commented 4 years ago

plse read https://github.com/WouterJD/FortiusANT/issues/42

It sounds like similar and that case was never explained. It seems another dongle solved the problem. Anyway: FortiusANT was not changed to resolve...

What dongles / configuration do you use? Where do you run Zwift? Perhaps try Trainer Road or Rouvy

I have confidence it will work

iainhay commented 4 years ago

It does seem to be something with Zwift now - I will try Rouvy tomorrow and let you know.

Thank you so much for all your help!

WouterJD commented 4 years ago

👍

iainhay commented 4 years ago

So in Rouvy I get the same, when searching for a trainer I see only a HRM :(

Screenshot_20200413-072833_ROUVY Workouts

I had to try on my phone because ANT+ is not supported on mac by Rouvy. But it seems that it's not just Zwift.

Here is what I get in ExplorAnt.py:

06:29:28,501: ExplorANT started
06:29:28,502: --------------------
06:29:28,502: Dongles in the system:
06:29:28,514: manufacturer=Dynastream Innovations, product= ANT USBStick2, vendor= 0xfcf, product=0x1008(4104)
06:29:28,515: manufacturer=Dynastream Innovations, product= ANT USBStick2, vendor= 0xfcf, product=0x1008(4104)
06:29:28,516: manufacturer=GenesysLogic, product=     USB2.1 Hub, vendor= 0x5e3, product= 0x610(1552)
06:29:28,516: manufacturer=Realtek, product=USB 10/100/1000 LAN, vendor= 0xbda, product=0x8153(33107)
06:29:28,517: manufacturer=GenesysLogic, product=     USB3.1 Hub, vendor= 0x5e3, product= 0x626(1574)
06:29:28,519: manufacturer=Apple Inc., product=Apple Internal Keyboard / Trackpad, vendor= 0x5ac, product= 0x340(832)
06:29:28,520: manufacturer=  Apple, product=           None, vendor= 0x5ac, product=0x8104(33028)
06:29:28,520: --------------------
06:29:29,060: Using Dynastream Innovations dongle
06:29:31,157: Pairing, press Ctrl-C to exit
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
06:29:41,268: Pairing stopped
06:29:41,269: --------------------
06:29:42,609: Listening, press Ctrl-C to exit
06:29:43,628: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:44,646: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:45,658: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:46,678: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:47,693: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:48,701: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:49,719: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:50,731: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:51,750: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:52,762: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1
06:29:53,777: HRM#= 0 hr= -1 FE-C#= 0 Speed=  -1 Cadence= -1 Power= -1 hr= -1

Does this look right?

My set up is:

Macbook Pro 2019 x2 ANT+ Dongles Tacx iFlow w/ 1932 Head Unit

WouterJD commented 4 years ago

Is FortiusANT running at the same time?

iainhay commented 4 years ago

No that was just running ExplorAnt.py

So when running python3 FortiusAnt.py -g -a -n -s and then running ExplorAnt.py I get:

07:31:16,155: ExplorANT started
07:31:16,155: --------------------
07:31:16,155: Dongles in the system:
07:31:16,170: manufacturer=Realtek, product=USB 10/100/1000 LAN, vendor= 0xbda, product=0x8153(33107)
07:31:16,171: manufacturer=Dynastream Innovations, product= ANT USBStick2, vendor= 0xfcf, product=0x1008(4104)
07:31:16,172: manufacturer=Dynastream Innovations, product= ANT USBStick2, vendor= 0xfcf, product=0x1008(4104)
07:31:16,173: manufacturer=GenesysLogic, product=     USB2.1 Hub, vendor= 0x5e3, product= 0x610(1552)
07:31:16,174: manufacturer=GenesysLogic, product=     USB3.1 Hub, vendor= 0x5e3, product= 0x626(1574)
07:31:16,175: manufacturer=Apple Inc., product=Apple Internal Keyboard / Trackpad, vendor= 0x5ac, product= 0x340(832)
07:31:16,177: manufacturer=  Apple, product=           None, vendor= 0x5ac, product=0x8104(33028)
07:31:16,178: --------------------
Exception: [Errno 19] No such device (it may have been disconnected)
07:31:16,187: GetDongle: [Errno 19] No such device (it may have been disconnected)
07:31:16,187: We're done
07:31:16,187: --------------------
WouterJD commented 4 years ago

ExplorANT "listens" on the ANT-network and shows what master-devices broadcast data.

There are two dongles; one used by FortiusANT and the second by ExplorANT. No other programs should be running, because then no dongle is free.

If problem persists, run ExplorANT with -d5 flag and send logfile.

iainhay commented 4 years ago

Here is the log file:

ExplorANT.2020-04-13 07-48-23.log

WouterJD commented 4 years ago

For some reason, the dongle cannot be used (that's what the message says). Since 2020-03-09 multiple dongles of the same type should be supported; before always the first dongle was taken, which would be in use by FortiusANT.

To get more info in the logfile, run ExplorANT -d7 so that functions are also logged.

M4M4R2 commented 4 years ago

Hi guys! I'm happy to see some of you are managing to do what i've been trying to for month if not years! Ok, i've been trying to install Antifier on my Raspberry pi 1 and it unfortunately didn't work properly as the ANT dongle could not be detected for some reason... Now I discover your work and I really find it great! Much like iainhay I'm a mac user very naive on programming with Python. I downloaded the Python code for FortiusANT but when running the module it says "ModuleNotFoundError: No module named 'numpy'". Would you please describe the installation process you used on mac??? THX

WouterJD commented 4 years ago

Just to be sure, I ran a FortiusANT -g -a -s test on Windows 10, without the Tacx trainer so using simulation mode.

Then ExplorAnt.py -d1; minimum logfile which produces the following result, which is as expected and immediatly shows what output is expected: The dongle is initiated Then a listening loop is done to check what devices are present (pairing) and HRM and FE is found. 57592 is the deviceID of the HRM like what Zwift shows you. And then a listening loop is done to listen what the masters say and correct HRM- and FE-values are received.

13:17:11,894: ExplorANT started 13:17:11,894: -d 1 (0b1) 13:17:11,894: -D -1 (-0x1) 13:17:11,894: -H -1 (-0x1) 13:17:11,894: -F -1 (-0x1) 13:17:11,894: -------------------- 13:17:11,894: Dongles in the system: 13:17:11,957: manufacturer=Dynastream Innovations, product=ANT USB-m Stick, vendor= 0xfcf, product=0x1009(4105) 13:17:11,957: manufacturer=Dynastream Innovations, product=ANT USB-m Stick, vendor= 0xfcf, product=0x1009(4105) 13:17:11,957: -------------------- 13:17:12,499: Using Dynastream Innovations dongle 13:17:14,594: Pairing, press Ctrl-C to exit 13:17:24,784: Pairing stopped 13:17:24,784: HRM discovered on channel=0, number=57592 typeID=120 TrType=120 13:17:24,785: FE discovered on channel=1, number=57591 typeID= 17 TrType= 17 13:17:24,785: -------------------- 13:17:26,307: HRM slave channel 5 opened; listening to device 57592 13:17:26,495: FE slave channel 4 opened; listening to device 57591 13:17:26,495: Listening, press Ctrl-C to exit 13:17:27,503: HRM#= 4 hr= 90 FE-C#= 3 Speed=35.7 Cadence=100 Power= 98 hr= 86 13:17:28,508: HRM#= 8 hr= 87 FE-C#= 7 Speed=35.7 Cadence=102 Power=103 hr= 87 13:17:29,384: Listening stopped 13:17:29,953: We're done 13:17:29,953: --------------------

ExplorAnt.py -d3; produces the following additional result:

... 13:21:50,994: GetDongle - Check for dongle 4100 Older 13:21:50,994: GetDongle - Check for dongle 4105 Garmin 13:21:51,010: GetDongle - Dongle found: manufacturer=Dynastream Innovations, product=ANT USB-m Stick, vendor= 0xfcf, product=0x1009(4105) 13:21:51,010: GetDongle - Send reset string to dongle 13:21:51,010: GetDongle - Dongle found: manufacturer=Dynastream Innovations, product=ANT USB-m Stick, vendor= 0xfcf, product=0x1009(4105) 13:21:51,010: GetDongle - Send reset string to dongle 13:21:51,512: GetDongle - Read answer 13:21:51,547: ReadFromDongle() returns: ["a4 01 6f 00 ca"] 13:21:51,547: GetDongle - Check for an ANT+ reply 13:21:51,547: GetDongle() returns: Using Dynastream Innovations dongle 13:21:51,547: Using Dynastream Innovations dongle ...

The software uses usb.core.find() which returns two dongles with type 4105; the first one gives an error on the "Send reset string" (because it's in use by FortiusANT), on the second device the "Send reset string" goes well, an answer is received and the software proceeds. By the way: FortiusANT and ExplorANT use the exact same loop.

It COULD mean that, when I think I use the second dongle, that actually the first is tried and hence is in use.

iainhay commented 4 years ago

Log files for -d1, -d3 and -d7

ExplorANT.2020-04-13 13-45-27.log ExplorANT.2020-04-13 13-46-26.log ExplorANT.2020-04-13 13-45-55.log

WouterJD commented 4 years ago

There is another error now, as if there are no dongles in your system Could not find ANT-dongle where previously you reported GetDongle: [Errno 19] No such device (it may have been disconnected).

In this case, I would power-down the system, take out the dongles (so that they are powered down as well), reboot and see whether there is any difference.

WouterJD commented 4 years ago

Please download logfile.py and antDongle.py and retry test withExplorAnt -d3

The dongle that is tried is printed to the logfile, let's see whether the second attempt indeed tries the second dongle.

WouterJD commented 4 years ago

Hi guys! ...I downloaded the Python code for FortiusANT but when running the module it says "ModuleNotFoundError: No module named 'numpy'". Would you please describe the installation process you used on mac??? THX

Welcome on board! pip install -r requirements.txt should do the job, please try

iainhay commented 4 years ago

Log file attached. Still seeing a similar error - I've checked and my mac recognises both dongles as being plugged in. I also restarted etc as mentioned.

ExplorANT.2020-04-14 08-15-35.log

M4M4R2 commented 4 years ago

Hi, Python shell doesn't accept pip install : "SyntaxError"! I didn't see that one since coding in Basic in the early eighties! Here is the log : Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information.

======= RESTART: /Applications/FortiusANT-master/pythoncode/FortiusAnt.py ====== Traceback (most recent call last): File "/Applications/FortiusANT-master/pythoncode/FortiusAnt.py", line 119, in import numpy ModuleNotFoundError: No module named 'numpy' pip install -r requirements.txt SyntaxError: invalid syntax

M4M4R2 commented 4 years ago

I tried "python -m pip install". Didn't work neither! Now I'm confused!

WouterJD commented 4 years ago

Log file attached. Still seeing a similar error - I've checked and my mac recognises both dongles as being plugged in. I also restarted etc as mentioned.

Please download antDongle.py and re-test; I have changed the error-handling in the module. It seems "in use" works different than under Windows/Linux

WouterJD commented 4 years ago

I tried "python -m pip install". Didn't work neither! Now I'm confused!

I do not have a Mac, so cannot test for you. "Didn't work neither" is not very clear, what messages do you get?

Perhaps google helps...