native ant not a type

153 views
Skip to first unread message

drew...@gmail.com

unread,
May 3, 2020, 12:43:51 PM5/3/20
to ant-api
Yesterday after modifying bootloader/softdevice on my adafruit nrf5 I tried some ant examples. When trying to compile the native ant example I get the following error:

NativeAnt:16:1: error: 'NativeAnt' does not name a type; did you mean 'BaseAnt'?

 NativeAnt ant = NativeAnt();

Does anybody know what this could be? I explored the libraries and NativeAnt seems to be defined.

Curtis Malainey

unread,
May 3, 2020, 4:03:58 PM5/3/20
to drew...@gmail.com, ant-api
Ah that is because I haven't finished that code (see example header), there is a massive refactor going on in the develop branch to fix a bunch of stuff and support for native, spi and 3 new RTOSes. I wrote the example early as a CI test, sorry for that.

--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/0095f403-241f-4037-b2f3-d416d8e579f0%40googlegroups.com.

drew...@gmail.com

unread,
May 3, 2020, 8:47:49 PM5/3/20
to ant-api
Ah I see thanks for the swift reply. Is that to say that native ant doesn't work yet/adafruit nrf52xxx devices are not yet supported?

Wondering what my next best course of action would be. Project involves sending torque data to a garmin 500 edge. If I can get the adafruit nrf52840 to work in the arduino environment that would be ideal but perhaps I may have to brush up on my C++ and go about it the manual way. 

On Sunday, May 3, 2020 at 4:03:58 PM UTC-4, Curtis Malainey wrote:
Ah that is because I haven't finished that code (see example header), there is a massive refactor going on in the develop branch to fix a bunch of stuff and support for native, spi and 3 new RTOSes. I wrote the example early as a CI test, sorry for that.

On Sun, May 3, 2020 at 9:43 AM <drew...@gmail.com> wrote:
Yesterday after modifying bootloader/softdevice on my adafruit nrf5 I tried some ant examples. When trying to compile the native ant example I get the following error:

NativeAnt:16:1: error: 'NativeAnt' does not name a type; did you mean 'BaseAnt'?

 NativeAnt ant = NativeAnt();

Does anybody know what this could be? I explored the libraries and NativeAnt seems to be defined.

--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant...@googlegroups.com.

Curtis Malainey

unread,
May 3, 2020, 9:23:51 PM5/3/20
to drew...@gmail.com, ant-api
Just that the libraries do not work yet, so you won't be able to use the byte parsing construct built into ANT+ yet. You can still call the softdevice API directly and write the profile into the code. The board is still usable, the APIs are available. My living situation changes starting next weekend, which means I will be able to work more on the driver. I can see if I can get the native driver support going. I think I only have a few finicky bits of code left (like handling return codes.) That being said, bike power is also not implemented into ANT+ so that would need to be integrated as well but that should be fairly easy as long as you don't factor in the secondary channel part.

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/c251d1cd-8f44-4395-8c45-d30586ed2a77%40googlegroups.com.

drew...@gmail.com

unread,
May 4, 2020, 11:12:59 PM5/4/20
to ant-api
Hello apologies for my delay. Native support would be great as I am a mechanical engineer by trade with mostly self-taught programming experience. Your libraries have been a huge help so far.

Honestly I don't know how to call the softdevice api into the arduino ide environment successfully. I'm going to have to study softdevices and the sdk more to understand what exactly is going on. I have a decent grasp on how device profiles work so I think getting the power meter to work shouldn't be too bad once I get ant+ working in general. 

Any advice or guidance from anyone who has done this would be greatly appreciated. Say, for example, how could one with an adafruit/arduino with native nrf52xxxx get the HR Display Example working? I will be continually investigating this myself and will keep everyone updated.

Curtis Malainey

unread,
May 5, 2020, 12:22:55 AM5/5/20
to drew...@gmail.com, ant-api
No worries, im guessing we all have day jobs :) Sounds good, I will try and give them another push starting on the weekend.

Not much to study there thankfully. The softdevice is much like a kernel, you call into it and it does things for you. When you downloaded it from thisisant.com you should have gotten two header files: ant_interface.h and ant_parameters.h. Those define the softdevice interface (you will see a bunch of SYSCALL definitions.) Read the docstrings for how to call them. The function calls should mirror the ant-arduino messages fairly closely as that is how the ant networking firmware is built (which ant-arduino was originally built for.) I'm glad the library has been a help.

For example in the openmessage example.

```
    cp = ChannelPeriod();
    cp.setChannel(0);
    cp.setPeriod(1234); //can't wildcard this
    ant.send(cp);
    parseMessage();
```
is converted to
```
sd_ant_channel_period_set(0, 1234);
```

If you want to see the confirmed conversion you can look at either the ant networking firmware and read by conversions. Another solution is you can checkout the develop branch for ant-arduino and see in the code what each message calls in the API mode. 

see for example src/TX/Config/ANT_ChannelPeriod.cpp (on the develop branch) you will see 

```
uint32_t ChannelPeriod::execute() {
    return sd_ant_channel_period_set(_channel, _period);
}
```
Which shows that setting the channel period is done by executing that command. Receiving data on the other hand is a bit trickier. It involves calling sd_ant_event_get and having it fill a buffer you made then parsing out the information passed back (also something I have to complete for the driver.)

Curtis

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/560b4759-74d6-40be-ba33-1ba58a874bd6%40googlegroups.com.

Gábor Ziegler

unread,
May 5, 2020, 10:11:44 AM5/5/20
to Curtis Malainey, drew...@gmail.com, ant-api
Hi,

I have a working example of ANT+ HRM with the S340 on the Adafruit nRF52840 Express Feather. Let me know if that fits your situation.
That is somewhat tricky, as that Feather is a Bluefruit Feather and I wanted to retain the Bluefruit capability, i.e., to use the SD in multi-protocol mode.

Note: the soft device approach necessitates an interrupt-driven approach, you must make yourself familiar with the concept of "interrupt handlers" and "callback functions" at least. If you want to use the Bluefruit lib together with ANT+, then at-least a basic competence in in multithreaded programming models (semaphore handling, concurrently running tasks in a time-shared manner, etc.) in general, and FreeRTOS in particular is a must.  If the concepts above sound as Klingon-speech to you, then it is better to learn a little about them first, as lack of that knowledge might cause a  lot-of frustration during programming.

Furthermore, usign my example would mean that you would need to install an ANT enabled S3xx series softdevice to your board

Having said that, the simplified API call sequence for receiving ANT+ HRM sensor data is more-or-less as follows. This might help your current effort (Note, that I have omitted details about interworking with the Bluefruit stack):
  1. Enable the softdevice by calling sd_softdevice_enable(...)
  2. Enable the ANT+ stack by
    1. "Mallocating" a suitably sized ANT stack buffer, possibly relying on the ANT_ENABLE_GET_REQUIRED_SPACE(..) macro from the nRF5 SDK
    2. Calling the sd_ant_enable() method and supplying the buffer to it in order to enable ANT operation
  3. Set ANT+ network address via sd_ant_network_address_set()
  4. Setup your ANT HRM profile in "display" mode.
    1. Assing a channel to it via sd_ant_channel_assign()
    2. assign proper channel number, device number, device type and transmission type via sd_ant_channel_id_set()
    3. Set RF frequency to ANT+ frequency via sd_ant_channel_radio_freq_set()
    4. Set channel period via sd_ant_channel_period_set()
  5. Add your ANT+ event handler callback
    1. Implement  the SD_EVT_IRQHandler() interrupt handler method from the SoftDevice API 
    2. Enable SD interrupts using the handler above via: NVIC_EnableIRQ(SD_EVT_IRQn);
With this you are "ready" to start receive events, including receive (RX) events from your sensors. You will need to implement ANT+ state  machine handling, as well, to handle channel-search timeouts, reconnects, etc.

To keep long story short: handling ANT+ sensors with Arduino is still an advanced-level task. I couldn't do this without the help of a fellow programmer (Ryan Green), with whom I got acquainted via Curtis. Ryan made a very efficient, but kinda "quick-and-dirty" task of amalgating nRF5 SDK examples  with the Adafruit Bluefruit52 code.

The approach by Ryan follows the Bluefruit and nRF SDK approach of amalgating SoftDevice and user-code in a callback/interrupt-driven approach. As it fits better my earlier programming experience from work and my plans for my own nRF52840 Feather project, therefore I use practically no code from the ant-arduino repo currently. (For me the ant-arduino logic is "built around" the concept of single threaded asynch serial communication to a remote ANT radio, which does not suite my use case.)

I have cleaned up and refactored somewhat Ryan's code and added further ANT´+ profiles. My code currently specific to the case of having the Bluefruit stack in place and to the S340 softdevice running on RF52840. If you plan to use a series S3xx softdevice and succesfully programmed your bootloader for that, then sharing my code might help you.

I guess it would be a small work to adapt to another BLE+ANT softdevice (e.g. to any 3xx series Nordic softdevices) with Bluefruit52 support and with  the Arduino framework.

///Gabor

drew...@gmail.com

unread,
May 5, 2020, 11:29:44 AM5/5/20
to ant-api
Curtis,

Thanks for the info. Your examples have cleared much of the smoke from the air and I'll continue to reference this as I push forward..

Gabor,

That would perfectly fit my situation as I am employing the nRF52840 with S340 sd. Only difference in my case is it is on the adafruit itsybitsy express board, but from what I understand can also incorporate the bluefruit functionality. As I already have the s340 sd successfully flashed, I think your examples would compile and flash without complications. Would love to try them out.

Thanks,
Drew



--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant...@googlegroups.com.

Curtis Malainey

unread,
May 5, 2020, 11:47:08 AM5/5/20
to Gábor Ziegler, drew...@gmail.com, ant-api
On Tue, May 5, 2020 at 7:11 AM Gábor Ziegler <orr...@gmail.com> wrote:
Hi,

I have a working example of ANT+ HRM with the S340 on the Adafruit nRF52840 Express Feather. Let me know if that fits your situation.
That is somewhat tricky, as that Feather is a Bluefruit Feather and I wanted to retain the Bluefruit capability, i.e., to use the SD in multi-protocol mode.

Note: the soft device approach necessitates an interrupt-driven approach, you must make yourself familiar with the concept of "interrupt handlers" and "callback functions" at least. If you want to use the Bluefruit lib together with ANT+, then at-least a basic competence in in multithreaded programming models (semaphore handling, concurrently running tasks in a time-shared manner, etc.) in general, and FreeRTOS in particular is a must.  If the concepts above sound as Klingon-speech to you, then it is better to learn a little about them first, as lack of that knowledge might cause a  lot-of frustration during programming.
Just a note, you can get away without using interrupts, but you do risk either wasting time polling (the typical arduino method) or possibly overflowing your event buffer. 
 
Furthermore, usign my example would mean that you would need to install an ANT enabled S3xx series softdevice to your board

Having said that, the simplified API call sequence for receiving ANT+ HRM sensor data is more-or-less as follows. This might help your current effort (Note, that I have omitted details about interworking with the Bluefruit stack):
  1. Enable the softdevice by calling sd_softdevice_enable(...)
Doesn't this call have to be wrapped by the TinyUSB calls? 

  1. Enable the ANT+ stack by
    1. "Mallocating" a suitably sized ANT stack buffer, possibly relying on the ANT_ENABLE_GET_REQUIRED_SPACE(..) macro from the nRF5 SDK
    2. Calling the sd_ant_enable() method and supplying the buffer to it in order to enable ANT operation
  2. Set ANT+ network address via sd_ant_network_address_set()
  3. Setup your ANT HRM profile in "display" mode.
    1. Assing a channel to it via sd_ant_channel_assign()
    2. assign proper channel number, device number, device type and transmission type via sd_ant_channel_id_set()
    3. Set RF frequency to ANT+ frequency via sd_ant_channel_radio_freq_set()
    4. Set channel period via sd_ant_channel_period_set()
  4. Add your ANT+ event handler callback
    1. Implement  the SD_EVT_IRQHandler() interrupt handler method from the SoftDevice API 
    2. Enable SD interrupts using the handler above via: NVIC_EnableIRQ(SD_EVT_IRQn);
With this you are "ready" to start receive events, including receive (RX) events from your sensors. You will need to implement ANT+ state  machine handling, as well, to handle channel-search timeouts, reconnects, etc.

To keep long story short: handling ANT+ sensors with Arduino is still an advanced-level task. I couldn't do this without the help of a fellow programmer (Ryan Green), with whom I got acquainted via Curtis. Ryan made a very efficient, but kinda "quick-and-dirty" task of amalgating nRF5 SDK examples  with the Adafruit Bluefruit52 code.

The approach by Ryan follows the Bluefruit and nRF SDK approach of amalgating SoftDevice and user-code in a callback/interrupt-driven approach. As it fits better my earlier programming experience from work and my plans for my own nRF52840 Feather project, therefore I use practically no code from the ant-arduino repo currently. (For me the ant-arduino logic is "built around" the concept of single threaded asynch serial communication to a remote ANT radio, which does not suite my use case.)
This is correct, the driver will add some code overhead in order to abstract the softdevice API for antplus-arduino and it is definitely not thread safe. 

Gábor Ziegler

unread,
May 5, 2020, 2:36:44 PM5/5/20
to drew...@gmail.com, ant-api
I have a private repo currently since my code stinks currently :P.
I am not ready to make public yet, but I plan to do that soon, say within 1-2 weeks. If you can't wait that long and  if you have a github account, Drew, then let me know you account id and I will try to give access.

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/def8df5e-b2c9-41ba-a87b-b1395cfde207%40googlegroups.com.

Curtis Malainey

unread,
May 5, 2020, 3:10:40 PM5/5/20
to Gábor Ziegler, drew...@gmail.com, ant-api
Sorry to sidetrack the thread, but I'm curious, Gabor, how do you plan to hide/obfuscate the ANT+ key? Are you sticking it in NVM/flash or special header using something like git-secret?

drew...@gmail.com

unread,
May 5, 2020, 3:14:12 PM5/5/20
to ant-api
Just joined github a few days ago.  Would love to have early access  - I don't mind stinky code xD

Gábor Ziegler

unread,
May 5, 2020, 3:25:07 PM5/5/20
to Curtis Malainey, drew...@gmail.com, ant-api
Hi Curtis,

See my inline c.omments

Curtis Malainey <cujoma...@gmail.com> ezt írta (időpont: 2020. máj. 5., K, 17:47):


On Tue, May 5, 2020 at 7:11 AM Gábor Ziegler <orr...@gmail.com> wrote:
Hi,

I have a working example of ANT+ HRM with the S340 on the Adafruit nRF52840 Express Feather. Let me know if that fits your situation.
That is somewhat tricky, as that Feather is a Bluefruit Feather and I wanted to retain the Bluefruit capability, i.e., to use the SD in multi-protocol mode.

Note: the soft device approach necessitates an interrupt-driven approach, you must make yourself familiar with the concept of "interrupt handlers" and "callback functions" at least. If you want to use the Bluefruit lib together with ANT+, then at-least a basic competence in in multithreaded programming models (semaphore handling, concurrently running tasks in a time-shared manner, etc.) in general, and FreeRTOS in particular is a must.  If the concepts above sound as Klingon-speech to you, then it is better to learn a little about them first, as lack of that knowledge might cause a  lot-of frustration during programming.
Just a note, you can get away without using interrupts, but you do risk either wasting time polling (the typical arduino method) or possibly overflowing your event buffer. 
Nope, not if you want to use the Bluefruit lib. That lib assumes that its user is an entry level Arduinoer, so it "hides the complexity" of Bluetooth handling. As such, it "hides" that Bluefruit is using FreeRTOS, and running 2 FreeRTOS threads ("tasks") concurrently: one BLE task (for BLuefruit code) and one SoC task (for the regular Arduino stuff).
Ryan's (and mine) adaptation introduces a 3rd task for ANT event handling, among other changes.
As such, a basic awareness of FreeRTOS, semaphores and "tasks" are very useful.

 
Furthermore, usign my example would mean that you would need to install an ANT enabled S3xx series softdevice to your board

Having said that, the simplified API call sequence for receiving ANT+ HRM sensor data is more-or-less as follows. This might help your current effort (Note, that I have omitted details about interworking with the Bluefruit stack):
  1. Enable the softdevice by calling sd_softdevice_enable(...)
Doesn't this call have to be wrapped by the TinyUSB calls? 
Well, yes. In fact  even more than that. As I have written:I have omitted details about interworking with the Bluefruit stack :)
As a matter of fact, the wrappers are needed not because of TinyUSB, but because enabling (i.e., activating) the SofDevice makes certain hardware resources "reserved" for exclusive access for the SoftDevice code. Certain memory-regions will became unavailable for user code, certain interrupts are intercepted by the SoftDevice and never delivered to use code, and last but foremost
  • certain peripherials become "protected" and unaccessible directly by user code while the SoftDevice is running
  • during SD operation certain peripherials can be accessed only via "supervisory mode" calls routed through the SoftDevice firmware.
Therefore such peripherials (I think the HW UART, among others) needs to be "released" by user code before calling sd_softdevice_enable()  and they can be accessed only via such supervisor calls (SVC calls). That is the reason for the tinyUSB pre- and post-enable wrappers.
I can't recall the link for the relevant NordicSemi document from the top of my head, but look for explanation for SVC (supervisory call) macros in the nRF5 SDK.

  1. Enable the ANT+ stack by
    1. "Mallocating" a suitably sized ANT stack buffer, possibly relying on the ANT_ENABLE_GET_REQUIRED_SPACE(..) macro from the nRF5 SDK
    2. Calling the sd_ant_enable() method and supplying the buffer to it in order to enable ANT operation
  2. Set ANT+ network address via sd_ant_network_address_set()
  3. Setup your ANT HRM profile in "display" mode.
    1. Assing a channel to it via sd_ant_channel_assign()
    2. assign proper channel number, device number, device type and transmission type via sd_ant_channel_id_set()
    3. Set RF frequency to ANT+ frequency via sd_ant_channel_radio_freq_set()
    4. Set channel period via sd_ant_channel_period_set()
  4. Add your ANT+ event handler callback
    1. Implement  the SD_EVT_IRQHandler() interrupt handler method from the SoftDevice API 
    2. Enable SD interrupts using the handler above via: NVIC_EnableIRQ(SD_EVT_IRQn);
With this you are "ready" to start receive events, including receive (RX) events from your sensors. You will need to implement ANT+ state  machine handling, as well, to handle channel-search timeouts, reconnects, etc.

To keep long story short: handling ANT+ sensors with Arduino is still an advanced-level task. I couldn't do this without the help of a fellow programmer (Ryan Green), with whom I got acquainted via Curtis. Ryan made a very efficient, but kinda "quick-and-dirty" task of amalgating nRF5 SDK examples  with the Adafruit Bluefruit52 code.

The approach by Ryan follows the Bluefruit and nRF SDK approach of amalgating SoftDevice and user-code in a callback/interrupt-driven approach. As it fits better my earlier programming experience from work and my plans for my own nRF52840 Feather project, therefore I use practically no code from the ant-arduino repo currently. (For me the ant-arduino logic is "built around" the concept of single threaded asynch serial communication to a remote ANT radio, which does not suite my use case.)
This is correct, the driver will add some code overhead in order to abstract the softdevice API for antplus-arduino and it is definitely not thread safe. 
Not the thread-safety is the most critical difference, IMHO. Simply stating:
  • ant-arduino assumes an active, synchronous, i.e., not event-driven code: it decides when to poll the ANT radio for events, for example.
  • Ryan's and mine code is a re-active, asynchronous , i.e., event-driven code: it makes no assumption about when will an RX event happen, it does not actbvely handle the reception in the main loop,  etc.
That is a somewhat subtle and but important difference in programming paradigms.
It is like using active, or passive verb tenses in an English statement. Both works, but they differ.

I know that you plan to make ant-arduino a "unified" library for both external, serial communication driven ANT radios and for embedded, co-located softdevice driven ANT-radios, but to be honest, I am yet to be convinced that such unification will result in a simple user-friendly API suitable for an everyday Arduinoer.

I am definitely looking forward to try your new code, when it will be ready. :)

Br,
Gabor
 

Gábor Ziegler

unread,
May 5, 2020, 3:31:46 PM5/5/20
to drew...@gmail.com, ant-api
Allright, I will try to shovel out the most stinky and embarrassing code-pieces and I will kick-out an inactive wannabe-programmer friend from the access list. (he never used his current access).  Explanation: I have free Github account where I am limited to having at most 3 participants per private repos.

I will give you access within 1-2 days.

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/c87593cf-8da1-45c1-bcf7-f205e0691d93%40googlegroups.com.

Gábor Ziegler

unread,
May 5, 2020, 3:46:59 PM5/5/20
to Curtis Malainey, drew...@gmail.com, ant-api
Hi,

My current solution is like this. https://github.com/orrmany/ANTplus-PoC/blob/develop/lib/ant/src/ANTProfile.h (you have had access already):
#if __has_include("ANT_Network_Keys.h") 
  #include "ANT_Network_Keys.h" //set the ANT+ Network key with #define in "ANT_Network_Keys.h"! 
#endif

#ifndef ANT_PLUS_NETWORK_KEY
   #warning ANT+ Network key is missing!!!
   #define ANT_PLUS_NETWORK_KEY    {00000000}            /**< The ANT+ network key. */
#endif //ANT_PLUS_NETWORK_KEY
#ifndef ANT_FS_NETWORK_KEY
   #warning ANT FS network key is missing!!!
   #define ANT_FS_NETWORK_KEY      {00000000}           /**< The ANT-FS network key. */
#endif // ANT_FS_NETWORK_KEY

Of course I won't publish ANT_Networks_keys.h...
/G/G

Curtis Malainey

unread,
May 5, 2020, 8:17:50 PM5/5/20
to Gábor Ziegler, drew...@gmail.com, ant-api
On Tue, May 5, 2020 at 12:25 PM Gábor Ziegler <orr...@gmail.com> wrote:
Hi Curtis,

See my inline c.omments

Curtis Malainey <cujoma...@gmail.com> ezt írta (időpont: 2020. máj. 5., K, 17:47):


On Tue, May 5, 2020 at 7:11 AM Gábor Ziegler <orr...@gmail.com> wrote:
Hi,

I have a working example of ANT+ HRM with the S340 on the Adafruit nRF52840 Express Feather. Let me know if that fits your situation.
That is somewhat tricky, as that Feather is a Bluefruit Feather and I wanted to retain the Bluefruit capability, i.e., to use the SD in multi-protocol mode.

Note: the soft device approach necessitates an interrupt-driven approach, you must make yourself familiar with the concept of "interrupt handlers" and "callback functions" at least. If you want to use the Bluefruit lib together with ANT+, then at-least a basic competence in in multithreaded programming models (semaphore handling, concurrently running tasks in a time-shared manner, etc.) in general, and FreeRTOS in particular is a must.  If the concepts above sound as Klingon-speech to you, then it is better to learn a little about them first, as lack of that knowledge might cause a  lot-of frustration during programming.
Just a note, you can get away without using interrupts, but you do risk either wasting time polling (the typical arduino method) or possibly overflowing your event buffer. 
Nope, not if you want to use the Bluefruit lib. That lib assumes that its user is an entry level Arduinoer, so it "hides the complexity" of Bluetooth handling. As such, it "hides" that Bluefruit is using FreeRTOS, and running 2 FreeRTOS threads ("tasks") concurrently: one BLE task (for BLuefruit code) and one SoC task (for the regular Arduino stuff).
Ryan's (and mine) adaptation introduces a 3rd task for ANT event handling, among other changes.
As such, a basic awareness of FreeRTOS, semaphores and "tasks" are very useful.
I still fail to understand how this requires it to be interrupt driven since the APIs are separate for events. I will have to run some tests once I get it setup to verify BLE is alive. Guess its time to live and learn :) 

Gábor Ziegler

unread,
May 6, 2020, 1:49:53 PM5/6/20
to drew...@gmail.com, ant-api

drew...@gmail.com

unread,
May 6, 2020, 3:12:52 PM5/6/20
to ant-api
I'm eager to check it out. Many thanks G

Gábor Ziegler

unread,
May 6, 2020, 4:28:52 PM5/6/20
to drew...@gmail.com, ant-api

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/befcba5d-b66f-4554-9a86-8f135c880f59%40googlegroups.com.

Curtis Malainey

unread,
May 25, 2020, 10:20:07 PM5/25/20
to Gábor Ziegler, drew...@gmail.com, ant-api
Sorry to revive a dead thread, but I think the softdevice code might take a bit longer. Im hitting a bug somewhere in GCC where for some silly reason the compiler is shifting the object pointer by 4 bytes and causing parental calls inside the child to return corrupted data. I am hitting it across gcc 7 through 9 but I have a pointer work around in gcc 9 at least.

Gábor Ziegler

unread,
May 26, 2020, 6:25:02 AM5/26/20
to Curtis Malainey, drew...@gmail.com, ant-api
Hmm, I remember a warning during compilation about the need of shifting some memory code by 4bytes . I will check later today

Gábor Ziegler

unread,
May 26, 2020, 3:41:24 PM5/26/20
to ant-api
Well, I have some warnings but it seems to work:
c:/users/egbozie/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes
c:/users/egbozie/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes
c:/users/egbozie/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes
c:/users/egbozie/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes
c:/users/egbozie/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .bss by 4 bytes

--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant...@googlegroups.com.

Curtis Malainey

unread,
May 28, 2020, 2:31:52 AM5/28/20
to Gábor Ziegler, ant-api
Yea I don't think that is related as my data is all having an issue on the stack. Basically if Im calling AntRequest functions from the main threat it use the pointer SP, but if I call from within subclass such as AntRxDataResponse or BroadcastData it uses SP + #4 and results in garbage. Compiling against teensy the same code, the stack code is also increased by #4 so its something isolated to the nrf code. Forcing the same compiler that teensy uses on the nrf build doesn't seem to fix it.

To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/035f7cf5-66d0-467a-9dc8-674ad3a6be56%40googlegroups.com.

Curtis Malainey

unread,
Jun 3, 2020, 4:10:57 AM6/3/20
to Gábor Ziegler, ant-api
Development is back on, figured out my bug, wow that was painful. Friend of mine suggested it a while back but I missed the location until I inspected the classes a bit closer. I had a header that had a #if in it to compile out some native ant functions, but I forgot to include the header that defined the check for that if. As a result the function was getting added and removed randomly based on what headers were included before it which created two different memory layouts for the class.

Gábor Ziegler

unread,
Jun 3, 2020, 10:36:11 AM6/3/20
to Curtis Malainey, ant-api
How is that possible? A class can't have more than one declaration, can it? Do you do some type-casting with the pointers?

Curtis Malainey

unread,
Jun 3, 2020, 12:54:43 PM6/3/20
to Gábor Ziegler, ant-api
The issue is the definitions are isolated to separate objects and the linker just checks the names.

https://github.com/cujomalainey/ant-arduino/blob/develop/src/RX/ANT_AntResponse.h#L136

So when you dump the class hierarchy you get the following definitions

In AntResponse.o you get:

Class AntResponse
  ¦size=12 align=4
  ¦base size=9 base align=4
AntResponse (0x0x104496f60) 0

In main.o you get:

Vtable for AntResponse
AntResponse::_ZTV11AntResponse: 3 entries
0     (int (*)(...))0
4     (int (*)(...))0
8     (int (*)(...))AntResponse::backfill

Class AntResponse
   size=16 align=4
   base size=13 base align=4
AntResponse (0x0x105596ae0) 0
    vptr=((& AntResponse::_ZTV11AntResponse) + 8)

As you can see the second definition has a vtable offset in its pointer. So main is offsetting the function calls to functions in AntResponse to handle the vtable case, where as classes such as AntRxDataResponse (which inherit the same definition as AntResponse due to the header architecture) and don't offset and results in data corruption and segfaults. Its a pretty gross bug.

Adding ANT_defines.h to AntResponse.h resolves these issues as it enforces the define switch is included.

Paolo Cecchini

unread,
Jan 31, 2022, 10:31:51 AM1/31/22
to ant-api
I just flashed bootloader and softdevice on this
board and I get the above error, still :)

Curtis Malainey

unread,
Jan 31, 2022, 11:59:02 AM1/31/22
to Paolo Cecchini, ant-api
Ah yes, it's because you are missing the build flag. if you are using the S340 softdevice for example add -DS340 to your build flag and the driver should become available. The reason is I have to compile out the API function calls on non-supported platforms.

--
You received this message because you are subscribed to the Google Groups "ant-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant-api+u...@googlegroups.com.

Paolo Cecchini

unread,
Jan 31, 2022, 12:40:41 PM1/31/22
to ant-api
Sorry,  I'm confused about that build flag.

I'd say I've actually built nothing. I just downloaded the feather_nrf52832_bootloader-0.3.2_s132_6.1.1.hex archive and flashed the board via raspberry and openocd, connecting, of course, the two SWD pins. Then I got to the Arduino IDE, set pin 20 to GND, and voila, the MCU is alive. I'm able to upload some example sketches from the Adafruit library, and they work, namely the meminfo.ino one.

Then I went to your nativeant example, I guessed I'd going to provide some include files on myself, but the compiler didn't blame me, apparently.

#include "ANT.h"
#include "bluefruit.h"

I'm missing something for sure, but what? I will be more than happy to flash the S332 instead of the S132, but I guess that isn't the solution.
:)

Sorry to be annoying. Thanks in advance for any hint.
PaoloC

Paolo Cecchini

unread,
Jan 31, 2022, 12:49:54 PM1/31/22
to ant-api
And sorry, only now I'm aware that the error message

'ArduinoNativeAnt' does not name a type; did you mean 'ArduinoSerialAnt'?

Is not exactly what I quoted from the original issue ...


Curtis Malainey

unread,
Jan 31, 2022, 1:34:31 PM1/31/22
to Paolo Cecchini, ant-api
Ah yes, the s132 does not support ANT. It is a BT only SD.

You need to install a softdevice from thisisant.com (make sure to cross check your MCU against supported versions). You then need to update the BSP to support initializing the ANT softdevice. Note if done incorrectly you run this risk of bricking your board unless you have a programmer handy as this requires modifying the bootloader. This is definitely the more complex method than getting a D52 board as a daughter board to another MCU and just controlling ANT over Serial. That is the only way to use the "Native" stack unfortunately. Gabor documented the process here how to do it with the nRF52 Feather Express if you want to take a crack at it with your board.

Curtis

Paolo Cecchini

unread,
Jan 31, 2022, 1:47:14 PM1/31/22
to ant-api
I see ... So I went wrong with the softdevice, pff. I'll try to flash the s332 asap. Or maybe, I dont remember now the code, there is an Ant only one s2something.

Yep it's for fun, I've been already successful with the D52.

Thanks. Paolo

Curtis Malainey

unread,
Jan 31, 2022, 1:49:51 PM1/31/22
to Paolo Cecchini, ant-api
Yep the S212 is ANT only. Good to hear about the serial success. If
you are dropping BT you will likely have to do a bit more work to boot
the Softdevice as the BT framework will likely have to be completely
disabled as the APIs will be gone and it won't boot it for you.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ant-api/4af9d54a-d66f-443a-9e0a-2efdebfcf9b1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages