Skip to content

Commit 3f1b420

Browse files
committed
linted
1 parent 27703cc commit 3f1b420

25 files changed

+180
-168
lines changed

β€Ž.code_snippets/ReadMe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Some heper code for copying where to use
1+
# Some helper code for copying where to use
22

33
BackUp/ = legacy stuff

β€ŽREADME.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This slightly simplified [view](https://github.com/jgraph/drawio) is explained [
5151
## Data Transfer
5252

5353
- Inplemented:
54-
- [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter) conectable to virtual UART over USB
54+
- [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter) connectable to virtual UART over USB
5555
- [RTT](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) over [J-Link](./third_party/segger.com/ReadMe.md) and [RTT over ST-Link](./third_party/goST/ReadMe.md)
5656
- A small separate micro-controller is always usable as interfaces bridge to [GPIO](https://circuitcellar.com/cc-blog/a-trace-tool-for-embedded-systems/), [IΒ²C](https://en.wikipedia.org/wiki/I%C2%B2C), [SPI](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface), [CAN](https://en.wikipedia.org/wiki/CAN_bus), [LIN](https://en.wikipedia.org/wiki/Local_Interconnect_Network), ...
5757

@@ -132,7 +132,7 @@ First are the PC reception timestamps and after the port info are the used *tric
132132
133133
The same is possible for **interrupt timing analysis**.
134134
135-
- Mixed case *trice* macros are [short](./docs/TriceEncodings.md#flex-short-sub-encoding) trices and the letter i at the end says **i**nside critical section. (FLEX encoding)
135+
- Mixed case TRICE macros are [short](./docs/TriceEncodings.md#flex-short-sub-encoding) *Trices* and the letter i at the end says **i**nside critical section. (FLEX encoding)
136136
- `Trice16( "tim: myFunc %d\n", sysTick );` before and after a function call lets you easy measure the function execution time.
137137
- As graphical visualization you could use a tool similar to [https://github.com/sqshq/sampler](https://github.com/sqshq/sampler).
138138

β€Žcmd/cui/cuip.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func setCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) {
2424
return g.SetViewOnTop(name)
2525
}
2626

27-
func nextView(g *gocui.Gui, v *gocui.View) error {
27+
func nextView(g *gocui.Gui, _ *gocui.View) error {
2828
nextIndex := (active + 1) % len(viewArr)
2929
name := viewArr[nextIndex]
3030

@@ -108,7 +108,7 @@ func layout(g *gocui.Gui) error {
108108
return nil
109109
}
110110

111-
func quit(g *gocui.Gui, v *gocui.View) error {
111+
func quit(_ *gocui.Gui, _ *gocui.View) error {
112112
return gocui.ErrQuit
113113
}
114114

β€Žcmd/trice/main_test.go

+97-103
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@ package main
55

66
import (
77
"bytes"
8-
"io/ioutil"
9-
"log"
108
"os"
119
"sync"
1210
"testing"
13-
"time"
1411

1512
"github.com/rokath/trice/internal/args"
16-
"github.com/rokath/trice/internal/decoder"
17-
"github.com/rokath/trice/internal/emitter"
18-
"github.com/rokath/trice/internal/id"
19-
"github.com/rokath/trice/pkg/msg"
2013
"github.com/rokath/trice/pkg/tst"
21-
"github.com/tj/assert"
2214
)
2315

2416
var (
@@ -39,14 +31,6 @@ func execHelper(t *testing.T, expect string) {
3931
tst.EqualLines(t, expect, act)
4032
}
4133

42-
func getTemporaryFileName(pattern string) string {
43-
tempFileHandle, e := ioutil.TempFile(os.TempDir(), pattern) // opens for read and write
44-
msg.OnErr(e)
45-
tempFileName := tempFileHandle.Name()
46-
msg.OnErr(tempFileHandle.Close())
47-
return tempFileName
48-
}
49-
5034
func TestTriceWrong(t *testing.T) {
5135
os.Args = []string{"trice", "wrong"}
5236
expect := `unknown sub-command 'wrong'. try: 'trice help|h'
@@ -67,6 +51,28 @@ func TestTriceVersion(t *testing.T) {
6751
date = ""
6852
}
6953

54+
/*
55+
func stdoutDoit() {
56+
doit(os.Stdout)
57+
}
58+
59+
var osArgsBUFFER []string
60+
61+
func example(args []string) {
62+
m.Lock()
63+
dn, e := ioutil.TempDir("", "sampledir")
64+
msg.FatalOnErr(e)
65+
//fn := createCFile(dn)
66+
os.Args = append(args, "-src", dn)
67+
//act := tst.CaptureStdOut(stdoutDoit)
68+
//b, e := os.ReadFile(fn)
69+
msg.FatalOnErr(e)
70+
msg.FatalOnErr(os.RemoveAll(dn))
71+
id.DryRun = false // reset changed value
72+
os.Args = os.Args[:0]
73+
m.Unlock()
74+
}
75+
7076
//for some reason this test disturbs in parallel execution
7177
func _TestDoitDssd(t *testing.T) {
7278
o := msg.OsExitDisallow()
@@ -95,51 +101,62 @@ func _TestDoitDssd(t *testing.T) {
95101
tst.EqualLines(t, expSD, actM)
96102
}
97103
98-
func stdoutDoit() {
99-
doit(os.Stdout)
104+
func _ExampleDoit5() {
105+
example([]string{"trice", "zeroSourceTreeIds", "-dry-run"})
106+
// Output:
107+
// ... TRICE0( Id(100), "tata");...
108+
// Id(100) -> Id(0)
100109
}
101110
102-
func _TestDoitDssd_a(t *testing.T) {
103-
o := msg.OsExitDisallow()
104-
defer msg.OsExitAllow(o)
105-
m.Lock()
106-
log.SetFlags(0)
107-
os.Args = []string{"trice", "ds", "-color", "off", "-ipp", "61498"}
108-
var actDS string
109-
go func() {
110-
actDS = tst.CaptureStdOut(stdoutDoit)
111-
}()
112-
time.Sleep(100 * time.Millisecond)
111+
func _ExampleDoit6() {
112+
example([]string{"trice", "zeroSourceTreeIds"})
113+
// Output:
114+
// ... TRICE0( Id(0), "tata");...
115+
// Id(100) -> Id(0)
116+
}
113117
114-
//os.Args = append(osArgsBUFFER, "-ds")
115-
//actSD := tst.CaptureStdOut(stdoutDoit)
118+
func _getTemporaryFileName(pattern string) string {
119+
tempFileHandle, e := ioutil.TempFile(os.TempDir(), pattern) // opens for read and write
120+
msg.OnErr(e)
121+
tempFileName := tempFileHandle.Name()
122+
msg.OnErr(tempFileHandle.Close())
123+
return tempFileName
124+
}
116125
117-
os.Args = []string{"trice", "sd", "-ipp", "61498"}
118-
actSD := tst.CaptureStdOut(stdoutDoit)
119-
os.Args = os.Args[:0]
120-
time.Sleep(100 * time.Millisecond)
126+
// func TestMain(t *testing.M) {
127+
// // do stuff before tests
128+
// fnTIL := createTIL()
129+
// osArgsBUFFER = []string{"trice", "log", "-p", "BUFFER", "-args", "2, 124, 227, 255, 0, 0, 4, 0", "-ts", "off", "-color", "off", "-idlist", fnTIL}
130+
//
131+
// exitVal := t.Run() // tests
132+
//
133+
// // do stuff after tests
134+
// msg.FatalOnErr(os.Remove(fnTIL))
135+
//
136+
// os.Exit(exitVal) // done
137+
// }
138+
139+
func _ExampleDoit3() {
140+
m.Lock()
121141
142+
os.Args = osArgsBUFFER
143+
//act := tst.CaptureStdOut(stdoutDoit)
144+
os.Args = os.Args[:0]
122145
m.Unlock()
123-
assert.Equal(t, "displayServer @ localhost:61498\nBUFFER: MSG: triceFifoMaxDepth = 4, select = 0\n", actDS)
124-
actM := actSD[0:19] + "xxxxx" + actSD[24:]
125-
assert.Equal(t, "\n\ndbg:displayServerxxxxxdown\n\n\naccept tcp 127.0.0.1:61498: use of closed network connection", actM)
146+
// Output:
147+
// BUFFER: MSG: triceFifoMaxDepth = 4, select = 0
126148
}
127149
128-
func _TestDoitDssd_b(t *testing.T) {
129-
o := msg.OsExitDisallow()
130-
defer msg.OsExitAllow(o)
150+
func _ExampleDoit4() {
131151
m.Lock()
132-
os.Args = append(osArgsBUFFER, "-ds", "-autostart", "-ipp", "61499")
152+
os.Args = append(osArgsBUFFER, "-testTable", "-prefix", " }, `")
133153
//act := tst.CaptureStdOut(stdoutDoit)
134-
time.Sleep(100 * time.Millisecond)
135-
136-
os.Args = []string{"trice", "sd", "-ipp", "61499"}
137-
actSD := tst.CaptureStdOut(stdoutDoit)
138154
os.Args = os.Args[:0]
139-
time.Sleep(100 * time.Millisecond)
155+
decoder.TestTableMode = false // reset changed value
156+
emitter.Prefix = args.DefaultPrefix // reset changed value
140157
m.Unlock()
141-
actM := actSD[0:19] + "xxxxx" + actSD[24:]
142-
assert.Equal(t, "read tcp 127.0.0.1:xxxxx->127.0.0.1:61499: wsarecv: An existing connection was forcibly closed by the remote host.", actM)
158+
// Output:
159+
//{ []byte{ 2,124,227,255, 0, 0, 4, 0, }, `MSG: triceFifoMaxDepth = 4, select = 0`},
143160
}
144161
145162
// // createTIL returns a name of a temporary file containing a valid trice id JSON map
@@ -168,69 +185,46 @@ func _TestDoitDssd_b(t *testing.T) {
168185
// return
169186
// }
170187
171-
var osArgsBUFFER []string
172-
173-
// func TestMain(t *testing.M) {
174-
// // do stuff before tests
175-
// fnTIL := createTIL()
176-
// osArgsBUFFER = []string{"trice", "log", "-p", "BUFFER", "-args", "2, 124, 227, 255, 0, 0, 4, 0", "-ts", "off", "-color", "off", "-idlist", fnTIL}
177-
//
178-
// exitVal := t.Run() // tests
179-
//
180-
// // do stuff after tests
181-
// msg.FatalOnErr(os.Remove(fnTIL))
182-
//
183-
// os.Exit(exitVal) // done
184-
// }
185-
186-
func _ExampleDoit_c() {
188+
func _TestDoitDssd1(t *testing.T) {
189+
o := msg.OsExitDisallow()
190+
defer msg.OsExitAllow(o)
187191
m.Lock()
192+
log.SetFlags(0)
193+
os.Args = []string{"trice", "ds", "-color", "off", "-ipp", "61498"}
194+
var actDS string
195+
go func() {
196+
actDS = tst.CaptureStdOut(stdoutDoit)
197+
}()
198+
time.Sleep(100 * time.Millisecond)
188199
189-
os.Args = osArgsBUFFER
190-
//act := tst.CaptureStdOut(stdoutDoit)
191-
os.Args = os.Args[:0]
192-
m.Unlock()
193-
// Output:
194-
// BUFFER: MSG: triceFifoMaxDepth = 4, select = 0
195-
}
200+
//os.Args = append(osArgsBUFFER, "-ds")
201+
//actSD := tst.CaptureStdOut(stdoutDoit)
196202
197-
func _ExampleDoit_d() {
198-
m.Lock()
199-
os.Args = append(osArgsBUFFER, "-testTable", "-prefix", " }, `")
200-
//act := tst.CaptureStdOut(stdoutDoit)
203+
os.Args = []string{"trice", "sd", "-ipp", "61498"}
204+
actSD := tst.CaptureStdOut(stdoutDoit)
201205
os.Args = os.Args[:0]
202-
decoder.TestTableMode = false // reset changed value
203-
emitter.Prefix = args.DefaultPrefix // reset changed value
206+
time.Sleep(100 * time.Millisecond)
207+
204208
m.Unlock()
205-
// Output:
206-
//{ []byte{ 2,124,227,255, 0, 0, 4, 0, }, `MSG: triceFifoMaxDepth = 4, select = 0`},
209+
assert.Equal(t, "displayServer @ localhost:61498\nBUFFER: MSG: triceFifoMaxDepth = 4, select = 0\n", actDS)
210+
actM := actSD[0:19] + "xxxxx" + actSD[24:]
211+
assert.Equal(t, "\n\ndbg:displayServerxxxxxdown\n\n\naccept tcp 127.0.0.1:61498: use of closed network connection", actM)
207212
}
208213
209-
func example(args []string) {
214+
func _TestDoitDssd2(t *testing.T) {
215+
o := msg.OsExitDisallow()
216+
defer msg.OsExitAllow(o)
210217
m.Lock()
211-
dn, e := ioutil.TempDir("", "sampledir")
212-
msg.FatalOnErr(e)
213-
//fn := createCFile(dn)
214-
os.Args = append(args, "-src", dn)
218+
os.Args = append(osArgsBUFFER, "-ds", "-autostart", "-ipp", "61499")
215219
//act := tst.CaptureStdOut(stdoutDoit)
216-
//b, e := os.ReadFile(fn)
217-
msg.FatalOnErr(e)
218-
msg.FatalOnErr(os.RemoveAll(dn))
219-
id.DryRun = false // reset changed value
220+
time.Sleep(100 * time.Millisecond)
221+
222+
os.Args = []string{"trice", "sd", "-ipp", "61499"}
223+
actSD := tst.CaptureStdOut(stdoutDoit)
220224
os.Args = os.Args[:0]
225+
time.Sleep(100 * time.Millisecond)
221226
m.Unlock()
227+
actM := actSD[0:19] + "xxxxx" + actSD[24:]
228+
assert.Equal(t, "read tcp 127.0.0.1:xxxxx->127.0.0.1:61499: wsarecv: An existing connection was forcibly closed by the remote host.", actM)
222229
}
223-
224-
func _ExampleDoit_e() {
225-
example([]string{"trice", "zeroSourceTreeIds", "-dry-run"})
226-
// Output:
227-
// ... TRICE0( Id(100), "tata");...
228-
// Id(100) -> Id(0)
229-
}
230-
231-
func _ExampleDoit_f() {
232-
example([]string{"trice", "zeroSourceTreeIds"})
233-
// Output:
234-
// ... TRICE0( Id(0), "tata");...
235-
// Id(100) -> Id(0)
236-
}
230+
*/

β€Žinternal/args/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func scVersion(w io.Writer) error {
184184
// distributeArgs is distributing values used in several packages.
185185
// It must not be called before the appropriate arg parsing.
186186
func distributeArgs(w io.Writer) {
187-
com.Verbose = verbose
187+
//com.Verbose = verbose
188188
id.Verbose = verbose
189189
link.Verbose = verbose
190190
cage.Verbose = verbose

β€Žinternal/args/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ If you need target timestamps you need to get the time inside the target and sen
101101
fsScLog.StringVar(&decoder.ShowTargetLocation, "tLocFmt", "%16s:%4d ", `Target location format string at start of each line, if target location existent (configured). Use "" to suppress existing target location. If several trices form a log line only the location of first trice ist displayed.`)
102102
fsScLog.StringVar(&decoder.ShowTargetTimestamp, "ttsf", "time:%9d ", `Target timestamp format string at start of each line, if target timestamps existent (configured). Use "" to suppress existing target timestamps. If several trices form a log line only the timestamp of first trice ist displayed.`)
103103
fsScLog.BoolVar(&decoder.DebugOut, "debug", false, "Show additional debug information")
104-
fsScLog.StringVar(&decoder.TargetEndianess, "targetEndianess", "littleEndian", `Target endianness trice data stream. Option: "bigEndian".`)
104+
fsScLog.StringVar(&decoder.TargetEndianness, "targetEndianess", "littleEndian", `Target endianness trice data stream. Option: "bigEndian".`)
105105
fsScLog.StringVar(&emitter.ColorPalette, "color", "default", colorInfo) // flag
106106
fsScLog.StringVar(&emitter.Prefix, "prefix", DefaultPrefix, "Line prefix, options: any string or 'off|none' or 'source:' followed by 0-12 spaces, 'source:' will be replaced by source value e.g., 'COM17:'.") // flag
107107
fsScLog.StringVar(&emitter.Suffix, "suffix", "", "Append suffix to all lines, options: any string.") // flag

β€Žinternal/args/short_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ func TestUpdateV(t *testing.T) {
6262
execHelper(t, args, expect)
6363
}
6464

65-
func _TestComX(t *testing.T) {
66-
args := []string{"trice", "log", "-p", "COMX", "-idList", "emptyFile"}
67-
expect := `can not open COMX`
68-
execHelper(t, args, expect)
69-
}
65+
// func _TestComX(t *testing.T) {
66+
// args := []string{"trice", "log", "-p", "COMX", "-idList", "emptyFile"}
67+
// expect := `can not open COMX`
68+
// execHelper(t, args, expect)
69+
// }
7070

7171
func TestVersion(t *testing.T) {
7272
verbose = false

β€Žinternal/args/tricehelp_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func TestHelpRefresh(t *testing.T) {
397397
`
398398
execHelper(t, args, expect)
399399
}
400-
400+
/*
401401
func _TestHelpLog(t *testing.T) {
402402
args := []string{"trice", "help", "-log"}
403403
expect := `syntax: 'trice sub-command' [params]
@@ -535,3 +535,5 @@ func _TestHelpLog(t *testing.T) {
535535
`
536536
execHelper(t, args, expect)
537537
}
538+
539+
*/

β€Žinternal/args/tricehelpall_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
package args
55

6-
import "testing"
7-
6+
/*
87
func _TestHelpAll(t *testing.T) {
98
input := []string{"trice", "help", "-all"}
109
expected := `syntax: 'trice sub-command' [params]
@@ -385,3 +384,4 @@ func _TestHelpAll(t *testing.T) {
385384
`
386385
execHelper(t, input, expected)
387386
}
387+
*/

β€Žinternal/com/com.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
Baud int
2020

2121
// Verbose shows additional information if set true.
22-
Verbose bool
22+
// Verbose bool
2323
)
2424

2525
// COMport is the comport interface type to use different COMports.

β€Žinternal/decoder/_decoder_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,7 @@ func _TestTranslate(t *testing.T) {
30213021
assert.Nil(t, lu.FromJSON([]byte(til)))
30223022
m := new(sync.RWMutex) // m is a pointer to a read write mutex for lu
30233023
Encoding = "FLEX"
3024-
TargetEndianess = "littleEndian"
3024+
TargetEndianness = "littleEndian"
30253025
receiver.Port = "BUFFER"
30263026
ShowID = "%d"
30273027
defer func() {

0 commit comments

Comments
Β (0)