File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ type CanMessageLog struct {
1818 Length uint8 `json:"length"`
1919 Timestamp time.Time `json:"timestamp"`
2020 Direction string `json:"direction"` // "RX" for received messages
21+
22+ HEX_ID string `json:"hex_id"` // Hexadecimal representation of ID
23+ HEX_Data []string `json:"hex_data"` // Hexadecimal representation of data
2124}
2225
2326// InterfaceMessageBuffer manages message history for a single interface
@@ -238,6 +241,14 @@ func (cml *CanMessageListener) StopListening(interfaceName string) error {
238241 return nil
239242}
240243
244+ func bytesToHexArray (data []byte ) []string {
245+ hexArray := make ([]string , len (data ))
246+ for i , b := range data {
247+ hexArray [i ] = fmt .Sprintf ("%02X" , b )
248+ }
249+ return hexArray
250+ }
251+
241252// listenOnInterface performs the actual message listening for an interface
242253func (cml * CanMessageListener ) listenOnInterface (listener * interfaceListener ) {
243254 listener .isRunning = true
@@ -290,6 +301,9 @@ func (cml *CanMessageListener) listenOnInterface(listener *interfaceListener) {
290301 Length : frame .Length ,
291302 Timestamp : time .Now (),
292303 Direction : "RX" ,
304+
305+ HEX_ID : fmt .Sprintf ("%08x" , frame .ID ),
306+ HEX_Data : bytesToHexArray (data ),
293307 }
294308
295309 // Add to buffer
You can’t perform that action at this time.
0 commit comments