psi: removed byteToBool func as can do this by other means

This commit is contained in:
saxon 2019-01-07 16:30:48 +10:30
parent ba9e5a3136
commit 13b8c23351
1 changed files with 5 additions and 12 deletions

View File

@ -124,8 +124,8 @@ func ReadPSI(data []byte) *PSI {
}
psi.Tid = data[pos]
pos++
psi.Ssi = byteToBool(data[pos] & 0x80)
psi.Pb = byteToBool(data[pos] & 0x40)
psi.Ssi = data[pos]&0x80 != 0
psi.Pb = data[pos]&0x40 != 0
psi.Sl = uint16(data[pos]&0x03)<<8 | uint16(data[pos+1])
pos += 2
psi.Tss = readTSS(data[pos:], &psi)
@ -139,7 +139,7 @@ func readTSS(data []byte, p *PSI) *TSS {
tss.Tide = uint16(data[pos])<<8 | uint16(data[pos+1])
pos += 2
tss.V = (data[pos] & 0x3e) >> 1
tss.Cni = byteToBool(data[pos] & 0x01)
tss.Cni = data[pos]&0x01 != 0
pos++
tss.Sn = data[pos]
pos++
@ -237,7 +237,7 @@ func (t *TSS) Bytes() []byte {
out := make([]byte, TSSDefLen)
out[0] = byte(t.Tide >> 8)
out[1] = byte(t.Tide)
out[2] = 0xc0 | (0x3e & (t.V << 1)) | (0x01 & boolToByte(t.Cni))
out[2] = 0xc0 | (0x3e & (t.V << 1)) | (0x01 & asByte(t.Cni))
out[3] = t.Sn
out[4] = t.Lsn
out = append(out, t.Sd.Bytes()...)
@ -291,16 +291,9 @@ func (e *ESSD) Bytes() []byte {
return out
}
func boolToByte(b bool) (o byte) {
func asByte(b bool) (o byte) {
if b {
o = 0x01
}
return
}
func byteToBool(b byte) (o bool) {
if b != 0 {
o = true
}
return
}