An SECS-II/HSMS library written in go.
Users might need some knowledge on Go, SEMI Standards, and SECS Message Language (SML) to use this library.
-
Install the library
go get github.com/wolimst/lib-secs2-hsms-go
-
Import the packages and use them
Example: using the SECS-II parser
import ( "github.com/wolimst/lib-secs2-hsms-go/pkg/ast" "github.com/wolimst/lib-secs2-hsms-go/pkg/parser/sml" ) func main() { messages, errors, warnings := sml.Parse("S1F1 W\n.") // ... }
SECS-II/HSMS messages can be represented using the objects implemented in this library.
The message and data item objects are implemented as following structure.
Multi-byte string data type such as JIS-8 is not supported currently.
HSMSMessage (Interface)
├── DataMessage
└── ControlMessage
ItemNode (Interface)
├── ASCIINode
├── BinaryNode
├── BooleanNode
├── FloatNode
├── IntNode
├── ListNode
└── UintNode
Parse SML format input string into DataMessage
object.
This library extends the default SML syntax, and support following additional syntax.
These additional syntax are optional; the default syntax can be parsed as well.
-
Message direction (
H->E
,H<-E
orH<->E
) can be specified after the wait bit.Example:
S1F1 W H->E .
-
Message name can be specified after the message direction, or the wait bit if the message direction is not specified.
Message name can be any unicode characters except the whitespace characters.Example:
S1F1 W H->E AreYouThere? .
-
Line comment
Any text between//
and the end of the line is ignored by the parser.//
in ASCII quoted string is not a comment.Example:
S1F13 W // This is comment <L[2] <A MDLN> <A "1.0.0 // This is not a comment"> > .
-
Arbitrary data item size
Example:
S5F11 W <L[4] <A[32] TIMESTAMP> // size should be exactly 32 (SML default syntax) <A[5..20] EXID> // size should be in range of 5..20 (SML default syntax) <A[..5] EXTYPE> // size lower limit is 0, upper limit is 5 <A[5..] EXMESSAGE> // size lower limit is 5, upper limit is not specified > .
Parse HSMS byte sequence into DataMessage
or ControlMessage
object.
Example:
byte sequence 00 00 00 0A FF FF 00 00 00 05 FF FF FF FF
will be parsed to a ControlMessage
that represent linktest.req
.