I modified the Flags command to support 64bit. The display on WEBui is also fixed. Checked on the simulator and on BK7238. Is there anyone who can verify this on other platforms?
Btw, what was the original reason to make flags into 2 integers, instead of an uint64_t?
I don´t know. Maybe, first version have 32 flags only.
Added after 11 [minutes]:
insmod wrote:
Wouldn't it break config on platforms where long is 8 bytes?
You're right, changed to uint32.
Added after 3 [minutes]:
BTW, on which platform for OBK is a long actually 8 bytes long? Are they all 32 bit mcu's, or not?
It's my fault, I'm a developer mainly for Win and on 64bit Win (LLP64) long is 32bit
>>21456907 Currently all are 32bit, but who knows in the future. And while long on 32bit is usually 4 bytes, who knows what some compilers would do. I know that i've seen 4 bytes long on 64 bit windows.
I don't remember well, but I think I've started with a single 32-bit integer. Then I added another 32 bits it has turned out that there is a long-standing bug with flag set (or read?). It has been tacked several times but we didn't get any definitive fix, unless PR 1548 works well on all platforms?
Ok will test. Is the latest build looking final for testing?
Are there platforms I shouldn't bother with at all because it'll definitely not work? And should all the ESPs be treated as one test or one from each series required - like one ESP32-C#, one ESP32-S# etc
>>21457353 It is final. There is no need to test all devices, all of them are 32bit.
The thing to test is if funcion strtoull() works ok on the main SDKs (ESP, BL, LN). Beken is ok.
Maybe we could do a selftest system like the one on Windows, but designed to run on Device?
For example, put it into the cmd_selfTest.c and make there a long list of commands with result assertions.
Then we could run it on physical devices to make sure that everything is okay.
This could be very useful, especially considering platform differences and such....
We already had issues related to those, for example:
- time_t size (32 bit vs 64 bit)
- missing realloc on BL602
- strange sprintf behaviour (remember static IP page?)
Maybe we could do a selftest system like the one on Windows, but designed to run on Device?
I think this is not necessary. The main problems are revealed on win, and the "special" unexpected ones would be detected by the test with very little probability anyway.
That's why I think we may benefit from making a simple self-test that runs on any platform, with #define entry in obk_config.h , so it takes 0 space in Release builds.
It could test for basic stuff, like JSON parsing, commands execution, etc.
100 means 100ms interval between steps.
It runs in such a way, that it first prints command it will run, it waits 100ms for log to come through, then runs command, then checks run result, then waits 100 ms, and pritns again....
Sample run:
The most important thing to note here is that if some command crashes, you can also run it from console without test driver.
Please give me initial feedback, but also wait 1 day before running it. I will improve it a bit soon.
Yes and this will be finally meaningful, and not pointless like testing on Windows, because those functions are outside our SDK and testing them on Windows won't tell us if they will work on Beken on BL602.
this all sounds quite good. How exactly do self-tests work and help? I'm not very codey, but it seems like a sensible thing to have in place. If, for example, a contributor proposes code changes in a new PR and they cause a problem somewhere, how does the self-test manifest? What and where fails? Somewhere in the build workflow log?
Those self tests are basically simulating a use case scenario, for example, setting up a LED, and then they check externally is the use case result as expected.
For example, if we set two PWM pins, we expect CW control to show up and we expect Dimmer command to work. We expect certain things to be published when light state changse, we can test it as well. So, we simulate setting of two PWM pins, then we run some commands, and check is result as expected (for example, are output PWM values as expected for correct CW control).
Example 1 - if we set channel 1 to 123, is $CH1 constant working in script and expands to 123?
Code: C / C++
Log in, to see the code
If "buffer" is not "123", then SELFTEST_ASSERT_STRING will show error on Github build (red cross instead of green checkmark).
Example 2 - if we set two PWM pins, are they correctly detected as CW light? Is light responding to commands and settings PWMs correctly?
Code: C / C++
Log in, to see the code
Let's look deeper at one fragment:
Code: C / C++
Log in, to see the code
This basically says:
- if you have CW light set up, and OBK receives a POWER OFF Tasmota command, the led_enableAll variable should be 0 (false) and both PWMs should be 0
- if you later receive POWER ON Tasmota command, led_enableAll is expected to be 1 (true) and for current configuration (set earlier in code) first PWM should be 100%, second 0% (because we earlier set up temperature 100% cold)
Thanks to this mechanism, as soon as somebody breaks the expected behaviour (for example, adds a change that makes CW lights not working), we will know at compile time, because self test will catch it.
Per-platform can be only run on true platform devices, like BK7231, not in simulator.
They were introduced because not everything can be tested in Windows simulator.
Some things are per-platform, for example sscanf command, or realloc, etc.
So we have "different" sscanf or sprintf on each platform - different on BK7231, W800, W600...
That's why I added test commands like this one:
Code: C / C++
Log in, to see the code
This checks IP parsing, and this is required, because it has proven problematic, see implementation:
Code: C / C++
Log in, to see the code
This is not just a theoretical sample - we really had this issue:
As you can see above, we had a sscanf problem that requires special handling on W600/LN882H/Realtek, and we didn't catch it early.
If we had per-platform device tests back then that cover str to ip, we would have caught it earlier.
It is impossible to catch this problem on WIndows self tests, because it is present only on some platforms with their specific implementation.
Thanks to the per-platform tests, it's now possible to catch it.
If you compile OBK with test commands enabled, and if your platform has str_to_ip broken, then this code:
Code: C / C++
Log in, to see the code
will attempt to parse "192.168.0.123", but it will fail,, then "if" will detect it, so it will return CMD_RES_ERROR.
So, later, the drv_test.c will catch it, and it will show error here:
Self tests are very useful, because they can quickly check if all tested features can work as expected. You don't need to setup a CW light to check if PWMs are set correctly - this is done by Windows selftests in SImulator on each Github build. You also don't need now to manually check each page like local ip config on every platform, because per-platform tests will cover it as well....
How to run self tests? - to run Windows simulator self tests, just trigger online github build, they are ran automatically
- to run per-platform tests, compile OBK with ENABLE_TEST_COMMANDS , flash it to your device, and run "backlog startDriver Test; StartTest 100;"
I didn't have time to run per-platform tests myself, but I strongly suspect that at least realloc test will just crash BL602 device - realloc is known to be a problem on BL602.
So now let's make a demonstration. We'll consider a hypothetical scenario where someone breaks some function by accident, for example, the channel set.
I modified CHANNEL_Set_Ex to always set value to 0:
Then I commited changes to Github.
Let's see what happens.
It's building, so we wait a moment...
And then we get:
AS you can see, many self tests have failed. They expect channels to work, so they recognized that something is wrong:
The discussion revolves around the modification of the Flags command to support 64-bit integers, with a focus on verifying its functionality across multiple platforms. The original implementation used two 32-bit integers due to historical limitations, but the transition to a single uint64_t is seen as a step towards future-proofing. Participants discuss potential issues with platform compatibility, particularly regarding the size of data types like 'long' on different architectures. Testing is emphasized, with suggestions for a self-test system to ensure consistent behavior across devices. Initial tests indicate successful flag setting, although some issues, such as a hard fault on the RTL-B platform, were noted. The conversation also touches on the importance of testing functions like strtoull() across various SDKs and the implementation of per-platform testing to catch platform-specific bugs. Summary generated by the language model.