FREESECS project

SECSII (SEMI E5 standard)

FREESECS solution for SECSII (SEMI E5) is the static library written in C++.
The library features:

Reads from and writes to SEMI E5 binary format

    uint8_t data[] = {...};//SEMI E5 binary message
    uint8_t begin = data;
    uint8_t end = data + sizeof(data);
    shared_ptr<data_item_t> pit;
    try
    {
        binary_deserializer_t bs(begin, end);//throws exception if things go bad
        pit = bs(NULL);
        pit->print(std::cout);
    }
    catch(...)
    {
        //handle deserialization error
    }
Data is printed-out in SML style:
    <L '' [4]
        <UI16 'DATAID' [1] 1>
        <ASCII 'CARRIERACTION' [15] CARRIER_0000001>
        <UI8 'PTN' [1] 1>
        <L 'CARRIERLIST' [5]
            <L '' [2]
                <ASCII 'CATTRID' [8] Capacity>
                < 'CATTRDATA' [1] 25>
            >
    ...
Serialization back to SEMI E5 binary format:
    pdata_item_t pit;
    (*pit)['DATA'] = "Hello world";
    binary_serializer_t::data_container_t raw_data = binary_serializer_t(pit);
raw_data shall be used to build a message to send over HSMS or SECSI

Converts to/from XML

Refer FREESECS SECSTWO XML schema file for SECSII XML format declaration.
Deserialization from XML:
    char buf[] = "
    <messages>
        <secsIImsg name=\"CR\">
            <stream>1</stream>
            <function>13</function>
            <wbit>1</wbit>
            <list>
                 <ascii name=\"MDLN\">Model 1</ascii>
                 <ascii name=\"SOFTREV\">v.1.0.0.0</ascii>
            </list>
        </secsIImsg>
    </messages>";
    xml_serializer_t::msg_container_t msgs;
    int err = xml_deserializer_t::from_mem(xml_membuf, sizeof(xml_membuf),schema_membuf, sizeof(schema_membuf), msgs);
    (*msgs.begin())->print(std::cout);
Output gives:
    S1F13 'CR' wbit=1 sysbytes=0
    <L '' [2]
        <ASCII 'MDLN' [7] Model 1>
        <ASCII 'SOFTREV' [9] v.1.0.0.0>
    >

SEMI E5 to XML and back

FREESECS SECSII corelib was primarily designed to convert semiconductor industry-specific E5 format to wide-used XML format keeping in mind IFA and XSLT. So conversion between SEMI E5 and XML is just a few lines:
    uint8_t *xml_format;
    uint8_t e5_format[] = {...};
    shared_ptr<data_item_t> pit;

    binary_deserializer_t bs(e5_format, e5_format + sizeof(e5_format));
    pit = bs(NULL);
    xml_serializer_t xs(pit);
    xml_format = xs.get();
    /*TODO: process XML*/
Converting from XML to SEMI E5 is done in similar way, please refer:
  • FREESECS SECSII serialization interface
  • FREESECS SECSII serialization test


  • FREESECS SECSII internal format

    SECSII data format is implemented with C++ composite pattern for SECSII data items plus overloading type cast operators for data access, assignment operators for data assignment "[]" operators for quick access to message data items.
    The format is defined in the interface header file secstwomsg.h

    Data access

    Data items can be accessed by name, index or both:
      std::string CARRIERACTION = (*s3f17)["CARRIERACTION"];//Access by data item name, identation is resolved automatically

      std::string OBJTYPE_ix = (*s14f9)[NUM(0)][NUM(0)];//Access by data item index

      std::string CATTRID_name = (*s3f17)["CARRIERLIST"][3]["CATTRID"];//Mixed access by data item name and index
    All SEMI E5 data types are supported:
      uint64_t data_64bit = (*s127f127)["uint64"];//Support unsigned 64-bit data

      uint8_t data_8bit = (*s127f127)["uint8"];//Support unsigned 8-bit data

      uint8_t data_16bit = (*s127f127)["uint16"];//Support unsigned 16-bit data

      uint32_t data_32bit = (*s127f127)["uint32"];//Support unsigned 32-bit data

      int64_t data_64bit = (*s127f127)["int64"];//Support signed 64-bit data

      int8_t data_8bit = (*s127f127)["int8"];//Support signed 8-bit data

      int8_t data_16bit = (*s127f127)["int16"];//Support signed 16-bit data

      int32_t data_32bit = (*s127f127)["int32"];//Support signed 32-bit data

      double data_double = (*s127f127)["double"];//Support signed double-precision fp data

      float data_float = (*s127f127)["float"];//Support signed fp data

      bool data_bool = (*s127f127)["bool"];//Support boolean data

      while(ix < (*s127f127)["binary"].size())
          bdata[ix] = (*s127f127)["binary"][ix];//Support accessing data item array
    String data types are cast to C++ std::string. Non-ascii data types (JIS-8, Unicode), are converted to UTF-8 format with ICONV library.
      std::string ascii = (*s127f127)["ascii"];//Support ASCII string

      std::string uincode = (*s127f127)["unicode"];//Support Unicode string

      std::string jis8 = (*s127f127)["jis8"];//Support JIS-8 string



    Data assignment

    Data is assigned in similar way it is accessed.


    Incoming message contents checking

    Messaged can be compared to each other. This is to be used to check incoming messages for structure and expected data and send Stream 9 System Errors back.
    This coveres well the use case of accepting S6,F11 Event Reports with a limited range of CEID values.
      /*Match message structure only, do not treat data*/
      bool match_struct = s3f17_msg->match(incoming_msg, STRUCT);

      /*Match structure and data*/
      bool match_data = s3f17_msg->match(incoming_msg, DATA);

      /*
          For all data items in s3f17_msg:
          Match structure of that in incoming.
          If a data item contains some actual data,
          then match it with that of incoming.
      */
      bool match_non_empty = s3f17_msg->match(incoming_msg, NON_EMPTY_DATA);

      /*Match structure and data, including variable lists and arrays*/
      bool match_all = s3f17_msg->match(incoming_msg, ALL);

      /*Equivalent to match(ALL)*/
      bool match = (*s3f17_msg) == (*incoming_msg);


    Support for variable SEMI E5 List Data items

    SEMI E5 defines lots of messages having lists of variable length of data of same type. To handle this, FREESECS SECSII has got "variable" Lists, i.e. List data items that can take any number of data items of pre-defined type. These lists are declared in XML as follows:
      <list name="SlotMap" variable="true">
          <uint8>1</uint8>
          <uint8>2</uint8>
          <uint8>3</uint8>
          ...
      </list>
    The number of items in the declaration is the list initial contents, minimum one item is allowed to tell to the library the variables of which type the list takes. The list is handled with FREESECS SECSII internal format as follows:
      /*Clear the contents*/
      (*s3f17)["SlotMap"].clear_data();
      /*Clone the List contents data type using magic number*/
      pdata_item_t slotmap_element = (*s3f17)["SlotMap"][VAR_ARRAY_ELEMENT].clone();

      /*Fill the list with own data*/
      for(int i=0; i < 25; ++i)
      {
          *slotmap_element = i;
          (*s3f17)["SlotMap"] += slotmap_element;
      }
    For all data handling features, refer data test coming along with FREESECS SECSII library.