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

Examples vs Tinyproto documentation #18

Open
timov50 opened this issue May 3, 2021 · 3 comments
Open

Examples vs Tinyproto documentation #18

timov50 opened this issue May 3, 2021 · 3 comments

Comments

@timov50
Copy link

timov50 commented May 3, 2021

Hi,

I'm a bit noob with C++ and have some difficulties to understand how to use Tinyproto.

In the Tinyproto documentation there is mentioned that higher level protocols needs 4 user defined callbacks.

  • int write_func_cb(void *user_data, const void *data, int len);
  • int read_func_cb(void *user_data, void *data, int len);
  • int on_frame_read(void *user_data, void *data, int len);
  • int on_frame_sent(void *user_data, const void *data, int len);

Is the documentation (in https://codedocs.xyz/lexus2k/tinyproto/index.html) out of sync with the main branch because in the examples I find references to the on_frame_read and on_frame_sentfunctions, but not to the write_func_cb or read_func_cbfunctions?

Examples where on_frame_read or on_frame_sent are used:
./examples/linux/hdlc_demo_multithread/hdlc_demo_multithread.cpp
./examples/esp32_idf/spi/master/main/app_main.c
./examples/esp32_idf/spi/slave/main/app_main.c

Or have I missed something essential?

-timo-

@lexus2k
Copy link
Owner

lexus2k commented May 3, 2021

Hi,

Yes, you're right. Some pages in the documentation are outdated. The source code for the page, you've pointed out is here: https://github.com/lexus2k/tinyproto/blob/master/src/mainpage.dox. Feel free to update it, and create pull request, or I will fix it later.
The most correct "documentation" is examples folder. It is always up to date.

Thank you

@timov50
Copy link
Author

timov50 commented May 5, 2021

Thanks for quick response.
I’m afraid I don’t understand the design of tinyproto well enough to touch the documentation.

E.g., what is going here (esp uart loopback example)?
proto.run_tx([](void *p, const void *b, int s) -> int { return uart_write_bytes(UART_NUM_1, (const char *)b, s); });

I do not understand role ole p* as the uart_write_bytes function (esp-idf) does not use it.

My understanding is that the first part of the lambda is coming from here:
typedef int (*write_block_cb_t)(void *pdata, const void *buffer, int size);
The *pdata is definition:
@param pdata - pointer to user private data - absent in Arduino version

Q: What is the purpose of the *pdata argument? Legacy?

@lexus2k
Copy link
Owner

lexus2k commented May 6, 2021

Hi @timov50

*p is just a pointer to the user data, which can be specified via setUserData(), if you need it. So, in the example *p is not used.

@lexus2k lexus2k removed the bug label Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants