Skip to content
Merged

Wip #738

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cmd/trice/tcp4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func TestTCP4Reception(t *testing.T) {
fSys := &afero.Afero{Fs: afero.NewMemMapFs()}
defer setupTest(t, fSys)()

// Keep the old one-letter prefix in these captured-message fixtures.
// It is no longer a built-in tag, so every receiver must preserve "w:".
til := `{
"16201": {
"Type": "TRice",
Expand Down Expand Up @@ -82,7 +84,7 @@ func TestTCP4Reception(t *testing.T) {
// We use "-port TCP4BUFFER" just for the test, to force the Trice tool to shutdown after receiving a package.
// In real life, the user will enter "-port TCP4" instead. To keep things simple we switch off all unnecessary information.
input := []string{"trice", "log", "-port", "TCP4BUFFER", "-args", "localhost:" + portNumber, "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off"}
expect := `Hello! 👋🙂
expect := `w: Hello! 👋🙂
`

var out bytes.Buffer
Expand Down Expand Up @@ -113,7 +115,7 @@ func TestHEX(t *testing.T) {
// create a minimalistic til.json
assert.Nil(t, fSys.WriteFile("til.json", []byte(til), 0777))
input := []string{"trice", "log", "-port", "HEX", "-args", "09 92 19 06 45 0b 10 56 3a,00", "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off"}
expect := `Hello! 👋🙂
expect := `w: Hello! 👋🙂
`

var out bytes.Buffer
Expand Down Expand Up @@ -143,7 +145,7 @@ func TestDUMP(t *testing.T) {
// create a minimalistic til.json
assert.Nil(t, fSys.WriteFile("til.json", []byte(til), 0777))
input := []string{"trice", "log", "-port", "DUMP", "-args", "09 92 19 06 45 0b 10 56 3a,00", "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off"}
expect := `Hello! 👋🙂
expect := `w: Hello! 👋🙂
`

var out bytes.Buffer
Expand Down Expand Up @@ -173,7 +175,7 @@ func TestBUFFER(t *testing.T) {
// create a minimalistic til.json
assert.Nil(t, fSys.WriteFile("til.json", []byte(til), 0777))
input := []string{"trice", "log", "-port", "BUFFER", "-args", "9 146 25 6 69 11 16 86 58 00", "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off"}
expect := `Hello! 👋🙂
expect := `w: Hello! 👋🙂
`

var out bytes.Buffer
Expand Down Expand Up @@ -203,7 +205,7 @@ func TestDEC(t *testing.T) {
// create a minimalistic til.json
assert.Nil(t, fSys.WriteFile("til.json", []byte(til), 0777))
input := []string{"trice", "log", "-port", "DEC", "-args", "9 146 25 6 69 11 16 86 58 00", "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off"}
expect := `Hello! 👋🙂
expect := `w: Hello! 👋🙂
`

var out bytes.Buffer
Expand Down Expand Up @@ -235,7 +237,7 @@ func TestHEXToTCP(t *testing.T) {
// create a minimalistic til.json
assert.Nil(t, fSys.WriteFile("til.json", []byte(til), 0777))
input := []string{"trice", "log", "-port", "HEX", "-args", "09 92 19 06 45 0b 10 56 3a,00", "-pw", "MySecret", "-pf", "cobs", "-li", "off", "-hs", "off", "-color", "none", "-prefix", "off", "-ts", "off", "-tcp", "localhost" + portNR}
exp := " Hello! 👋🙂\n"
exp := "w: Hello! 👋🙂\n"

go func() { // listening for transmit
err := args.Handler(os.Stdout, fSys, input)
Expand Down
146 changes: 106 additions & 40 deletions docs/TriceReferenceManual.md

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions docs/TriceUserManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,19 @@ A tag is the prefix before the first colon, for example `info:` or `wrn:`. Try t
```sh
./show_text.sh -pick info
./show_json.sh -logLevel wrn
./show_json.sh -loglevel 600
./show_json.sh -ulabel sensor:650 -logLevel wrn
```

The first shows INFO events only. The second selects Warning and higher-priority events, including `Retry 2`. The third raises this tour's custom `sensor` tag above the Warning threshold, so `Humidity 55 percent` also appears. This is useful when you want all serious messages rather than a list of individual tags. Higher weights mean higher priority; a lower threshold admits more events.
The first shows INFO events only. The second selects Warning and higher-priority events, including `Retry 2`; the third uses the equivalent lowercase option spelling and numeric Warning threshold. The fourth raises this tour's custom `sensor` tag above the Warning threshold, so `Humidity 55 percent` also appears. This is useful when you want all serious messages rather than a list of individual tags. Higher weights mean higher priority; a lower threshold admits more events.

Built-in tag aliases such as `wrn`, `WARNING` and `Wrn` identify the same group for selection. Lowercase tags normally disappear from the displayed message; mixed/uppercase ones remain visible. A message without a recognized tag remains as written: `untagged` is classification metadata, not a prefix the tool invents in its message. Details: [tags, weights and selection](./TriceReferenceManual.md#trice-tags-color-and-weights).
Repeat `-pick` or `-ban` for several selectors: `./show_json.sh -pick info -pick wrn` displays either group. A number selects an exact weight: `-ban 450` hides this tour's sensor events, while `-pick 450` displays only events at weight 450. In comparison, `-loglevel 450` displays weights 450 and above. Colon-separated lists and weight ranges are rejected; use one selector per option.

JSON and KV derive `level` from the effective weight while keeping `tag` as the category. Here, `sensor` normally has weight 450 and appears as `tag=sensor level=DEBUG`. With `-ulabel sensor:650`, it becomes `tag=sensor level=WARNING`; its message and fields stay the same. RECEIVE normally has level DEBUG, and `untagged` has level INFO. The eight [level intervals](./TriceReferenceManual.md#json-and-kv-contract) stay fixed when tag weights are overridden.

Built-in tag names and aliases ignore case: `rx`, `RX` and `rX` all identify RECEIVE for selection, weights, colors, statistics and structured output. Lowercase tags normally disappear from the displayed message; mixed/uppercase ones remain visible, so `rX:payload` keeps its prefix. Free user tags match exactly: `new` and `NEW` can have separate weights; an unregistered spelling `NeW` is classified as `untagged`. A message without a recognized tag remains as written: `untagged` is classification metadata, not a prefix the tool invents in its message. Details: [tags, weights and selection](./TriceReferenceManual.md#trice-tags-color-and-weights).

Built-in aliases have at least two letters, for example `err`, `inf`, `msg`, `wrn`, `dbg`, `rx` and `tx`. Former one-letter aliases such as `e` are no longer recognized: `e:problem` remains visible and is classified as `untagged`. You can still explicitly register a one-letter user tag with `-ulabel x:200`.

### 3.3. <a id="read-target-stamps"></a>Read target stamps

Expand Down
28 changes: 15 additions & 13 deletions docs/ref/trice-help-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ sub-command 'ds|displayServer': Starts a display server.
-color string
The format strings can start with a lower or upper case channel information.
See https://github.com/rokath/trice/blob/main/_test/testdata/triceCheck.c for examples. Color options:
"off": Disable ANSI color. The lower case channel information is kept: "w:x"-> "w:x"
"none": Disable ANSI color. The lower case channel information is removed: "w:x"-> "x"
"off": Disable ANSI color. The lower case channel information is kept: "wr:x"-> "wr:x"
"none": Disable ANSI color. The lower case channel information is removed: "wr:x"-> "x"
"default|color": Use ANSI color codes for known upper and lower case channel info are inserted and lower case channel information is removed.
(default "default")
-ipa string
Expand Down Expand Up @@ -111,8 +111,8 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
port "HEX" or "DUMP": default="", Option for args is any space or comma separated byte sequence in hex. Example: -p DUMP -args "7B 1A ee,88, 5a".
(default "default")
-ban value
Tag group(s) to suppress. Repeat the option or separate names with colons. Registered aliases select their complete group; "all" suppresses every message and "off" suppresses none.
Example: "-ban dbg:wrn -ban diag" suppresses Debug, Warning, and Diag messages. Empty or unknown names are rejected after user tags are registered. Not usable with "-pick". See also "-ulabel" and "-logLevel".
Suppress a tag group or an exact effective integer weight (0..999). Supply one selector per option and repeat the option to exclude any matching group or weight. Colon lists and weight ranges are not supported. Built-in tags ignore case and user-defined tags match exactly. "all" suppresses every message and "off" suppresses none.
Example: "-ban dbg -ban wrn -ban 200" suppresses Debug, Warning, and every event at weight 200 (not 199 or 201). Empty or invalid selectors are rejected after user tags are registered. Not usable with "-pick". See also "-ulabel" and "-logLevel".
-baud int
Set the serial port baudrate.
It is the only setup parameter. The other values default to 8N1 (8 data bits, no parity, one stopbit).
Expand All @@ -131,8 +131,8 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
-color string
The format strings can start with a lower or upper case channel information.
See https://github.com/rokath/trice/blob/main/_test/testdata/triceCheck.c for examples. Color options:
"off": Disable ANSI color. The lower case channel information is kept: "w:x"-> "w:x"
"none": Disable ANSI color. The lower case channel information is removed: "w:x"-> "x"
"off": Disable ANSI color. The lower case channel information is kept: "wr:x"-> "wr:x"
"none": Disable ANSI color. The lower case channel information is removed: "wr:x"-> "x"
"default|color": Use ANSI color codes for known upper and lower case channel info are inserted and lower case channel information is removed.
(default "default")
-d16
Expand Down Expand Up @@ -204,7 +204,7 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
-logLevel string
Filter application events at or above a priority threshold. The value can be "all", "off", a registered tag or alias, or an integer from 0 to 999. Higher values mean higher priority; "off" suppresses all application events.
A typical use case is "-logLevel wrn". Application events without a recognized format-string tag use the built-in "untagged" group. Selection occurs once per event, before location information (-liFmt), target stamps (-ts0, -ts16, -ts32), prefix, suffix, and visualization are added.
Invalid values are rejected before the input channel is opened. User tags are registered before this value is resolved. See also CLI switches -ulabel, -pick and -ban. (default "all")
Invalid values are rejected before the input channel is opened. User tags are registered before this value is resolved. Built-in tag names and aliases ignore case; user-defined tags are matched exactly. The equivalent spelling -loglevel accepts the same values. See also CLI switches -ulabel, -pick and -ban. (default "all")
-logfile string
Append all output to logfile. Options are: 'off|none|filename|auto':
"off": no logfile (same as "none")
Expand All @@ -214,6 +214,8 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
All trice output of the appropriate subcommands is appended per default into the logfile additionally to the normal output.
Change the filename with "-logfile myName.txt" or switch logging off with "-logfile none".
(default "off")
-loglevel string
Alias for -logLevel; accepts all, off, a registered tag or alias, or an integer weight from 0 to 999. (default "all")
-newlineIndent int
Force newline offset for trice format strings with line breaks before end. -1=auto sense (default -1)
-noCycleCheck
Expand All @@ -230,8 +232,8 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
-pf string
Short for '-packageFraming'. (default "TCOBSv1")
-pick value
Tag group(s) to display exclusively. Repeat the option or separate names with colons. Registered aliases select their complete group; "all" selects every message and "off" selects none.
Example: "-pick err:wrn -pick default" displays only Error, Warning, and Default messages. Empty or unknown names are rejected after user tags are registered. Not usable with "-ban". See also "-ulabel" and "-logLevel".
Display only a tag group or an exact effective integer weight (0..999). Supply one selector per option and repeat the option to include any matching group or weight. Colon lists and weight ranges are not supported. Built-in tags ignore case and user-defined tags match exactly. "all" selects every message and "off" selects none.
Example: "-pick err -pick wrn -pick 200" displays Error, Warning, and every event at weight 200. This is exact selection; use -loglevel 200 for weight 200 and above. Empty or invalid selectors are rejected after user tags are registered. Not usable with "-ban". See also "-ulabel" and "-logLevel".
-port string
Case insensitive receiver device name: 'serial name|JLINK|STLINK|FILE|FILEBUFFER|TCP4|TCP4BUFFER|DEC|BUFFER|HEX|DUMP.
The serial name is like 'COM12' for Windows or a Linux name like '/dev/tty/usb12'.
Expand Down Expand Up @@ -291,7 +293,7 @@ sub-command 'l|log': For displaying trice logs coming from port. With "trice log
Selector-0/typeX0 handling for TREX logs. "error" reports X0 packets and is the default. "ignore" and "counted:ignore" silently discard valid counted X0 packets but still report malformed ones. "all:ignore" discards the complete selector-0 package without length checks and must only be used for non-mixed X0 packages. "counted:<format>" prints the counted payload with Go fmt. A value without ':' is shorthand for "counted:<format>". (default "error")
-u Short for '-unsigned'. (default true)
-ulabel value
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors".
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors". Built-in tag names and aliases ignore case; user-defined tags are matched exactly.
Example: "-ulabel motor -ulabel sensor:150 -ulabel motor:red:blue" registers a tag with color; "-ulabel msg:300 -ulabel msg:red:blue" combines weight and color for every built-in MESSAGE alias. "-ulabel new:300 -ulabel NEW:400" creates separate user labels. A new tag without a weight uses the final INFO weight. See also "-logLevel".
-unsigned
Hex, Octal and Bin values are printed as unsigned values. For signed output use -unsigned=false (default true)
Expand Down Expand Up @@ -592,7 +594,7 @@ sub-command 'i|insert': For updating til.json and inserting IDs into source file
Short for '-idlist'.
(default "til.json")
-ulabel value
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors".
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors". Built-in tag names and aliases ignore case; user-defined tags are matched exactly.
Example: "-ulabel motor -ulabel sensor:150 -ulabel motor:red:blue" registers a tag with color; "-ulabel msg:300 -ulabel msg:red:blue" combines weight and color for every built-in MESSAGE alias. "-ulabel new:300 -ulabel NEW:400" creates separate user labels. A new tag without a weight uses the final INFO weight. See also "-logLevel".
-v short for verbose
-verbose
Expand Down Expand Up @@ -695,7 +697,7 @@ sub-command 'b|bind': Generate stable Trice ID sidecars while keeping bind-owned
Short for '-idlist'.
(default "til.json")
-ulabel value
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors".
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors". Built-in tag names and aliases ignore case; user-defined tags are matched exactly.
Example: "-ulabel motor -ulabel sensor:150 -ulabel motor:red:blue" registers a tag with color; "-ulabel msg:300 -ulabel msg:red:blue" combines weight and color for every built-in MESSAGE alias. "-ulabel new:300 -ulabel NEW:400" creates separate user labels. A new tag without a weight uses the final INFO weight. See also "-logLevel".
-v short for verbose
-verbose
Expand Down Expand Up @@ -785,7 +787,7 @@ sub-command 'c|clean': Set all [id|Id|ID](n) inside source tree dir to [id|Id|ID
Short for '-idlist'.
(default "til.json")
-ulabel value
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors".
Register a tag or set its weight (0..999) or color. Repeat with name, name:weight, or name:color. Colors must match tokens shown by "trice generate -colors". Built-in tag names and aliases ignore case; user-defined tags are matched exactly.
Example: "-ulabel motor -ulabel sensor:150 -ulabel motor:red:blue" registers a tag with color; "-ulabel msg:300 -ulabel msg:red:blue" combines weight and color for every built-in MESSAGE alias. "-ulabel new:300 -ulabel NEW:400" creates separate user labels. A new tag without a weight uses the final INFO weight. See also "-logLevel".
-v short for verbose
-verbose
Expand Down
4 changes: 2 additions & 2 deletions docs/scratchPad/Implementierungsplan.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ Die sichtbare Ausgabe enthält kein synthetisches `untagged:` mehr. Für ungetag
| Format | Ausgabe für `trice("hi")`, ohne weitere Metadaten |
| --- | --- |
| Text | `hi` |
| JSON | `{"tag":"untagged","message":"hi"}` |
| KV | `tag=untagged message="hi"` |
| JSON | `{"tag":"untagged","level":"INFO","message":"hi"}` |
| KV | `tag=untagged level=INFO message="hi"` |

Bei einem unbekannten Präfix wie `trice("mgs:blah")` bleibt die Message `mgs:blah`, während das Tag-Metadatum `untagged` lautet. Dadurch bleibt auch ein möglicher Tippfehler sichtbar. Die bestehenden Darstellungsregeln für ausdrücklich geschriebene bekannte Tags bleiben erhalten; ebenso die Regeln für Leerraum und Zeilenabschluss. Anwendertext darf nicht durch pauschales Entfernen gleichlautender Textstücke verändert werden.

Expand Down
3 changes: 1 addition & 2 deletions examples/DemoData_Trice/triceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#include <stdint.h>

/*
* Keep normal TRice code active. This demo already contains a fixed iD(1000)
* This demo already contains a fixed iD(1000)
* and a matching private til.json, so an insertion step is not required.
*/
#define TRICE_CLEAN 0

/*
* A stack buffer is the simplest choice for this single-threaded host program.
Expand Down
2 changes: 0 additions & 2 deletions examples/F030_inst/Core/Inc/triceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ extern "C" {
#endif

#define TRICE_LEGACY_RPC_SUPPORT 1
//! TRICE_CLEAN, if found inside triceConfig.h, is modified by the Trice tool to silent editor warnings in the cleaned state.
#define TRICE_CLEAN 0 // Do not define this at an other place! But you can delete this here.

extern uint32_t ms32; //! ms32 is a 32-bit millisecond counter, counting circular in steps of 1 every ms.
#include "stm32f0xx_ll_system.h"
Expand Down
3 changes: 0 additions & 3 deletions examples/G0B1_features/Core/Inc/triceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ extern "C" {
// Limit custom assert messages to a safe size (>104) to avoid truncation
#define TRICE_SINGLE_MAX_SIZE 256

//! TRICE_CLEAN, if found inside triceConfig.h, is modified by the Trice tool to silent editor warnings in the cleaned state.
#define TRICE_CLEAN 0 // Do not define this at an other place! But you can delete this here.

// hardware specific trice lib settings
#include "main.h"
#define TriceStamp16 TIM17->CNT // 0...999 us
Expand Down
2 changes: 1 addition & 1 deletion examples/G0B1_features/Core/Inc/triceCustomAliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
FILENAME(file_path), line_number, condition_str, user_msg); \
char* out_var = full_msg

#if (defined(TRICE_CLEAN) && TRICE_CLEAN == 0) || !defined(TRICE_OFF) || TRICE_OFF == 0
#if TRICE_OFF == 0
// ALL calls have ID as first parameter.

#define CUSTOM_ASSERT_IMPL(id, condition, condition_str, file, line) \
Expand Down
Loading
Loading