Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CYPLUS ANT+ Dongle - "Device does not work correctly" error #65

Closed
ElDonad opened this issue Apr 26, 2020 · 96 comments
Closed

CYPLUS ANT+ Dongle - "Device does not work correctly" error #65

ElDonad opened this issue Apr 26, 2020 · 96 comments

Comments

@ElDonad
Copy link

ElDonad commented Apr 26, 2020

Hello !
I have in mind since a few days to connect my old i-magic trainer to Zwyft, and I have bought two ant+ dongle (from Amazon, labelled CYCPLUS, id 0fcf:1008, Dynastream Innovation Inc.) and tried to run FortiusANT as well as antifier both on my linux and windows machine.

So far I haven't been able to run it successfully as I encountered several problems. Maybe would you have a clue about what it is ?

So, on linux the ANT didn't allow connection (errno 16: Busy) and I managed to overcome that by disabling the kernel drivers on code (basically copy-paste of https://stackoverflow.com/a/36505328). Now the ANT device is recognized as well as the trainer, but as soon as I click "Start" the console get flooded with read/write error (errno 30), happening directly after the dongle reset, from what I have been able to debug.

On windows the situation is the same, the ANT device is recognized as well as the trainer, but on clicking start I get this :

19:03:21,672: ------------------
19:03:21,672: Version info for the components
19:03:21,673:         FortiusAnt = 2020-04-07
19:03:21,673:          antDongle = 2020-03-31
19:03:21,674:             antHRM = 2020-02-18
19:03:21,675:              antFE = 2020-02-18
19:03:21,675:              debug = 2020-03-04
19:03:21,676:  FortiusAntCommand = 2020-03-25
19:03:21,676:      FortiusAntGui = 2020-04-07
19:03:21,677:            logfile = 2020-03-24
19:03:21,677:    structConstants = 2020-01-25
19:03:21,677:         usbTrainer = 2020-03-29
19:03:21,678:           argparse = 1.1
19:03:21,678:              numpy = 1.17.4
19:03:21,679:             pickle = 4.0
19:03:21,684:           platform = 1.0.8
19:03:21,685:       sys (python) = 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]
19:03:21,685:                usb = 1.0.2
19:03:21,686:                 wx = 4.0.7.post2
19:03:22,210: Dongle    receive: synch=0xa4, len= 1, id=0x6f Start up             , check=0xea, info="20"
19:03:22,233: Dongle    timeout
19:03:22,234: Dongle - Using CYCPLUS dongle
19:03:22,234: Tacx   - Simulated Trainer
19:03:22,235: ResetDongle()
19:03:22,236: Dongle    send   : synch=0xa4, len= 1, id=0x4a Reset System         , check=0xef, info="00"
19:03:22,737: Calibrate()
19:03:22,737: ResetDongle()
19:03:22,738: Dongle    send   : synch=0xa4, len= 1, id=0x4a Reset System         , check=0xef, info="00"
19:03:23,239: Dongle    send   : synch=0xa4, len= 2, id=0x4d Request Message      , check=0xbf, info="00 54" msg=0x54
19:03:23,239: Dongle    drop   : synch=0xa4, len= 1, id=0x6f Start up             , check=0xea, info="20"
19:03:23,263: Dongle    timeout

and then `SendToDongle write error, reaping request failed, win error : * a device attached to the system is not functionning*, and multiple ReadFromDongle read error.

So the problem seems to come from the dongle, however running antifier from linux, which from what I understand uses instead the serial interface of the dongle, I was able to connect from Zwyft to antifier (even if the head unit wasn't supported).

So here I am. I don't know what I could try next or event where the problem come from. Has someone any clue ? Thanks a lot in advance...

@WouterJD
Copy link
Owner

Please verify whether you have most recent software downloaded, if so let's have a look.
Quite some error handling has been improved lately.

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

Hello, thanks for your reply !
Yes, I git clone whenever I need a new copy of the software.

@WouterJD
Copy link
Owner

Do you use .exe (is older) or .py?

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

The .py one. python FortiusAnt.py -s -a.

@WouterJD
Copy link
Owner

Ok will check later. Please send logfile of the version you run -d127

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

Done, thank you much !
FortiusANT.2020-04-27 15-17-33.log

(sorry for the french Windows error messages)

@WouterJD WouterJD changed the title Various issues CYPLUS ANT+ Dongle - "Device does not work correctly" error Apr 27, 2020
@WouterJD
Copy link
Owner

Hi Elie, bon jour!

It's strange you have an error on Linux AND windows.
I understand the logfile is from Windows

Detecting the ANT-dongle goes well; Tacx trainer is irrelevant (-s flag).
I did not see a manufacturer=CYCPLUS ANT-dongle before, but that is not necessarily an issue.

The dongle responds normally untill 15:17:35,153 and then the message
15:17:35,627: devAntDongle.write exception: [Errno None] b'libusb0-dll:err [_usb_reap_async] reaping request failed, win error: Un périphérique attaché au système ne fonctionne pas correctement.' (Device does not work correctly)

Since some commands are received and responded correctly, basically your FortiusANT installation is OK and therefore it sounds like a driver issue. Cannot help you right now with this, perhaps somebody else following FortiusANT has a clue?

Just for my information; where are you located?

@WouterJD
Copy link
Owner

Hmmm... I read Iainhay's note on CYPLUS ANT-sticks: #45 (comment) seems like bad news on this kind of dongles.

@iainhay
Copy link

iainhay commented Apr 27, 2020

Just to jump in, I had similar issues as referenced by @WouterJD - it was an issue with the CYCPLUS dongles, I ordered these to help confirm it was or wasnt the issue and these worked straight away.

Not sure why the CYCPLUS ones don't work, I'm going to try and find out why and what the difference is but changing the dongles should solve the issue.

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

Alright, merci de vos réponses !

So the ant dongle are causing the issue, weird...
Something I noticed is that the driver of the linux version of antifier is working properly (that said, is able to communicate with the other dongle). I will check tomorrow if the windows version works as well, if so we might have the beginning of an answer, if not I will have either to implement the serial interface for FortiusANT, or the 1902 head unit support for antifier. Probably which one is the simplest, I don't have much knowledge about ant or serial drivers tough ...

Anyway, if you want to experiment with these devices, I could get you an ssh server running, tell me if you're intrested !

EDIT : an article I got from googling a bit, for what it's worth 😄 : https://tacxfaqx.com/knowledge-base/cycplus-ant-stick/

@WouterJD
Copy link
Owner

The antifier code contains solutions for a serial interface (see antifier.py and search for posix).
Since FortiusANT works on windows, linux, macOS, etc I am not very inclined to restore the serial interface because some dongles do not work correctly...

Unless somebody has a clear reason to do that and a solid condition when that interface should be used...

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

Yes, I can understand that. But anyway, following what was being said by the article, the dongle "zwift-side" may cause the same kind of issue, even if they seem to connect. I will try to investigate a bit further, since these little pieces of scrap aren't cheap nor quick to deliver ^^ but I might eventually end up buying another model...

@WouterJD
Copy link
Owner

I understand Elie, and I understand that ANT+ dongles may be difficult to get.
I leave you to it to resolve the issue, but will limit effort for this issue.

@ElDonad
Copy link
Author

ElDonad commented Apr 27, 2020

Alright, thank you again for your advice ! I will try to post here the eventual results of my investigations, but for now I think I can consider this thread closed.

@ElDonad ElDonad closed this as completed Apr 27, 2020
@totalreverse
Copy link

Just a thought: several ANT+ implementations add two (or more) '0x00' bytes after the checksum. Maybe some dongles need these additional dummy bytes?

@mattipee
Copy link
Contributor

I have just received two of these dongles.

The error I get is:
23:17:15,413: devAntDongle.read exception: [Errno None] b'libusb0-dll:err [submit_async] submitting request failed, win error: The device does not recognize the command.\r\n'
23:17:15,415: devAntDongle.write exception: [Errno None] b'libusb0-dll:err [submit_async] submitting request failed, win error: The device does not recognize the command.\r\n'

Adding the two null bytes after checksum (in ComposeMessage()) didn't help in my case.

@WouterJD
Copy link
Owner

Just a thought: several ANT+ implementations add two (or more) '0x00' bytes after the checksum. Maybe some dongles need these additional dummy bytes?

Antifier had two 0x00 bytes in every message and these did not make it to ComposeMessage() because there was no indication whatsoever why these 0x00's were there. Perhaps not smart after all; they will there for a reason.
@totalreverse would you recommend to add these padding bytes? I have experience (and others) that ANT dongles "hang" and need full power-down-restart to get working properly again. Could that be related? Do 0x00 bytes give the dongles "space to breathe"?

Suggestions and hints welcome, and yes @mattipee I have read your test-result.
Thanks guys!

@mattipee
Copy link
Contributor

FortiusANT.2020-04-28 06-53-43.log
@WouterJD for visibility, here's the log from the start.

@mattipee
Copy link
Contributor

@WouterJD subject line to "CYCPLUS"

On Linux, I see "Pipe error" followed by many "No such device" errors. Note that in /var/log/messages, I see the ANT+ adapter reconnecting with a different numeric id. Also note that I appear to be able to restart FortiusANT repeatedly and it looks very much like every second attempt will succeed, and every other attempt will fail. I haven't checked that another device can read what the is being sent using the CYCPLUS, but FortiusANT doesn't always fail.

I wonder perhaps if it's worth implementing a three-retries approach to starting ANT+, certainly being defensive and failing and stopping automatically if there's nothing but exceptions.

@WouterJD
Copy link
Owner

Be my guest for a code-suggestion.
It feels like programming around a faulty device, however, but I'm OK to adopt code when suggested.

@WouterJD
Copy link
Owner

PS. Perhaps an idea to log an issue in pyusb; I have the impression that they respond pretty fast. Perhaps they have a suggestion...

@ElDonad
Copy link
Author

ElDonad commented Apr 29, 2020

Hello again !
I have done some debugging on my side, and after having butchered your code to work with linux's serial interface, I was able to determine that the device return an error upon sending the event 4e (broadcast message). Here is the error message I got (deciphered with the ANT+ specification, not exactly sure of what I'm doing here...)
a4 : start
03 : size
40 : message channel
01 : channel number
01 : message id
09 : message code : EVENT_CHANNEL_COLLISION
ee : checksum

EDIT : it appears that the problem is found also with antifier, so I'm assuming that even if I was able to connect the two dongles using antifier, I wouldn't have been able to get them to run, since this message come after all the channel setup, and is used to broadcast data.... Again I'm not a specialist, this is only blind guesses and I might be wrong.

@WouterJD
Copy link
Owner

Please send the logfile as generated with -d127

@WouterJD
Copy link
Owner

WouterJD commented Apr 30, 2020

PS, where are you from Elie? I like to know about the spread of FortiusANT and if you can, give me a ping on Strava: https://www.strava.com/athletes/2885978

@martingeraghty please join this issue (#67 closed)

@aegisdesign
Copy link

Succes guys with the hard work you are doing together.
Please bear in mind that you are solving a buggy device, for which most likely no neat solution is available!

I think this is the problem here. Yesterday I also had the dongle that was receiving data into Zwift disconnect and not reconnect so I would guess even if we work around the buggy CYCPLUS dongle in FortiusANT, it'll be an issue elsewhere. I've requested a refund on the two CYCPLUS dongles I have and I'll try a different brand. This may be tricky as there's dozens of these cheap dongles with different branding but identical physical appearance and even images on ecommerce sites but with different logos printed/shopped on them.

@mattipee
Copy link
Contributor

mattipee commented May 4, 2020

@aegisdesign Thanks for your contributions. Less than perfect dongles, agreed. ANSELF are the go-to. Good luck.

@martingeraghty
Copy link

Thanks to everyone for all their hard work on this, you've all inspired me away from my Django development and into some electrical engineering (which is a bit beyond me just now). I'm going to have a look at using Bluetooth as an interface to try to get away from the ant dongles. Note that mine say ANSELF on them but CYCPLUS once connected...

@WouterJD
Copy link
Owner

WouterJD commented May 4, 2020

Going to bluetooth would imply building bluetooth into FortiusANT or other bridge.
Bying working dongles may be a shorter path.

@aegisdesign
Copy link

Note that mine say ANSELF on them but CYCPLUS once connected...

Hmm. I can see lots of buy->test->return->refund coming up. I was about to pull the trigger on buying the ANSELF dongles on Amazon.

@WouterJD I'm not sure finding working dongles would be a shorter path!

@ElDonad
Copy link
Author

ElDonad commented May 4, 2020

I will do the PR on the branch you mentionned. For the kernel driver detachement on linux, I can try to put it as a separate cl argument, or just remove it if nobody is intrested. You tell me.

Yes, this device seems a perfect exemple of crappy engineering, but as I'm not disposed to buy an ant dongle three times the price of a bluetooth dongle, they will have to do it ^^

@WouterJD thanks to you and your work ! It's already incredible that we are able to use our old trainers with the most recent technologies ! (a little bit disappointed though, I would have assumed that Swift would support steering wheel movements... 😢 )

@TrevorHunter
Copy link

Yes a huge thank you to you all for your amazing work. I'd almost given up on using my old trainer, especially as my model only had a 32bit driver from Tacx. I've ordered some new dongles anyway, but they will likely not arrive for a couple of weeks, but will send back the Cycplus ones for a refund (but have up to May 31st to do so), so happy to test any code changes before that time if I can help in anyway?

@ElDonad
Copy link
Author

ElDonad commented May 4, 2020

Well, the code we have for the moment "just works", that's all it is required from it honestly ^^
We could dive deeper in the log files to see what exactly is causing the device to reset, but since it is probably an awkward combinaison of poorly implemented software and crappy hardware, I won't bother studying that, for my own sanity !

I would however be pleased if you could try to do an extended run with the existing codebase, to see if the reconnection is reliable enough...

@mattipee
Copy link
Contributor

mattipee commented May 5, 2020

As optimistic as I was, I had a bad evening with CYCPLUS tonight.

Personally, one for a rainy day. :/

@WouterJD
Copy link
Owner

WouterJD commented May 6, 2020

I will do the PR on the branch you mentionned. For the kernel driver detachement on linux, I can try to put it as a separate cl argument, or just remove it if nobody is intrested. You tell me.

Yes, this device seems a perfect exemple of crappy engineering, but as I'm not disposed to buy an ant dongle three times the price of a bluetooth dongle, they will have to do it ^^

@WouterJD thanks to you and your work ! It's already incredible that we are able to use our old trainers with the most recent technologies ! (a little bit disappointed though, I would have assumed that Swift would support steering wheel movements... 😢 )

Elie, I understand that FortiusANT works for you right now. Could you please share the code with me (share a link to the working version) I will then integrate in the FortiusANT code base.

"Zwift would support steering wheel movements" --> The Fortius steering wheel cannot be communicated to Zwift, because the ANT FE-C interface does not provide messaging for it. BUT: if you use Zwift Companion and attach it to your steering-wheel, the companion will transmit the movements to Zwift. Please try and let me know.

@WouterJD
Copy link
Owner

WouterJD commented May 6, 2020

I have created a branch to submit code for the work on this issue:
https://github.com/WouterJD/FortiusANT/tree/***-CYPLUS-ANT****-Dongle-support [removed]

Elie; perhaps it's an idea you submit your code here using a Pull Request?

Please retry the PR, I've been experimenting a bit in github and may have lost your input.
https://github.com/WouterJD/FortiusANT/tree/65-CYPLUS

@WouterJD
Copy link
Owner

WouterJD commented May 6, 2020

@ElDonad Thanks for your investigations!

@WouterJD
Copy link
Owner

WouterJD commented May 7, 2020

@ElDonad @mattipee @TrevorHunter @aegisdesign @martingeraghty @aegisdesign @iainhay

Based upon the investigations done by Elie and Matthew, combined with the invaluable lessons I learned from Matthew last night, error-recovery is implemeted for unwilling dongles.

At first, CYCPLUS dongles don't like the ResetDongle() command, other than at session-startup. So it is disabled.

Secondly, the dongle goes "offline" and must be reconnected. This is what FortiusANT now does: after an error, the dongle is found again and all channels are paired again. So it required some work.
In my situation (I have no CYCPLUS dongle) I can remove the dongle while running and pluggin in (even another one) and FortiusANT and ExplorANT continue to run.

So my request to you is to test this from the https://github.com/WouterJD/FortiusANT/tree/65-CYPLUS branch.

If results are positive, I will promote to the master.

--- Target*** variables now survive restart. So please retry

@ElDonad
Copy link
Author

ElDonad commented May 7, 2020

Yep, that helped greatly ! By the way, completly unrelated, but Zwift seems to expect imperial miles from the dongle instead of kilometers... Don't know if it is a known issue, but the workaround shoudln't be too hard to develop ^^

Anyway, my dongle's stability is still bad, but I will try with another, more modern pc to see if it changes anything (maybe on windows too, who knows ?). Anyway, thanks a lot for taking the time to support such a crappy piece of hardware when we could just buy a working setup instead ! 😄

@ElDonad
Copy link
Author

ElDonad commented May 7, 2020

Oh, and I just read your post about the working version, so sorry, here it is : https://github.com/ElDonad/FortiusANT

Now that I managed to convert it to V2.6, I should be able to PR.

EDIT : come on, did I really PR to the wrong branch ? Shame on me, I change that immediately.

@ElDonad
Copy link
Author

ElDonad commented May 7, 2020

BUT: if you use Zwift Companion and attach it to your steering-wheel, the companion will transmit the movements to Zwift. Please try and let me know.

Yes, I saw something like that, interesting workaround ! I might give it a try as well. Thanks for the info !

@WouterJD
Copy link
Owner

WouterJD commented May 7, 2020

By the way, completly unrelated, but Zwift seems to expect imperial miles from the dongle instead of kilometers... Don't know if it is a known issue, but the workaround shoudln't be too hard to develop ^^

If that actually is the case, please raise a separate issue.
I would be curious how this is covered by the ANT+ specs.

@TrevorHunter
Copy link

Not sure if this helps, lots of disconnection/connections, however had successful ride on zwift for 31 mins... By the way, I've also bought 2x Suunto dongles which work perfectly, so will be sending back the Cycplus ones, however can hang onto them for another week if helps any debugging?

FortiusANT.2020-05-12 18-31-28.log

@WouterJD
Copy link
Owner

@TrevorHunter thanks for the logfile. It shows that the CYCPLUS dongle disconnects multiple times per minute and that FortiusANT successfully recovers from the disconnect. It's the best we can achieve I think. Thanks for sharing the experience.

#65 can therefore be marked as solved in release 3.0

@WouterJD
Copy link
Owner

see also #115 (comment)

@smiley1962
Copy link

Wouter,

Wel opgelet maar niet goed genoeg blijkbaar, heb 2 van de cyplus dongles binnen gekregen, maar ze geven inderdaad een foutmelding error 110 en error 32.
Ik heb niet goed begrepen of je de code hebt kunnen aanpassen of dat ik ze beter kan vervangen.

@WouterJD
Copy link
Owner

dit komt niet bekend voor; vervangen lijkt me... Dikke pech

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants