@@ -49,6 +49,8 @@ type Decoder struct {
4949 lsfBytes []byte
5050 dashLog * slog.Logger
5151 lastLogTime time.Time
52+ errors int
53+ bits int
5254}
5355
5456// 8 preamble symbols, 8 for the syncword, and 960 for the payload.
@@ -79,6 +81,8 @@ func (d *Decoder) DecodeFrame(typ uint16, softBits []SoftBit) {
7981 d .timeoutCnt = 0
8082 d .lastStreamFN = 0xffff
8183 d .lastPacketFN = 0xff
84+ d .errors = e
85+ d .bits = 368
8286
8387 if d .lsf .Type [1 ]& byte (LSFTypeStream ) == byte (LSFTypeStream ) {
8488 d .syncedType = StreamSync
@@ -129,6 +133,8 @@ func (d *Decoder) DecodeFrame(typ uint16, softBits []SoftBit) {
129133
130134 case typ == PacketSync && d .syncedType == PacketSync :
131135 pktFrame , e := d .decodePacketFrame (softBits )
136+ d .errors += e
137+ d .bits += 368
132138 // log.Printf("[DEBUG] pktFrame: % x", pktFrame)
133139 lastFrame := (pktFrame [25 ] >> 7 ) != 0
134140
@@ -164,9 +170,9 @@ func (d *Decoder) DecodeFrame(typ uint16, softBits []SoftBit) {
164170 if d .dashLog != nil {
165171 if p .Type == PacketTypeSMS && len (p .Payload ) > 0 {
166172 msg := string (p .Payload [0 : len (p .Payload )- 1 ])
167- d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Packet" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (e ) / 3.68 )), "packetType" , p .Type , "smsMessage" , msg )
173+ d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Packet" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (d . errors ) / float64 ( d . bits ) * 100 )), "packetType" , p .Type , "smsMessage" , msg )
168174 } else {
169- d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Packet" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (e ) / 3.68 )), "packetType" , p .Type )
175+ d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Packet" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (d . errors ) / float64 ( d . bits ) * 100 )), "packetType" , p .Type )
170176 }
171177 }
172178 } else {
@@ -183,6 +189,8 @@ func (d *Decoder) DecodeFrame(typ uint16, softBits []SoftBit) {
183189 var fn uint16
184190 d .frameData , lich , fn , lichCnt , e = d .decodeStreamFrame (softBits )
185191 log .Printf ("[DEBUG] frameData: [% 2x], lich: %02x, lichCnt: %d, d.lichParts: %04x, fn: %04x, d.lastStreamFN: %04x, e: %d" , d .frameData , lich , lichCnt , d .lichParts , fn , d .lastStreamFN , e )
192+ d .errors += e
193+ d .bits += 272
186194 if d .lastStreamFN + 1 == fn & 0x7fff {
187195 if d .lichParts != 0x3F && lichCnt < 6 { //6 chunks = 0b111111
188196 //reconstruct LSF chunk by chunk
@@ -243,7 +251,7 @@ func (d *Decoder) DecodeFrame(typ uint16, softBits []SoftBit) {
243251 d .timeoutCnt = 0
244252 if d .dashLog != nil && lastFrame {
245253 log .Printf ("[DEBUG] Last frame for RF voice stream %04x" , d .streamID )
246- d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Voice End" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (e ) / 2.72 )))
254+ d .dashLog .Info ("" , "type" , "RF" , "subtype" , "Voice End" , "src" , d .lsf .Src .Callsign (), "dst" , d .lsf .Dst .Callsign (), "can" , d .lsf .CAN (), "mer" , json .Number (fmt .Sprintf ("%f" , float64 (d . errors ) / float64 ( d . bits ) * 100 )))
247255 }
248256 }
249257 if lastFrame {
@@ -413,4 +421,6 @@ func (d *Decoder) reset() {
413421 d .lastPacketFN = 0xff
414422 d .lastStreamFN = 0xffff
415423 d .lichParts = 0
424+ d .errors = 0
425+ d .bits = 0
416426}
0 commit comments