PyBushido code up

Overview of PyBushido:

bushido_logger.py

replicates Tacx TTS slope distance mode (headunit enters PC Communication mode)

functionality:

  • logs data to console
  • slope buttons (up and down arrows) implemented

bushido_middle.py

a simple man in the middle implementation for snooping on communication from the headunit to the brake.

to use:

  • start training on tacx headunit
  • run bushido_middle.py
  • you can optionally edit injections.py to modify data before retransmission

Source code

You can grab all the source code we are using to reverse engineer the Tacx Bushido here:

Cowboy Coders Github

7 thoughts on “PyBushido code up”

  1. Hi,

    I have a Tacx Genius and I’m trying to log communications between the pc and the brake/headunit, I’m running the python scripts on a mac with 2 ant+ sticks. I’m successfully running ant-server.py, ant-server2.py and bushido_middle.py. However I do not see any kind of communications going thru. I looked at the code and changed the device type and id in the assignBrakeChannel function to match my genius brake but that did not help. I tried changing the device type in assignRetransmitChannel as well but I’m not sure what I should be using for the id…
    Basically I’m looking for help setting all this up, is there some kind of pairing necessary to make it work?

    Thanks,

    Pyt

  2. Hi, good to see you back and working on the genius!

    We were using wireshark with this dissector: https://github.com/cowboy-coders/wireshark-ant for logging the traffic. You could extend the class event.EventCallback, add some logging to its process function, and add an instance to each channel.

            self.daemon.register(self.retransmit_listener)
            self.retransmit_channel.registerCallback(self.retransmit_listener)

    Have you verified python-ant is working? If you have an ant+ heart rate strap you could try https://github.com/cowboy-coders/python-ant/blob/develop/demos/ant.core/ant-client.py in conjunction with ant-server.py.

    I recommend you remove InputThread as that was just a hack to allow toggling of the channels via button presses and isn’t really needed. Otherwise you may need to use a mac compatible version of Getch (See http://code.activestate.com/recipes/134892/)

  3. Also this setup logs the traffic flow:

    bushido brake < --> bushido_middle.py < ---> bushido headunit

    normal operation:

    bushido brake < --> bushido headunit

    pc connection:

    bushido brake < --> bushido headunit < --> pc

    To get our setup:

    bushido brake < - brake_channel -> bushido_middle.py < - retransmit_channel -> bushido headunit

    to work, we did the follwoing:

    – power off the headunit
    – setup ant channel to connect to the brake, this is named brake_channel (we used the id from previous communications, but just wild card this). This should look exactly like the headunit to the brake (i.e a slave).
    – power on the headunit
    – establish a second ant channel with the headunit (we named this retrasmit channel). The channel id can be whatever you want. This should look exactly like the brake to the headunit (i.e the master).

    NOTES:

    – the ordering is ensured as once the brake has established a connection with our brake_channel, it will not then attempt to establsh a connection with the actual headunit. So by powering off the headunit we can (almost) guarentee it will pair with the retransmit_channel and not the actual brake (as long as the brake channel has been established by that point). We set channel.setSearchTimeout(TIMEOUT_NEVER) so that the channel will continue searching whilst the headunit is powered off.
    – no pairing bit is needed for the bushido

    Do you pair the brake and the headunit in Tacx TTS? Or is all traffic routed through a single component (brake or headunit)?

  4. Hi, thanks for all the info, I’ll try to get things going soon.

    As far as I understand, I believe this is the way the genius setup work:

    genius brake pc <—- genius headunit

    The Tacx software does not let you connect to the brake before the head unit is connected.
    The unit is just a stupid controller, it's just used to control the software and does not seem to control the brake directly. I'll have to remove the batteries of the controller during a workout and see what happens.

    Gonna try to connect to my heart rate strap now.

    I'll keep you posted.

    Thanks,

    Pyt

  5. Nice. Maybe this will work then:

    – turn the brake off
    – run bushido_middle.py (with your brake settings)
    – start TTS and try and find brake
    – turn on the brake (hopefully bushido_middle will have already paired with TTS)
    – the brake should now pair with bushido_middle
    – TTS should successfully pair with the brake (but with all data going through bushido_middle)
    – log all the packets that go through bushido_middle.py

    I’ve mentioned before, but also bear in mind that the client/server setup is a little tempormental and you may need to replug the sticks and restart the server if the client doesn’t quit cleanly. The server also seems to occasionally hang.

    NOTE: I’ve left some injections in injections.py. You should comment these out (or remove them) as they will change the data packets passing through. This file can be modified on the fly (as it is running) – this is useful when you want to see which packet affects which reading (just inject some large numbers)

Leave a Reply

Your email address will not be published. Required fields are marked *