update json tags for idx

This commit is contained in:
saji 2023-05-22 08:41:37 -05:00
parent 38ac8d8e55
commit 580c6d756a
3 changed files with 9 additions and 7 deletions

View file

@ -284,8 +284,6 @@ func main() {
// then we need to make a header template. // then we need to make a header template.
v := &SkylabFile{} v := &SkylabFile{}
fmt.Printf("running %s on %s\n", os.Args[0], os.Getenv("GOFILE"))
basePath, err := filepath.Abs(os.Args[1]) basePath, err := filepath.Abs(os.Args[1])
if err != nil { if err != nil {
panic(err) panic(err)

View file

@ -1,4 +1,4 @@
// generated by gen_skylab.go at 2023-05-20 12:46:09.664376329 -0500 CDT m=+0.002839937 DO NOT EDIT! // generated by gen_skylab.go at 2023-05-22 08:37:01.7251166 -0500 CDT m=+0.002980842 DO NOT EDIT!
package skylab package skylab
@ -232,6 +232,8 @@ var idMap = map[uint32]bool{
0x117: true, 0x117: true,
} }
// FromCanFrame creates a Packet from a given CAN ID and data payload.
// If the CAN ID is unknown, it will return an error.
func FromCanFrame(id uint32, data []byte) (Packet, error) { func FromCanFrame(id uint32, data []byte) (Packet, error) {
if !idMap[id] { if !idMap[id] {
return nil, errors.New("Unknown Id") return nil, errors.New("Unknown Id")
@ -1554,7 +1556,7 @@ type BmsModule struct {
// 1 C // 1 C
Temperature float32 `json:"temperature"` Temperature float32 `json:"temperature"`
// Idx is the packet index. The accepted range is 0-36 // Idx is the packet index. The accepted range is 0-36
Idx uint32 Idx uint32 `json:"idx"`
} }
func (p *BmsModule) CANId() (uint32, error) { func (p *BmsModule) CANId() (uint32, error) {
@ -2541,7 +2543,7 @@ func (p *VisionRearviewCommand) String() string {
type TrackerEnable struct { type TrackerEnable struct {
Enable uint8 `json:"enable"` Enable uint8 `json:"enable"`
// Idx is the packet index. The accepted range is 0-6 // Idx is the packet index. The accepted range is 0-6
Idx uint32 Idx uint32 `json:"idx"`
} }
func (p *TrackerEnable) CANId() (uint32, error) { func (p *TrackerEnable) CANId() (uint32, error) {
@ -3631,7 +3633,7 @@ type TrackerData struct {
// 0.01 C // 0.01 C
Temperature uint16 `json:"temperature"` Temperature uint16 `json:"temperature"`
// Idx is the packet index. The accepted range is 0-6 // Idx is the packet index. The accepted range is 0-6
Idx uint32 Idx uint32 `json:"idx"`
} }
func (p *TrackerData) CANId() (uint32, error) { func (p *TrackerData) CANId() (uint32, error) {

View file

@ -41,7 +41,7 @@ type {{$structName}} struct {
{{- end}} {{- end}}
{{- if .Repeat }} {{- if .Repeat }}
// Idx is the packet index. The accepted range is 0-{{.Repeat}} // Idx is the packet index. The accepted range is 0-{{.Repeat}}
Idx uint32 Idx uint32 `json:"idx"`
{{- end }} {{- end }}
} }
@ -110,6 +110,8 @@ var idMap = map[uint32]bool{
{{- end}} {{- end}}
} }
// FromCanFrame creates a Packet from a given CAN ID and data payload.
// If the CAN ID is unknown, it will return an error.
func FromCanFrame(id uint32, data []byte) (Packet, error) { func FromCanFrame(id uint32, data []byte) (Packet, error) {
if !idMap[id] { if !idMap[id] {
return nil, errors.New("Unknown Id") return nil, errors.New("Unknown Id")