package satel import ( "strings" "golang.org/x/text/encoding/charmap" ) type DeviceType byte const ( DeviceType_Partition DeviceType = 0 DeviceType_Zone DeviceType = 1 DeviceType_User DeviceType = 2 DeviceType_ExpanderOrLCD DeviceType = 3 DeviceType_Output DeviceType = 4 DeviceType_ZoneWithPartitionAssignment DeviceType = 5 DeviceType_Timer DeviceType = 6 DeviceType_Telephone DeviceType = 7 DeviceType_Object DeviceType = 15 DeviceType_PartitionWithObjectAssignment DeviceType = 16 DeviceType_OutputWithDurationTime DeviceType = 17 DeviceType_PartitionWithObjectAssignmentAndOptions DeviceType = 18 ) type NameEvent struct { DevType DeviceType DevNumber byte DevTypeFunction byte DevName string } func makeNameEvent(bytes []byte) NameEvent { cp1250dec := charmap.Windows1250.NewDecoder() name, err := cp1250dec.String(string(bytes[3:19])) if err != nil { name = "CP1250 DECODE ERROR" } return NameEvent{ DevType: DeviceType(bytes[0]), DevNumber: bytes[1], DevTypeFunction: bytes[2], DevName: strings.TrimSpace(name), } }