Commit Graph

275 Commits

Author SHA1 Message Date
Tester23
8da39b51bd PLATFORM_W800 2025-06-18 22:44:17 +02:00
Tester23
2513558bb0 Update selftest_tasmota.c 2025-06-18 22:17:33 +02:00
Tester23
770d2c6ae7 backlog 2025-06-18 21:59:21 +02:00
Tester23
901a43ceaf sefl test for tuyamcu calibration 2025-06-17 17:45:20 +02:00
Tester23
6a027eb204 self test for click event with backlog and repeating event 2025-06-15 12:24:12 +02:00
Bartosz Nitka
92ea9cd8ab Ability to run linux tests with AddressSanitizer (#1651)
* Ability to run linux tests with AddressSanitizer

This makes it possible to compile and run the tests with Address
Sanitizer (ASAN) [1].

The command is:
```
make -f custom.mk clean; ASAN=1 make -f custom.mk && ./build/win_main -runUnitTests 2
```

Building without ASAN works without change.

Address Sanitizer saves a lot of time debugging memory issues, for
example for a bug where we index in an array with negative index it
gives this nice error message:
```
=================================================================
==2532658==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5642389c5e37 at pc 0x564237e67492 bp 0x7fff17726e50 sp 0x7fff17726e40
READ of size 1 at 0x5642389c5e37 thread T0
    #0 0x564237e67491 in CHANNEL_GetType src/new_cfg.c:427
    #1 0x564237dfc933 in TuyaMCU_ApplyMapping src/driver/drv_tuyaMCU.c:1126
    #2 0x564237dff92f in TuyaMCU_ParseStateMessage src/driver/drv_tuyaMCU.c:1632
    #3 0x564237e019fa in TuyaMCU_ProcessIncoming src/driver/drv_tuyaMCU.c:1977
    #4 0x564237e027ee in TuyaMCU_RunReceive src/driver/drv_tuyaMCU.c:2178
    #5 0x564237e02dc2 in TuyaMCU_RunFrame src/driver/drv_tuyaMCU.c:2335
    #6 0x564237dd2ce6 in DRV_RunQuickTick src/driver/drv_main.c:536
    #7 0x564237ec4037 in QuickTick src/user_main.c:946
    #8 0x564237eca8a5 in Sim_RunFrame src/win_main.c:106
    #9 0x564237eca993 in Sim_RunFrames src/win_main.c:134
    #10 0x564237ebce4a in Test_TuyaMCU_Basic src/selftest/selftest_tuyaMCU.c:369
    #11 0x564237ecab1f in Win_DoUnitTests src/win_main.c:194
    #12 0x564237ecba57 in main src/win_main.c:535
    #13 0x7fb55312ed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #14 0x7fb55312ee3f in __libc_start_main_impl ../csu/libc-start.c:392
    #15 0x564237cb16b4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0xcf6b4)

0x5642389c5e37 is located 51 bytes to the right of global variable 'stat_deduper_culled_tooFast' defined in 'src/mqtt/new_mqtt_deduper.c:40:12' (0x5642389c5e00) of size 4
0x5642389c5e37 is located 9 bytes to the left of global variable 'g_mutex' defined in 'src/mqtt/new_mqtt_deduper.c:42:26' (0x5642389c5e40) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow src/new_cfg.c:427 in CHANNEL_GetType
Shadow bytes around the buggy address:
  0x0ac8c7130b70: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b80: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b90: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130ba0: 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bb0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
=>0x0ac8c7130bc0: 04 f9 f9 f9 f9 f9[f9]f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==2532658==ABORTING
```

[1] https://github.com/google/sanitizers/wiki/addresssanitizer

* disable tests broken on linux

* add a suppression file for known leaks

* attempt at adding an ASAN workflow

* fix autogen

* Update workflow.yaml

---------

Co-authored-by: openshwprojects <85486843+openshwprojects@users.noreply.github.com>
2025-05-31 14:27:02 +02:00
openshwprojects
d6f7678dc6 TCL AC driver progress + LowMidHigh etc channels HA discovery
* Buzzer

* Update obk_config.h

* Display

* uart test stub

* unfinished TCL_DoDiscovery

* ha

* Update drv_tclAC.c

* ha mode send

* unfinished not working

* Update drv_tclAC.c

* Update hass.h

* better discovery

* Update obk_config.h
2025-05-30 16:10:36 +02:00
Tester23
529bf00170 cse test stub 2025-05-22 12:33:13 +02:00
openshwprojects
d07c72a0ca AC TCL driver - part 1
* ac t1

* test

* fx

* fx

* p

* build_set_cmd

* try enable

* makefile

* make

* header

* self test

* parsing - not tested

* rename for easier testing

* add src

* print len

* parity

* FIX PARITY - 2

* SwingH and SwingV

* w

* files

* Update drv_tclAC.c

* display vals

* few berry tests

* disable
2025-05-18 18:24:21 +02:00
openshwprojects
acd46ad682 add PIR driver
* tt

* Update selftest_berry.c

* Update obk_config.h

* some more fixes

* fixes

* IOR_PWM_ScriptOnly_n

* fx

* Update OpenBeken.mk

* disable
2025-05-16 10:07:38 +02:00
Tester23
db1942c10c fix Berry - add missing be_pop 2025-04-13 15:38:09 +02:00
Tester23
b21ca34812 Berry stack size test - part 1 2025-04-13 14:13:54 +02:00
openshwprojects
eadba42f9f Berry integration part 1
* t

* fx

* split closure handler

* setTimeout, setInterval

* split berry frm SVM, but I need to move event waiter to separate struct?

* fx

* fx

* split relations

* remvoe ode duplciaton

* POC - pass value to berry

* POC - pass str to berry

* berry preps + lfs test

* lfs test + bytes

* save

* remove code duplication

* try dpid calls

* working test for bytes

* tyuamcu to file in eberry

* str for berry test

* tuyamcu to berry glue

* fx1

* fixes

* try berry http

* fix

* tests

* test  vaar lifespan

* test

* test

* test if

* berry in html

* #if ENABLE_OBK_BERRY

* fx

* better

* fx

* test nested loop

* free mem

* simpler

* split lfs run

* arg

* fx

* fix

* #if ENABLE_OBK_BERRY

* comamnd hook

* vars access, ntp

* finalize?

* unfinished
2025-04-12 16:56:24 +02:00
Bartosz Nitka
7e1afd0fdf [POC] Run berry-lang (#1544)
* setChannel(ch, v) in Berry

* try

* t2

* b

* fx

* update to berry with autogenerated files

* Add debug to find out whether the submodule is really checked out

* Revert "Add debug to find out whether the submodule is really checked out"

This reverts commit 40ec2f6677.

* Add src/berry checkout to every build

* berry separate file p1

* #define ENABLE_OBK_BERRY 1 on Beken only

* Compile in obkSimulator

Compiles, but crashes in parser.
Seems like the Berry code has not been tested under MSVC2017.

* Checkout with submodules in obkSimulator workflow

* berry with ffs msvc fix

* berry autogen fiasco fix

* OpenBK7231T compiles from official berry, handle prebuild

Breaks obkSimulator

* Fix botched rebase on .gitmodules

* Build in msvc with a berry prebuild step (requires python)

* MSVC: also extend include directories for Release

* Fix BK723x build, extract common berry build rules into berry.mk

* Fix OpenBL602 build

This doesn't actually compile berry for OpenBL602, but makes compile
errors go away and marks where further work will be needed.

* working delayMs

Test Plan:
```
berry state = 1; var tick; def tick() state = 1 - state; channelSet(1, state); delayMs(1000, tick); end; tick();
```
can be stopped with `stopAllScripts`

* only use os_realloc on PLATFORM_BK7231T

* Move as much berry logic as possible out of cmd_script

* Guard more with ENABLE_OBK_BERRY

* upload script

* file operations & working import

* enough to implement "Advanced turn off after time with timer on UI and timer setting on UI and kept in flash"

* experiments

* clang-format -i src/berry/be_*.{h,c} src/cmnds/cmd_berry.c

* Remove redundant hfile != NULL

Calling with hfile == NULL would be bug in some other part of the code

* Don't checkout other submodules for simulator build

* remove stray debug & .user files

* Use be_newcomobj

* Build sim on linux

* build linux sim [2]

* threads & tests

* Leave enabled on Windows, disable on BEKEN

* SIM_RunWindow fix?

* allow "startScript test.be" as a shorthand for "berry import test" ??

* test?

* fix /

* test arg

* test2

* test

* test add

* fx

* test

* just checking if i can use import without module?

* test with module

* CMD_StopBerry fix?

* run obk command from berry? probably not good idea due to the stack size, will delay execution later?

* str arg

* test to see if i have to repeat import

* submit unfinished code

* concat tst

* more tests

* fix copy/paste mistake, add fib test

* fx

* channelSet

* fx

* try

* tester.fib(11)

* rename

---------

Co-authored-by: Tester23 <85486843+openshwprojects@users.noreply.github.com>
Co-authored-by: NonPIayerCharacter <18557343+NonPIayerCharacter@users.noreply.github.com>
2025-03-30 20:37:37 +02:00
openshwprojects
2d43185902 Port Simulator to Linux - p1
* intial makefile for windows sim

* netdb

* tr

* fx

* fxes

* fxes

* fxes

f

* fxes

* fxes

* fxes

* fx

* fx

* fxes?

* fxes

* better?

* stubs

* more

* fxes

* fx?

* comment out sleep

* but only in self test

* add assertion keyword

---------

Co-authored-by: Alexandre Oliveira <rockytvbr@gmail.com>
2025-03-26 22:13:39 +01:00
Tester23
b80fff5d40 added TuyaMCU delta option for per-dpID calibration like temperature, etc 2025-03-23 09:23:57 +01:00
Tester23
49a466aecb float change callback temp fix 2025-03-05 08:51:37 +01:00
Tester23
8c01b0cf83 test for addChangeHandler Channel20 != 0 2025-03-05 07:27:02 +01:00
Tester23
7495c70322 f div 1000 type 2025-01-28 04:56:25 +01:00
Tester23
0b39365b54 DP_TYPE_RAW_VCPPfF 2025-01-27 17:02:07 +01:00
openshwprojects
77efc7ebca make startup command multiline
* step 1

* step2

* Update cmd_script.c

* Update cmd_script.c

* Update obk_config.h

* Update cmd_script.c

* Update cmd_script.c

* fx

* Update obk_config.h

* Update OpenW800

* Update OpenW800

* Update obk_config.h

* f

* fix waitfor

* Update obk_config.h

* Update Makefile

* json escap9ijgng

* crash checks and size check

* w600 bmp

* fx

* Update Makefile

* test

* fx

* Tokenizer_GetPin

* fix

* fix

* ln882h pins

* Update new_http.c

* Update new_http.c

* Update new_http.c

* aht

* aht

* Update obk_config.h

* drv_sht3x

* aht pins

* f

* fx

* aht

* sunset fx

* ln owm

* Update CMakeLists.txt
2025-01-23 23:10:35 +01:00
Tester23
f209c00a8b fix rgb pr 2025-01-22 09:13:57 +01:00
openshwprojects
eb5b1ca2d0 Allow to disable more drivers and features in order to reduce binary size (#1500)
* Update obk_config.h

* Update obk_config.h

* shared

* fx

* he

* fix

* fx

* ffff

* F

* T

* tre

* fcx

* leeed

* ww

* w

* fx

* t

* ENABLE_OLD_YAML_GENERATOR

* w

* startyuip[

* dis all

* remove test post

* ENABLE_HTTP_SEND

* extra guard

* ENABLE_TCP_COMMANDLINE

* better OBK_DISABLE_ALL_DRIVERS

* tr

* ENABLE_PING_WATCHDOG

* ENABLE_HA_DISCOVERY

* TEST WITH EMPTY USER_MAIN

* fx

* no mqtt

* nm

* tr

* ENABLE_MQTT

* Update cmd_newLEDDriver.c

* tr

* header

* fx

* Update user_main.c

* t

* Update hal_main_bk7231.c

* w

* ENABLE_DRIVER_IR

* RESTORE

* fx

* #warning "Platform not defined"

* fx 1

* Update obk_config.h

* ENABLE_DRIVER_TESTPOWER

* DS1820

* fx

* fx

* enable DHT on W800

* Update Makefile

* ntp w800

* ntp

* ssdp

* OWM AND CHARTS

* why utils net has flash pub included

* nmakefile only, no refs

* makefile only

* drv

* Update Makefile

* drcs

* ENABLE_DRIVER_BMP280

* Update Makefile

* d

* ENABLE_I2C

* Update Makefile

* fin
2025-01-10 19:50:17 +01:00
Tester23
a45714b898 selftest: check parsing names in send dp 2025-01-10 00:21:09 +01:00
Tester23
b1f745deb1 setChannelType 10 ReadOnly test 2025-01-08 11:05:59 +01:00
Tester23
c7d6eac06c test 60.5 2025-01-08 10:51:11 +01:00
Tester23
5f53e20cd5 PowerSet self test 2025-01-08 10:43:44 +01:00
Tester23
d0b4168f29 color formats self test 2025-01-05 00:15:01 +01:00
Tester23
a11c671b25 Merge branch 'main' of https://github.com/openshwprojects/OpenBK7231T_App 2024-12-28 22:53:26 +01:00
Tester23
1f044b2d0f add channels label clear 2024-12-28 22:37:47 +01:00
MaxineMuster
cafa3619a5 Add commands to check if actual time is in DST or not (#1429)
* Add commands to check if actual time is in DST or not

New command "clock_calcDST nthWeekEnd monthEnd dayEnd hourEnd nthWeekStart monthStart dayStart hourStart"
to set the DST start and end rule.

$isDST will return 1 if DST is active, 0 else

It's enabled with

* switched from strftime to ctime to get smaller memory footprint

* disabled feature by default in obk_config.h (enabled for Windows for possible testing)

* try selftest for DST

* enable Test_NTP_DST() in win_main.c

* fix missing NTP offset settings, fix LOG

* Add possibility to set g_ntpTime according to DST settings
tried to reduce image sizes by avoiding mktime
still image size for this feature varies very much:

LN882H: 2.2k in bin / 1.5k in OTA
Beken:  4.3k in rbl
BL602:  21.4k in bin / 9.7k in ota

This commit has feature enabled, to get images for testing, will change it to disabled by default in next release

* disable feature for all plattforms but windows (to allow tests)

* Fix selftest - all DST changes are now done by the system!

* Fix selftest - setsimulated time must also call setDST as "real" ntp setting

* Next try to fix selftests

* For testing switch back to mktime

* New try to reduce image by avoiding time functions
Fix own leap year calculation

* Disable feature for all platforms but Windows (to keep selftest)
2024-12-28 22:23:21 +01:00
Tester23
f099183753 self test for conditional relay 2024-12-28 22:21:07 +01:00
Tester23
9faa30191e fx 2024-12-27 19:39:30 +01:00
Tester23
748ec4b1be VCP self test 2024-12-27 19:39:02 +01:00
Tester
22f68ffdff unfinished flags self test 2024-12-24 19:01:17 +01:00
Tester
e0bd9769df docs 2024-12-24 18:15:35 +01:00
Tester23
a0ab7c17e4 waiting for channel 1 to become non-zero self test 2024-12-09 14:10:42 +01:00
Tester23
6940b06cfa publish command JSON syntax test 2024-12-09 14:08:17 +01:00
Tester23
6acd938e71 comments 2024-12-09 14:08:06 +01:00
Tester23
6e176a3911 support multiple RAW_TAC2121C_VCP channels for devices with 3 phases, etc 2024-12-08 01:38:25 +01:00
Tester23
2cf3c37739 ddp sets brightness 2024-12-06 18:40:59 +01:00
Tester23
37a7c7aa6d experiment - RGBW DDP support? 2024-12-06 10:43:56 +01:00
Tester23
ecad0835a3 some more ddp tests before improvement 2024-12-06 10:07:10 +01:00
Tester23
14cbb7a073 extend mqtt self tests 2024-12-02 09:20:44 +01:00
Tester23
c3ebfee8c6 tests - larger mqtt history size 2024-11-29 09:26:53 +01:00
Tester23
c2d3691b63 mqtt history dump and temp self test fix? 2024-11-29 09:01:20 +01:00
Tester23
a6dcddb6a5 energy meter self test cover more cases 2024-11-28 23:12:34 +01:00
Tester23
3b23d873d7 a bit better MQTT hass self testing 2024-11-27 12:46:22 +01:00
Tester23
a2f3b02068 UART self test 2024-11-27 01:04:31 +01:00
Tester23
8f8f2574d4 startScript selftest fix 2024-11-27 00:40:21 +01:00