add some things
This commit is contained in:
parent
1bd003843c
commit
2dab308907
77
gen_skylab.go
Normal file
77
gen_skylab.go
Normal file
|
@ -0,0 +1,77 @@
|
|||
//go:build ignore
|
||||
|
||||
// this file is a generator for skylab code.
|
||||
package main
|
||||
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Field interface {
|
||||
Name() string
|
||||
|
||||
}
|
||||
type PacketField struct {
|
||||
Name string
|
||||
Type string
|
||||
Units string
|
||||
Conversion float32
|
||||
}
|
||||
|
||||
type PacketDef struct {
|
||||
Name string
|
||||
Description string
|
||||
Id uint32
|
||||
BigEndian bool
|
||||
data: []PacketField
|
||||
|
||||
}
|
||||
// we need to generate bitfield types.
|
||||
// packet structs per each packet
|
||||
// constancts for packet IDs or a map.
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
example for a simple packet type
|
||||
it also needs a json marshalling.
|
||||
|
||||
type BMSMeasurement struct {
|
||||
BatteryVoltage uint16
|
||||
AuxVoltage uint16
|
||||
Current float32
|
||||
}
|
||||
|
||||
func (b *BMSMeasurement)MarshalPacket() ([]byte, error) {
|
||||
pkt := make([]byte, b.Size())
|
||||
binary.LittleEndian.PutUint16(b.BatteryVoltage * 0.01)
|
||||
binary.LittleEndian.PutUint16(b.AuxVoltage * 0.001)
|
||||
binary.LittleEndian.PutFloat32(b.Current) // TODO: make float function
|
||||
}
|
||||
|
||||
func (b *BMSMeasurement)UnmarshalPacket(p []byte) error {
|
||||
|
||||
}
|
||||
|
||||
func (b *BMSMeasurement) Id() uint32 {
|
||||
return 0x010
|
||||
}
|
||||
|
||||
func (b *BMSMeasurement) Size() int {
|
||||
return 8
|
||||
}
|
||||
|
||||
func (b *BMSMeasurement) String() string {
|
||||
return 'blah blah"
|
||||
}
|
||||
|
||||
we also need some kind of mechanism to lookup data type.
|
||||
|
||||
func getPkt (id uint32, data []byte) (Packet, error) {
|
||||
|
||||
// insert really massive switch case statement here.
|
||||
}
|
||||
|
||||
*/
|
|
@ -47,7 +47,7 @@ func (c *rpcConnTrack) Claim() (uint32, chan Response) {
|
|||
|
||||
// Clear deletes the connection from the tracker and returns the channel
|
||||
// associated with it. The caller can use the channel afterwards
|
||||
// to send the response.
|
||||
// to send the response. It is the caller's responsibility to close the channel.
|
||||
func (c *rpcConnTrack) Clear(val uint32) (chan Response, error) {
|
||||
c.mu.RLock()
|
||||
ch, ok := c.ct[val]
|
||||
|
|
Loading…
Reference in a new issue