Documentation ¶
Overview ¶
Package media provides the OSI media layers from section 1 & 2.
Index ¶
Constants ¶
const ( // format class 1.1, section 1, subclause 6.2.4.1, rule R4 FT11IdleBits = 22 // format class 1.2, section 1, subclause 6.2.4.2.1, rule R4 FT12IdleBits = 33 // format class 2, section 1, subclause 6.2.4.3.1, rule R5 FT2IdleBits = 48 // format class 3, section 1, subclause 6.2.4.4.1, rule R5 FT3IdleBits = 54 )
Upon detecting an error, a minimum interval of line idle bits is required between packets, depending on the type.
const ( DataSize = 8 // bits in charater StopBits = 1 // character termination Parity = 'E' // even check bit )
Fixed serial configuration parameters defined in section 1. See also companion standard 101, annex 1.1 — UART definition.
const FrameBits = 1 + DataSize + 1 + StopBits
FrameBits is the number of bits per character needed at the physical layer.
Variables ¶
var ErrAddrFit = errors.New("part5: station address doesn't fit system-specific octet size")
Signals Addr is out of bounds.
var ErrCheck = errors.New("part5: checksum, constant or redundant value mismatch in packet")
ErrCheck signals integrity verification failure.
var ErrDataFit = errors.New("part5: user data size exceeds packet capacity or system limit")
ErrDataFit signals user data out of bounds.
Functions ¶
This section is empty.
Types ¶
type Addr ¶
type Addr uint16
Addr is a secondary station address. The actual presence and size is system-dependent. When not in use (with size 0) then GlobalAddr is the mandatory value in all cases.
The reference may be to a single station, a group of stations or all other stations. Group addresses should be defined by agreements between users and vendors.
const GlobalAddr Addr = 0xffff
GlobalAddr is the broadcast address. Use this value on 1 octet addressing systems too [not 255]. This value is applicable in 3 cases, namely (1) for single (control) character frames (2) for systems with addressing disabled (3) for unbalanced systems in combination with
type Ctrl ¶
type Ctrl byte
Ctrl is the control field.
const ( // Function codes from section 2, table 1 & 3. Reset Ctrl = iota // 0: reset of remote link ResetProc // 1: reset of user process Test // 2: test function for link (for balanced systems) Give // 3: user data: send/confirm expected Toss // 4: user data: send/no reply expected AvailReq // 8: poll access demand (for unbalanced systems) StatusReq // 9: request status of link Class1Req // 10: request submission of user data (for unbalanced systems) Class2Req // 11: request submission of user data (for unbalanced systems) // Flipped on every frame when FrameCountValidFlag to delete losses and duplications. FrameCountFlag Ctrl = 1 << 5 // Marks the applicability of FrameCountFlag for Test, Give, Class1Req and Class2Req. FrameCountValidFlag Ctrl = 1 << 4 )
Protocol-control from primary (initiating) stations. See section 2, clause 5.1.2 & 6.1.2.
const ( // Function codes from section 2, table 2 & 4. Ack Ctrl = iota // 0: positive acknowledgement Nack // 1: message not accepted, link busy Data // 8: submission of user data (for unbalanced systems) NoData // 9: no pending user data (for unbalanced systems) OK // 11: status of link or access demand Down // 14: link service not functioning NoImpl // 15: link service not implemented // Data flow control: further messages may cause buffer overflow. OverflowFlag Ctrl = 1 << 4 // With unbalanced transmission, secondary stations [slaves] may report // the availability of class 1 data with this flag. XSDemandFlag Ctrl = 1 << 5 )
Protocol-control from secondary (responding) stations. See section 2, clause 5.1.2 & 6.1.2. For permissible combinations see companion standard 101, table 3 & 4.
const FromPrimaryFlag Ctrl = 1 << 6
FromPrimaryFlag marks the frame direction.
const FuncMask Ctrl = 1<<4 - 1
FuncMask gets the function code from the control field.
type FT ¶
FT is a format class for Packet encoding.
func NewFT12 ¶
NewFT12 returns a new codec for format class FT 1.2, integrity class Ⅱ, Hamming distance 4.
The number of octets for station addresses must be in [0, 2]. When disabled with 0, packets use GlobalAddr exclusively.
The fuction of single (control) character Ⅰ (0xE5) and Ⅱ (0xA2) depends on the system. Character Ⅰ is usually Ack. Don't forget to set FromPrimaryFlag where applicable. Both characters are decoded as a packet with GlobalAddr in place.
WARNING! The implementation reuses one data buffer which makes operation efficient. The user data in packets can only be used until the next call.
See section 2, subclause 3.2 and companion standard 101, annex 1.2.