Versions in this module Expand all Collapse all v0 v0.2.0 Oct 11, 2026 Changes in this version type Master + func (m *Master) Repeater(ctx context.Context, c, ci byte, data []byte, answer bool) (Frame, error) v0.1.0 Oct 11, 2026 Changes in this version + const ACK + const ActADT + const ActIDEN + const ActiveImagesLAI + const AddrBroadcast + const AddrBroadcastAns + const AddrRepeater + const AddrReserved + const AddrSecondary + const AddrTest + const AddrUnconfigured + const CIAlarmLong + const CIAlarmShort + const CIAppErrLong + const CIAppErrNone + const CIAppErrShort + const CIAppReset + const CIAppSelect + const CIAppSelectLong + const CIAppSelectShort + const CIClockSync + const CIImageCmdLong + const CIImageCmdShort + const CIImageRspLong + const CIImageRspShort + const CIReqSelLong + const CIReqSelShort + const CIReqSelected + const CIRspAlarm + const CIRspDLMSLong + const CIRspDLMSShort + const CIRspFixed + const CIRspFixedM + const CIRspNoHeader + const CIRspSelLong + const CIRspSelShort + const CIRspSelected + const CIRspShort + const CIRspVariable + const CIRspVariableM + const CISelect + const CISetData + const CISynchronize + const CReqUD1 + const CReqUD2 + const CRspUD + const CSndNke + const CSndUD + const CSndUD2 + const CmplAINF + const CmplIDEN + const CmplRspIDEN + const CmplRspLIB + const CmplRspNBR + const CmplRspTNLB + const FCB + const FCV + const FixedBinary + const FixedPermanent + const FixedPowerLow + const FixedStored + const FixedTemporary + const ImgActivate + const ImgActiveImages + const ImgCompletion + const ImgPrepare + const ImgResponse + const ImgState + const ImgSynchronize + const ImgTerminate + const ImgTransfer + const ImgValidate + const MaxApplication + const MaxLongData + const NACK + const PrepADT + const PrepIDEN + const PrepINFO + const PrepMAC + const PrepMCAS + const PrepRspAINF + const PrepRspIDEN + const PrepRspINFO + const PrepRspMCAS + const PrepRspRDY + const PrepRspSZIN + const PrepSZIN + const StateActivationFailed + const StateActivationInitiated + const StateActivationSuccessful + const StateIdle + const StateTransferFailed + const StateTransferSuccessful + const StateValidationActive + const StateValidationFailed + const StateValidationInitiated + const StateValidationSuccessful + const SyncCTDN + const SyncIDEN + const TCAddJ + const TCAddM + const TCCorrectJ + const TCCorrectM + const TCSetI + const TCSetM + const TCSubtractJ + const TCSubtractM + const TermIDEN + const TermTIT + const TermTTR + const XferAINF + const XferIDEN + const XferREM + const XferSeqFirst + const XferSeqLast + const XferSeqMiddle + var ErrFrame = errors.New("invalid M-Bus frame") + var ErrImageNoResponse = errors.New("no image transfer response") + var ErrNoAnswer = errors.New("no answer") + var ErrSegmentLength = errors.New("invalid image transfer segment length") + var ErrTimeout = errors.New("no answer within the timeout") + var ImageStates = [16]string + var PrepareResults = []string + var Wildcard = SecondaryAddress + func AppErrorName(c byte) string + func Application(code int) string + func BaudCI(baud int) (byte, error) + func BitTime(baud int) time.Duration + func CIBaud(ci byte) int + func DialTCP(ctx context.Context, address string) (io.ReadWriteCloser, error) + func EncodeSegments(segs ...Segment) []byte + func Epoch2013(t time.Time) []byte + func FrameTime(n, baud int) time.Duration + func Full(a *SecondaryAddress) bool + func LongHeader(id SecondaryAddress, acc byte) ([]byte, error) + func MaxAnswerDelay(baud int) time.Duration + func OpenSerial(dev string, baud int) (io.ReadWriteCloser, error) + func ParseSubcode(b []byte) (app, block int, err error) + func QuietAfter(n, baud int) time.Duration + func SelectSubcode(app, block int) ([]byte, error) + func StatusInfo(s byte) map[string]any + func TypeI(t time.Time) []byte + func TypeJ(h, m, s int) []byte + func TypeM(t time.Time, n int) []byte + func TypeMDuration(d time.Duration, n int) ([]byte, error) + type AppError struct + Code byte + Data []byte + Name string + func ParseAppError(b []byte) AppError + func (e AppError) Error() string + type ClockSync struct + Diff time.Duration + Function byte + Legacy bool + Time time.Time + func (c ClockSync) Encode() ([]byte, error) + type CompletionRsp struct + ID *ImageID + Lost []uint16 + LostFrom int + NoneReceived bool + Total int + func ParseCompletionRsp(s Segment) (CompletionRsp, error) + func (r CompletionRsp) Missing(n int) []uint16 + type FixedCounter struct + Historic bool + Quantity string + Unit string + UnitCode byte + Valid bool + Value float64 + type FixedData struct + Access byte + Counters [2]FixedCounter + ID string + Medium string + Status byte + func ParseFixed(p []byte, msbFirst bool) (*FixedData, error) + type Frame struct + A byte + C byte + CI byte + Data []byte + Long bool + Nack bool + Single bool + func ReadFrame(r io.ByteReader) (Frame, error) + func (f Frame) Check() error + func (f Frame) Encode() []byte + type ImageID struct + DeviceType byte + Image uint32 + Manufacturer uint16 + Version byte + func (id ImageID) Bytes() []byte + type MAC struct + Algorithm byte + KeyID byte + KeyVersion byte + Value []byte + type MTime struct + Duration time.Duration + Invalid bool + Offset int + Relative bool + Time time.Time + func ParseTypeM(b []byte) (MTime, error) + type Master struct + Log *slog.Logger + Retries int + Timeout time.Duration + func NewMaster(baud int) *Master + func (m *Master) Baud() int + func (m *Master) CheckAppError(ctx context.Context, a byte) (*AppError, error) + func (m *Master) ConfirmAlarm(ctx context.Context, a byte) error + func (m *Master) Exchange(ctx context.Context, f Frame, answer bool) (Frame, error) + func (m *Master) ExpectACK(ctx context.Context, f Frame, what string) error + func (m *Master) ImageCommand(ctx context.Context, a byte, hdr []byte, seg Segment, want bool) (Segment, error) + func (m *Master) Port() (*Port, error) + func (m *Master) Probe(ctx context.Context, pattern SecondaryAddress) (int, SecondaryAddress, error) + func (m *Master) ReadAddress(ctx context.Context, a byte) (SecondaryAddress, error) + func (m *Master) ReadTelegrams(ctx context.Context, a byte, max int, fn func(Telegram) error) (int, error) + func (m *Master) RequestClass1(ctx context.Context, a byte) (*Response, error) + func (m *Master) Reset(ctx context.Context, a byte) error + func (m *Master) Search(ctx context.Context) ([]SecondaryAddress, error) + func (m *Master) Select(ctx context.Context, t Target) (byte, error) + func (m *Master) SelectApplication(ctx context.Context, a byte, app, block int) error + func (m *Master) SelectOne(ctx context.Context, t Target) (a byte, full *SecondaryAddress, err error) + func (m *Master) SetPort(p *Port, baud int) + func (m *Master) SetPrimary(ctx context.Context, t Target, to byte) (lostACK bool, err error) + func (m *Master) SwitchBaud(ctx context.Context, a byte, baud int) error + type Port struct + func NewPort(rw io.ReadWriteCloser) *Port + func (p *Port) Close() error + func (p *Port) Done() <-chan struct{} + func (p *Port) Drain() + func (p *Port) Err() error + func (p *Port) ReadByte() (byte, error) + func (p *Port) SetDeadline(t time.Time) + func (p *Port) Write(b []byte) (int, error) + type PrepareCmd struct + Absolute bool + Additional *[2]byte + ID *ImageID + MAC *MAC + Multicast bool + Pace byte + Size *SizeInfo + Start uint32 + func (c PrepareCmd) Segment(id byte) (Segment, error) + type PrepareRsp struct + Additional []byte + ID *ImageID + Multicast bool + Ready bool + Result byte + Size *SizeInfo + func ParsePrepareRsp(s Segment) (PrepareRsp, error) + func (r PrepareRsp) ResultName() string + type Response struct + ACD bool + Access byte + Address SecondaryAddress + Alarm []byte + AppError *AppError + CI byte + DLMS []byte + DecodeOK bool + Fixed *FixedData + Header bool + More bool + Primary byte + Records []records.Record + Selected bool + Status byte + TPDU *tpdu.TPDU + UnknownCI bool + func ParseResponse(f Frame) (*Response, error) + func (r *Response) HasStatus() bool + type SecondaryAddress struct + ID string + Manufacturer uint16 + Medium byte + Version byte + func ParsePattern(s string) (SecondaryAddress, error) + func ParseSecondary(b []byte) SecondaryAddress + func (s SecondaryAddress) Bytes() ([]byte, error) + func (s SecondaryAddress) Key() string + func (s SecondaryAddress) Matches(pattern SecondaryAddress) bool + type Segment struct + Function byte + ID byte + Params []byte + Sub byte + func EncodeCompletionRsp(id byte, lost []uint16, none bool) Segment + func ParseSegments(b []byte) ([]Segment, error) + func SimpleCmd(id byte, function byte, img *ImageID, flags byte, extra []byte) Segment + type SizeInfo struct + BlockSize uint16 + Blocks uint16 + Repetition byte + type StateRsp struct + Function byte + ID *ImageID + State int + func ParseStateRsp(s Segment) (StateRsp, error) + type Target struct + Name string + Primary byte + Secondary *SecondaryAddress + type Telegram struct + APDU []byte + ParseErr error + type TransferCmd struct + Block uint16 + Blocks uint16 + Data []byte + ID *ImageID + Remaining bool + func ParseTransferCmd(s Segment) (TransferCmd, error) + func (c TransferCmd) Segment(id byte) Segment