Rename CI-V decoder

This commit is contained in:
Nonoo 2020-10-30 20:28:45 +01:00
parent 451ae6a9ec
commit bf9f095c14
2 changed files with 10 additions and 10 deletions

View file

@ -4,10 +4,10 @@ import "math"
const civAddress = 0xa4
type civDecoderStruct struct {
type civControlStruct struct {
}
func (s *civDecoderStruct) decode(d []byte) {
func (s *civControlStruct) decode(d []byte) {
if len(d) < 6 || d[0] != 0xfe || d[1] != 0xfe || d[len(d)-1] != 0xfd {
return
}
@ -30,7 +30,7 @@ func (s *civDecoderStruct) decode(d []byte) {
}
}
func (s *civDecoderStruct) decodeFreq(d []byte) {
func (s *civControlStruct) decodeFreq(d []byte) {
var f float64
var pos int
for _, v := range d {
@ -44,7 +44,7 @@ func (s *civDecoderStruct) decodeFreq(d []byte) {
statusLog.reportFrequency(f)
}
func (s *civDecoderStruct) decodeMode(d []byte) {
func (s *civControlStruct) decodeMode(d []byte) {
if len(d) < 1 {
return
}
@ -87,7 +87,7 @@ func (s *civDecoderStruct) decodeMode(d []byte) {
statusLog.reportMode(mode, filter)
}
func (s *civDecoderStruct) decodePower(d []byte) {
func (s *civControlStruct) decodePower(d []byte) {
if len(d) < 3 || d[0] != 0x0a {
return
}
@ -98,7 +98,7 @@ func (s *civDecoderStruct) decodePower(d []byte) {
statusLog.reportTxPower(percent)
}
func (s *civDecoderStruct) decodePTT(d []byte) {
func (s *civControlStruct) decodePTT(d []byte) {
if len(d) < 2 {
return
}
@ -118,7 +118,7 @@ func (s *civDecoderStruct) decodePTT(d []byte) {
statusLog.reportPTT(ptt, tune)
}
func (s *civDecoderStruct) query(st *serialStream) error {
func (s *civControlStruct) query(st *serialStream) error {
// Querying frequency.
if err := st.send([]byte{254, 254, civAddress, 224, 3, 253}); err != nil {
return err

View file

@ -19,7 +19,7 @@ type serialStream struct {
receivedSerialData bool
lastReceivedSeq uint16
civDecoder civDecoderStruct
civControl civControlStruct
readFromSerialPort struct {
buf bytes.Buffer
@ -93,7 +93,7 @@ func (s *serialStream) handleRxSeqBufEntry(e seqBufEntry) {
e.data = e.data[21:]
s.civDecoder.decode(e.data)
s.civControl.decode(e.data)
if serialPort.write != nil {
serialPort.write <- e.data
@ -253,7 +253,7 @@ func (s *serialStream) init(devName string) error {
s.readFromSerialPort.frameTimeout = time.NewTimer(0)
<-s.readFromSerialPort.frameTimeout.C
if err := s.civDecoder.query(s); err != nil {
if err := s.civControl.query(s); err != nil {
return err
}