API for protocol development

More
30 Sep 2013 06:26 #14155 by victzh
API for protocol development was created by victzh
@PhracturedBlue, I would like to be able to ask some questions on the API available for protocol developers. The majority of the API can be deduced from other protocols, but sometimes I need a function which is not used in any of the existing ones. Could you book mark this topic for such questions?

The first question is following. For ESky I need to switch to another frequency pair each time the controller is turned on. Do you have a function to find some kind of "controller time" - the number of starts, or function allowing me to store a key-value pair between sessions?

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
30 Sep 2013 12:47 #14164 by rbe2012
Replied by rbe2012 on topic API for protocol development
Do you need something like "model=42" which saves the number of the last used model in the tx.ini?

Please Log in or Create an account to join the conversation.

More
30 Sep 2013 12:56 #14166 by victzh
Replied by victzh on topic API for protocol development
That would do. I wonder, how often can I do this without the risk of trashing the flash? At every start is ok?

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
30 Sep 2013 17:25 #14175 by rbe2012
Replied by rbe2012 on topic API for protocol development
I am not sure about that, but every time you change the model which has a permanent timer configured the new value is written. And the model number is written to tx.ini. So it is done already - changing two values should not do any harm.

Please Log in or Create an account to join the conversation.

More
30 Sep 2013 19:45 #14182 by victzh
Replied by victzh on topic API for protocol development
How can I do something like this myself? What is the place in the code to look at?

Also, do we have random number generator available?

Thanks for helping me.

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
01 Oct 2013 05:49 #14187 by rbe2012
Replied by rbe2012 on topic API for protocol development
The model number is written in CONFIG_SaveTxIfNeeded() in config/tx.c after the model number is changed when reading (look in config/model.c and in pages/320x240x16/common/_model_loadsave.c function okcancel_cb):
u8 CONFIG_ReadModel(u8 model_num) {
    crc32 = 0;
    Transmitter.current_model = model_num;
    clear_model(1);
    ...
If you want to use the same mechanism you would have to add an element to the struct "Transmitter" defined in config/tx.h, change this element if you switch to other channels and call CONFIG_SaveTxIfNeeded().

As far as I know there is no random number generator... Do you need real randomness or only an sufficient randomly looking sequence? In this case you probably can use a predefined list.

Please Log in or Create an account to join the conversation.

More
03 Oct 2013 02:59 #14209 by victzh
Replied by victzh on topic API for protocol development
To make things clear: ESky protocol uses a pair of frequencies during the whole session. It changes the pair at every TX start to reduce the probability of interference. It would be probably better just pick a random pair of frequencies, but for this we need truly random number, or at least some changing variable, like global time, randomized through PNG. Do we have global time or something resembling it? The number of restarts since last firmware reload?

Please Log in or Create an account to join the conversation.

More
03 Oct 2013 04:27 #14210 by SeByDocKy
Replied by SeByDocKy on topic API for protocol development

victzh wrote: To make things clear: ESky protocol uses a pair of frequencies during the whole session. It changes the pair at every TX start to reduce the probability of interference. It would be probably better just pick a random pair of frequencies, but for this we need truly random number, or at least some changing variable, like global time, randomized through PNG. Do we have global time or something resembling it? The number of restarts since last firmware reload?


Fix the seed of your RNG

Please Log in or Create an account to join the conversation.

  • rbe2012
  • rbe2012's Avatar
  • Offline
  • So much to do, so little time...
More
03 Oct 2013 13:09 #14216 by rbe2012
Replied by rbe2012 on topic API for protocol development

victzh wrote: ...Do we have global time or something resembling it? The number of restarts since last firmware reload?

We don't have, as far as I know. For Devo12 we could use the RTC.

When I have understood correctly the transmitter calculates two frequencies and gives them to the receiver. Wouldn't it be better to scan for free channels than to randomly select two? They could both be occupied by other rf transmitter...

We could possibly get something like randomness if we use the least significant bits of the A/D-converter. They could change quite often because the board layout does not seem to be optimized for high accuracy.

Please Log in or Create an account to join the conversation.

More
03 Oct 2013 13:25 - 03 Oct 2013 13:27 #14219 by vlad_vy
Replied by vlad_vy on topic API for protocol development
Look at DSM2 protocol initialization.
Last edit: 03 Oct 2013 13:27 by vlad_vy.

Please Log in or Create an account to join the conversation.

Time to create page: 0.050 seconds
Powered by Kunena Forum