Skip to content

Commit

Permalink
camel case for cause-of-transmission constants, plus cyclic name from…
Browse files Browse the repository at this point in the history
… section 5 rather than the per/cyc code from 101
  • Loading branch information
pascaldekloe committed Jul 26, 2024
1 parent 51de67e commit b4473a1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
30 changes: 15 additions & 15 deletions info/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,28 +467,28 @@ var errCauseZero = errors.New("part5: cause of transmission <0> is not used")
// “Additional cause of transmission”.
const (
_ Cause = iota // 0: not defined
Percyc // periodic, cyclic
Cyclic // periodic, cyclic
Back // background scan
Spont // spontaneous
Init // initialized
Req // request or requested
Act // activation
Actcon // activation confirmation
ActCon // activation confirmation
Deact // deactivation
Deactcon // deactivation confirmation
DeactCon // deactivation confirmation

Actterm // activation termination
Retrem // return information caused by a remote command
Retloc // return information caused by a local command
ActTerm // activation termination
RetRem // return information caused by a remote command
RetLoc // return information caused by a local command
File // file transfer
Auth // authentication
Seskey // maintenance of authentication session key
Usrkey // maintenance of user role and update key
SesKey // maintenance of authentication session key
UsrKey // maintenance of user role and update key
_ // 17: reserved for further compatible definitions
_ // 18: reserved for further compatible definitions
_ // 19: reserved for further compatible definitions

Inrogen // interrogated by station interrogation
InroGen // interrogated by station interrogation
Inro1 // interrogated by group 1 interrogation
Inro2 // interrogated by group 2 interrogation
Inro3 // interrogated by group 3 interrogation
Expand All @@ -506,12 +506,12 @@ const (
Inro14 // interrogated by group 14 interrogation
Inro15 // interrogated by group 15 interrogation
Inro16 // interrogated by group 16 interrogation
Reqcogen // requested by general counter request
Reqco1 // requested by group 1 counter request
Reqco2 // requested by group 2 counter request
Reqco3 // requested by group 3 counter request
ReqCoGen // requested by general counter request
ReqCo1 // requested by group 1 counter request
ReqCo2 // requested by group 2 counter request
ReqCo3 // requested by group 3 counter request

Reqco4 // requested by group 4 counter request
ReqCo4 // requested by group 4 counter request
_ // 41: reserved for further compatible definitions
_ // 42: reserved for further compatible definitions
UnkType // unknown type identification
Expand Down Expand Up @@ -561,7 +561,7 @@ func (c Cause) String() string {

var causeLabels = [64]string{
"notdef",
"per/cyc",
"cyclic", // conform section 5 instead of "per/cyc" introduced by companion standard 101
"back",
"spont",
"init",
Expand Down
8 changes: 4 additions & 4 deletions info/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ var goldenDataUnits = []struct {
DataUnit[OrigAddr8, ComAddr16, ObjAddr16]{
Type: M_SP_NA_1,
Enc: 1,
Cause: Percyc,
Cause: Cyclic,
Orig: Wide.MustOrigAddrN(7),
Addr: Wide.MustComAddrN(1001),
Info: []byte{1, 2, 3},
},
"M_SP_NA_1 per/cyc 7 1001: 0x03@513 .",
"M_SP_NA_1 cyclic 7 1001: 0x03@513 .",
}, {
DataUnit[OrigAddr8, ComAddr16, ObjAddr16]{
Type: M_DP_NA_1,
Expand All @@ -38,11 +38,11 @@ var goldenDataUnits = []struct {
DataUnit[OrigAddr8, ComAddr16, ObjAddr16]{
Type: M_SP_NA_1,
Enc: 0,
Cause: Percyc,
Cause: Cyclic,
Addr: Wide.MustComAddrN(404),
Info: []byte{},
},
"M_SP_NA_1 per/cyc 0 404: .",
"M_SP_NA_1 cyclic 0 404: .",
}, {
DataUnit[OrigAddr8, ComAddr16, ObjAddr16]{
Type: M_DP_NA_1,
Expand Down
10 changes: 5 additions & 5 deletions part5.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func isCommand(t info.TypeID) bool {
return t-45 < 25
}

// Response alternatives to info.Actcon are propagated as errors for simplicity.
// Response alternatives to info.ActCon are propagated as errors for simplicity.
var (
// A negative confirm denies without justification.
ErrConNeg = errors.New("part5: command not activated [actcon, P/N := <1>]")
Expand Down Expand Up @@ -77,18 +77,18 @@ func ConOf[Orig info.OrigAddr, Com info.ComAddr, Obj info.ObjAddr](in, req info.

// match cause of transmission, or not
switch in.Cause &^ info.TestFlag {
case info.Actcon:
case info.ActCon:
if req.Cause&^info.TestFlag == info.Act {
return nil // OK
}
case info.Deactcon:
case info.DeactCon:
if req.Cause&^info.TestFlag == info.Deact {
return nil // OK
}

case info.Actcon | info.NegFlag:
case info.ActCon | info.NegFlag:
return ErrConNeg
case info.Actterm:
case info.ActTerm:
return ErrTerm

// “ASDUs in the control direction with undefined values in the data
Expand Down

0 comments on commit b4473a1

Please sign in to comment.