-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg.go
53 lines (44 loc) · 1.04 KB
/
msg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2012 The can Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package can
// Message Flags.
type Flags int
const (
// message type
ExtFrame Flags = 1 << iota
RTRMsg
StatusMsg
// if StatusMsg is set:
ErrorActive
ErrorPassive
BusOff
DataOverrun
ReceiveBufferOverflow
)
// Reports wether the message is a status message, not a data message.
// In the first case, Msg fields Id, Len and Data should not be interpreted.
func (f Flags) IsStatus() bool {
return f&StatusMsg != 0
}
// Reports whether the message contains an 29 bit wide, extended indentifier,
// or a standard 11 bit wide identifier.
func (f Flags) ExtFrame() bool {
return f&ExtFrame != 0
}
func (f Flags) Test(t Flags) bool {
return (f & t) == t
}
// Definition of a CAN Message.
type Msg struct {
Id uint32 // The CAN message identifier
Flags
Len int
Data [8]byte
Tx struct {
Delayµs int // The driver shall delay this message.
}
Rx struct {
Time Time // Timestamp
}
}