trice icon indicating copy to clipboard operation
trice copied to clipboard

invalid use of Trice0 will misbehave trice insert

Open KammutierSpule opened this issue 1 year ago • 4 comments

Trice0( variable ); // invalid use Trice0( "text %u", variable ); // invalid use

Will cause that the next Trices will be ignored or not updated. (also if Trice0 are // commented)

See also: https://github.com/rokath/trice/issues/464

KammutierSpule avatar May 16 '24 13:05 KammutierSpule

Am I understand you right, that the first line causes the trice tool not to insert further IDs in that file? That's indeed an issue. Unfortunately I am not a parser expert and the trice tool is somehow limited.

There is probably no quick fix right now. See also comment in https://github.com/rokath/trice/blob/master/internal/id/insertIDs.go near line 280.

rokath avatar May 16 '24 15:05 rokath

also, it happens with clean too. If there is an invalid use of Trice0, trice clean will not be able to clean next ids on the file

KammutierSpule avatar May 16 '24 15:05 KammutierSpule

Yes, it is the same parser. I am going to add a chapter about that to https://github.com/rokath/trice/blob/master/docs/TriceUserGuide.md#9-additional-hints.

rokath avatar May 16 '24 16:05 rokath

It is added now into https://github.com/rokath/trice/blob/master/docs/TriceUserGuide.md#922-limited-trice-parser-capabilities.

rokath avatar May 19 '24 13:05 rokath

The following sequence inside trice/examples/OpenCM3_STM32F411_Nucleo/main.c

                // Depending on mode, either print this string to
		// UART (mode 0), or the Trice write buffer (mode 200).
		TRICE( Id( 4030),"Hello, TRICE, %d\n", 42);

		// TRICE() with a string parameter only is problematic.
		// See discussion on https://github.com/rokath/trice/issues/279
		// TRICE0() works in either case
		#ifdef __STRICT_ANSI__
		// if compiled with e.g. --std=c99
		TRICE0( Id( 4683),"Hello, TRICE\n");
		#else
		TRICE( Id( 2926),"Hello, TRICE\n");
		TRICE0( Id( 7263),"Hello, TRICE0()\n");
		#endif

gets changed into

		// Depending on mode, either print this string to
		// UART (mode 0), or the Trice write buffer (mode 200).
		TRICE(Id(0), "Hello, TRICE, %d\n", 42);

		// TRICE(Id(0), "Hello, TRICE\n");
		#else
		TRICE(Id(0), "Hello, TRICE\n");
		TRICE0(Id(0), "Hello, TRICE0()\n");
		#endif

so these lines are disappearing:

		// TRICE() with a string parameter only is problematic.
		// See discussion on https://github.com/rokath/trice/issues/279
		// TRICE0() works in either case
		#ifdef __STRICT_ANSI__
		// if compiled with e.g. --std=c99

when running renewIDs_in_examples_and_test_folder.sh in branch devel. This needs a special test first.

rokath avatar Nov 13 '24 22:11 rokath

I propose to close this issue for less issue noise. Normal usage is trice(... and all these cases are evaluated for matching value counts. If a user writes TRICE0(... or TRICE_3(... incorrectly, at least the compiler will complain. Also this limitation is documented now.

rokath avatar Dec 18 '24 13:12 rokath

Will be opened on demand again.

rokath avatar Jan 19 '25 20:01 rokath