forked from quimcalpe/iracing-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.go
45 lines (39 loc) · 1.07 KB
/
header.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
package irsdk
import (
"log"
)
type header struct {
version int
status int
tickRate int // ticks per second (60 or 360 etc)
// session information, updated periodicaly
sessionInfoUpdate int // Incremented when session info changes
sessionInfoLen int // Length in bytes of session info string
sessionInfoOffset int // Session info, encoded in YAML format
// state data, output at tickRate Hz
numVars int // length of array pointed to by varHeaderOffset
headerOffset int // offset to irsdk_varHeader[numVars] array, Describes the variables received in varBuf
numBuf int
bufLen int // length in bytes for one line
}
func readHeader(r reader) header {
rbuf := make([]byte, 48)
_, err := r.ReadAt(rbuf, 0)
if err != nil {
log.Fatal(err)
}
h := header{
byte4ToInt(rbuf[0:4]),
byte4ToInt(rbuf[4:8]),
byte4ToInt(rbuf[8:12]),
byte4ToInt(rbuf[12:16]),
byte4ToInt(rbuf[16:20]),
byte4ToInt(rbuf[20:24]),
byte4ToInt(rbuf[24:28]),
byte4ToInt(rbuf[28:32]),
byte4ToInt(rbuf[32:36]),
byte4ToInt(rbuf[36:40]),
}
//fmt.Printf("%v\n%+v\n", rbuf, h)
return h
}