-
Notifications
You must be signed in to change notification settings - Fork 1k
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
add support for sprintf #821
Conversation
add new public function: sprintfPrintPrettyDetails which accepts a char array as an argument add two new protected functions: sprintf_byte_register which takes a char array and the register address as arguments sprintf_address_register which takes a char array and the register address as arguments
add new public function sprintfPrettyDetails which takes a char array as an argument add two new protected functions sprintf_address_register which takes a char array and register address as arguments sprintf_byte_register which takes a char array and register address as arguments
Well, this came out of nowhere. I tried this a while back, but got stumped on what I thought was reference problems. I have questions:
|
|
I tested it on the teensy 4.1 (ARM Cortex-M7), I'll try a mega2560r3 tomorrow, and I think I have an m4 if you want to try more nxp. |
Ran the CI tests, and this breaks all builds for the Pico SDK and most builds for Linux. Fortunately, I think its an easy fix: You need to add If for some reason adding
Typically we only do this when a feature cannot/shouldn't be supported by a certain platform. So, if |
attempted to mimic printPrettyDetails output, added new char array and reused logic from printPrettyDetails to sprintfPrettyDetails.
include stdio; 4 space indent on example code
explanation of use
fixed typos
I tested on the mega2560 r3, working. |
I'm more concerned as to why the CI workflows aren't getting triggered. This makes testing the changes on various boards and platforms super easy (without having to hookup a physical board and everything). I'm thinking I need to close and re-open this PR to trigger the CI... We need to make sure the |
We tend to use doxygen primarily for documentation generation from src code comments. If you run I say all of this because the new function needs a:
You could word the description differently and elaborate how you like, but the parameter isn't documented for |
I don't know what CI workflows are, I've got a lot to learn about contributing and collaborating. AVR has their own stdio.h, I don't know if sprintf_P is standard C++. If it's not there are other ways I can get around that. |
add @param for debugging_information
CI stands for Continuous Integration. Github has docs about using them, and the results tend to be in the repo's "Actions" tab at the top of the page.
#ifndef sprintf_P
#define sprintf_P sprintf
#endif in the bottom of RF24_config.h |
Just built this locally on ubuntu, and it turns out that we need #include <stdio.h>
#ifndef sprintf_P
#define sprintf_P sprintf
#endif I'll have to get the pico SDK updated for my machine, and check that fixes the Pico SDK builds as well... |
add sprintf_P directive for portability
Ok, the BTW, it took almost 15 minutes to build the RPi Pico examples for 1 board. And that took place after the 5-10 minutes to setup the Pico SDK for my machine. The CI workflow builds the Pico examples for all supported boards in less than 5 minutes; this is another reason I'm concerned with the CI workflows not getting triggered. EDIT: I'm actually working from Windows using the WSL Ubuntu terminal, so some of the delay could be attributed to that tactic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My second review: This is looking better. We are now down to fixing English stuff (& a syntax typo)
update documentation for sprintfPrettyDetails, fix typos
add close comment to sprintf_P directive
syntax error in example code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats @dstroy0 ! I can now accept this change into master. Here is what the new function's docs look like on readthedocs,org.
@Avamander @TMRh20 Any objections/comments?
fixed syntax error in example code _len set but not used.
I fixed the indentation (manually) and trimmed the trailing whitespaces (a feature in vscode). about the python wrapperCurrently, this addition is not present in the python wrapper, and I added this fact to the function's docs. I don't think that this function would be easy to add to the python wrapper as there would have to be a conversion from c-string obj to python unicoded string obj implemented when calling a wrapped/modified version of |
I need to get better with python so I'll give it a try, I've never used the python wrapper. |
Its awesome you're willing to try! Here's some pointers:
|
This CPython function might make your life easier. |
I decided not to port this feature to Circuitpython_nRF24L01 lib because 1memory on Circuitpython running that lib is already being stretched thin for networking API and 2there is already enough exposed API (including private members - because its pure python) for users to manage their own implementation of this feature. @dstroy0 Mind if I try hacking this feature into the python wrapper or are you still cooking up another surprise? |
I’m still reading the boost python docs. Should I keep this pull request open? I’m curious to see the solution. I’ve got vscode up and running, getting my feet wet using it. Is there anything else that needs attention?
… On Jan 14, 2022, at 2:29 PM, Brendan ***@***.***> wrote:
I decided not to port this feature to Circuitpython_nRF24L01 lib because 1memory on Circuitpython running that lib is already being stretched thin for networking API and 2there is already enough exposed API (including private members - because its pure python) for users to manage their own implementation of this feature.
@dstroy0 Mind if I take try to hack this feature into the python wrapper or are you still cooking up another surprise?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
Its not unusual for a PR to remain open while the feature it introduces gets ironed out. Aside from settling what to do with the python wrapper, I don't think anything else needs attention. I'll try coding what I've got stuck in my head and see if it builds. If it builds I'll commit it and test it on RPi... Words of the wisedom
|
Sometimes I surprise myself when I get it right the first time! @dstroy0 This commit works to add the new function to the python wrapper. Result from testing on my RPi4: >>> from RF24 import RF24
>>> radio = RF24(22, 0)
>>> radio.begin()
True
>>> s = radio.sprintfPrettyDetails()
>>> print(s)
================ SPI Configuration ================
CSN Pin = 0
CE Pin = 22
SPI Frequency = 10 Mhz
================ NRF Configuration ================
Channel = 76 (~ 2476 MHz)
RF Data Rate = 1 MBPS
RF Power Amplifier = PA_MAX
RF Low Noise Amplifier = Enabled
CRC Length = 16 bits
Address Length = 5 bytes
Static Payload Length = 32 bytes
Auto Retry Delay = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
current channel = 0
Retry attempts made for
last transmission = 0
Multicast = Disabled
Custom ACK Payload = Disabled
Dynamic Payloads = Disabled
Auto Acknowledgment = Enabled
Primary Mode = TX
TX address = 0x65646f4e32
pipe 0 ( open ) bound = 0x65646f4e32
pipe 1 ( open ) bound = 0x65646f4e31
pipe 2 ( closed ) bound = 0xc3
pipe 3 ( closed ) bound = 0xc4
pipe 4 ( closed ) bound = 0xc5
pipe 5 ( closed ) bound = 0xc6
>>>repr(s)
"'================ SPI Configuration ================\\nCSN Pin\\t\\t\\t= 0\\nCE Pin\\t\\t\\t= 22\\nSPI Frequency\\t\\t= 10 Mhz\\n================ NRF Configuration ================\\nChannel\\t\\t\\t= 76 (~ 2476 MHz)\\nRF Data Rate\\t\\t= 1 MBPS\\nRF Power Amplifier\\t= PA_MAX\\nRF Low Noise Amplifier\\t= Enabled\\nCRC Length\\t\\t= 16 bits\\nAddress Length\\t\\t= 5 bytes\\nStatic Payload Length\\t= 32 bytes\\nAuto Retry Delay\\t= 1500 microseconds\\nAuto Retry Attempts\\t= 15 maximum\\nPackets lost on\\n current channel\\t= 0\\r\\nRetry attempts made for\\n last transmission\\t= 0\\r\\nMulticast\\t\\t= Disabled\\nCustom ACK Payload\\t= Disabled\\nDynamic Payloads\\t= Disabled\\nAuto Acknowledgment\\t= Enabled\\nPrimary Mode\\t\\t= TX\\nTX address\\t\\t= 0x65646f4e32\\npipe 0 ( open ) bound\\t= 0x65646f4e32\\npipe 1 ( open ) bound\\t= 0x65646f4e31\\npipe 2 ( closed ) bound\\t= 0xc3\\npipe 3 ( closed ) bound\\t= 0xc4\\npipe 4 ( closed ) bound\\t= 0xc5\\npipe 5 ( closed ) bound\\t= 0xc6\\n\\n'" However, notice that there is extra whitespace at the end of the returned string; executing |
It’s not necessary, you are correct the user should specify spacing after. Just the one new line makes it like the output of printPrettyDetails. Any padding you want to remove to make the output smaller is ok with me. The function local buffer sizes can be optimized too so that memory use for the function goes down.
… On Jan 17, 2022, at 2:11 PM, Brendan ***@***.***> wrote:
@2bndy5 commented on this pull request.
In RF24.cpp:
> + "\n"
+ "pipe 3 ( "
+ PRIPSTR
+ " ) bound\t= 0x"
+ PRIPSTR
+ "\n"
+ "pipe 4 ( "
+ PRIPSTR
+ " ) bound\t= 0x"
+ PRIPSTR
+ "\n"
+ "pipe 5 ( "
+ PRIPSTR
+ " ) bound\t= 0x"
+ PRIPSTR
+ "\n\n"
@dstroy0 If your scenario is ok with these changes, then I'll commit them. I'm not sure if the \n\n is required for sending the c-string over MQTT, but I think it can still be added on the user's end not the lib's end.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
- fixed some outstanding misspelling in docs (this was my bad) - remove terminating `\n\n` and whitespace padding in sprintfPrettyDetails() - change buffer size for python wrapper about sprintfPrettyDetails_wrap() - revised docs for sprintfPrettyDetails() - trimmed all trailing whitespace in RF24.h
I'm ready to merge this now. >>> s = radio.sprintfPrettyDetails()
>>> print(s)
================ SPI Configuration ================
CSN Pin = 0
CE Pin = 22
SPI Frequency = 10 Mhz
================ NRF Configuration ================
Channel = 76 (~ 2476 MHz)
RF Data Rate = 1 MBPS
RF Power Amplifier = PA_MAX
RF Low Noise Amplifier = Enabled
CRC Length = 16 bits
Address Length = 5 bytes
Static Payload Length = 32 bytes
Auto Retry Delay = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
current channel = 0
Retry attempts made for
last transmission = 0
Multicast = Disabled
Custom ACK Payload = Disabled
Dynamic Payloads = Disabled
Auto Acknowledgment = Enabled
Primary Mode = TX
TX address = 0x65646f4e32
pipe 0 ( open ) bound = 0x65646f4e32
pipe 1 ( open ) bound = 0x65646f4e31
pipe 2 (closed) bound = 0xc3
pipe 3 (closed) bound = 0xc4
pipe 4 (closed) bound = 0xc5
pipe 5 (closed) bound = 0xc6
>>> len(s)
856 Any more optimizations can be submitted via another PR. I just want to get this upstream because it may well support boards that can't use |
well the CI workflows finally got triggered... @dstroy0 You can see that this change does not harm builds for any of the officially supported boards in the Arduino CI run. The PlatformIO CI run shows all green as well (for all Teensy boards). The Linux CI run is looking good too. Keep in mind that these workflows only test compile all the examples, and none of the examples actually call |
Excellent!
… On Jan 17, 2022, at 4:48 PM, Brendan ***@***.***> wrote:
I'm ready to merge this now.
python wrapper test:
>>> s = radio.sprintfPrettyDetails()
>>> print(s)
================ SPI Configuration ================
CSN Pin = 0
CE Pin = 22
SPI Frequency = 10 Mhz
================ NRF Configuration ================
Channel = 76 (~ 2476 MHz)
RF Data Rate = 1 MBPS
RF Power Amplifier = PA_MAX
RF Low Noise Amplifier = Enabled
CRC Length = 16 bits
Address Length = 5 bytes
Static Payload Length = 32 bytes
Auto Retry Delay = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
current channel = 0
Retry attempts made for
last transmission = 0
Multicast = Disabled
Custom ACK Payload = Disabled
Dynamic Payloads = Disabled
Auto Acknowledgment = Enabled
Primary Mode = TX
TX address = 0x65646f4e32
pipe 0 ( open ) bound = 0x65646f4e32
pipe 1 ( open ) bound = 0x65646f4e31
pipe 2 (closed) bound = 0xc3
pipe 3 (closed) bound = 0xc4
pipe 4 (closed) bound = 0xc5
pipe 5 (closed) bound = 0xc6
>>> len(s)
856
Any more optimizations can be submitted via another PR. I just want to get this upstream because it may well support boards that can't use printDetails() due to lack of printf() support.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.
|
now you can use your RF24 object to format a buffer with debugging information