Commit c9ef074b authored by Yann Garcia's avatar Yann Garcia
Browse files

Implementing TP/VBS/MSGF/BV-01 to TP/VBS/MSGF/BV-20

parent ac6fba97
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,15 @@ namespace LibItsVru__TestSystem {
    loggers::get_instance().set_stop_time(_time_key, duration);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }
  }


  void UpperTesterPort::outgoing_send(const LibItsVru__TypesAndValues::UtVamTrigger &send_par) {
    loggers::get_instance().log_msg(">>> UppertesterPort_Vru::outgoing_send: ", send_par);

    float duration;
    loggers::get_instance().set_start_time(_time_key);
    static_cast<uppertester_vru_layer *>(_layer)->sendMsg(send_par, _layer_params);
    loggers::get_instance().set_stop_time(_time_key, duration);
  }

  void UpperTesterPort::receiveMsg(const Base_Type &p_ind, const params &p_params) {
  void UpperTesterPort::receiveMsg(const Base_Type &p_ind, const params &p_params) {
    loggers::get_instance().log_msg(">>> UpperTesterPort_Vru::receive_msg: ", p_ind);
    loggers::get_instance().log_msg(">>> UpperTesterPort_Vru::receive_msg: ", p_ind);
    // Sanity check
    // Sanity check
+1 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ namespace LibItsVru__TestSystem {
    void user_stop();
    void user_stop();


    void outgoing_send(const LibItsVru__TypesAndValues::UtVamInitialize &send_par);
    void outgoing_send(const LibItsVru__TypesAndValues::UtVamInitialize &send_par);
    void outgoing_send(const LibItsVru__TypesAndValues::UtVamTrigger &send_par);
  };
  };


} // namespace LibItsVru__TestSystem
} // namespace LibItsVru__TestSystem
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@ cps_layer::cps_layer(const std::string &p_type, const std::string &param) : t_la
  // Setup parameters
  // Setup parameters
  params::convert(_params, param);
  params::convert(_params, param);
  _params.insert(std::make_pair<std::string, std::string>("its_aid", "639"));     // ETSI TS 102 965 V2.1.1 (2021-11) 
  _params.insert(std::make_pair<std::string, std::string>("its_aid", "639"));     // ETSI TS 102 965 V2.1.1 (2021-11) 
  _params.insert(std::make_pair<std::string, std::string>("payload_type", "2")); // CP message id - See ETSI TS 102 894
  _params.insert(std::make_pair<std::string, std::string>("payload_type", "14")); // CP message id - See ETSI TS 102 894


  // Register this object for AdapterControlPort
  // Register this object for AdapterControlPort
  loggers::get_instance().log("cps_layer::cps_layer: Register %s/%p", p_type.c_str(), this);
  loggers::get_instance().log("cps_layer::cps_layer: Register %s/%p", p_type.c_str(), this);
+10 −62
Original line number Original line Diff line number Diff line
@@ -11,9 +11,10 @@
template <typename T_type> class OPTIONAL;
template <typename T_type> class OPTIONAL;
class TTCN_EncDec;
class TTCN_EncDec;


unsigned char uppertester_vru_codec::c_utVamInitialize              = 0x00;
uint8_t uppertester_vru_codec::c_utVamInitialize       = 0x00;
unsigned char uppertester_vru_codec::c_utVamInitializeResult        = 0x01;
uint8_t uppertester_vru_codec::c_utVamInitializeResult = 0x01;
unsigned char uppertester_vru_codec::c_utVamEventInd                = 0x23;
uint8_t uppertester_vru_codec::c_utVamSetProfile       = 0x20;
uint8_t uppertester_vru_codec::c_utVamEventInd         = 0x23;


int uppertester_vru_codec::encode(const Record_Type &msg, OCTETSTRING &data) {
int uppertester_vru_codec::encode(const Record_Type &msg, OCTETSTRING &data) {
  loggers::get_instance().log_msg(">>> uppertester_vru_codec::encode: ", (const Record_Type &)msg);
  loggers::get_instance().log_msg(">>> uppertester_vru_codec::encode: ", (const Record_Type &)msg);
@@ -21,7 +22,7 @@ int uppertester_vru_codec::encode(const Record_Type &msg, OCTETSTRING &data) {
  TTCN_EncDec::clear_error();
  TTCN_EncDec::clear_error();
  TTCN_Buffer encoding_buffer;
  TTCN_Buffer encoding_buffer;
  if (std::string(msg.get_descriptor()->name).compare("@LibItsVru_TypesAndValues.UtVamInitialize") == 0) {
  if (std::string(msg.get_descriptor()->name).compare("@LibItsVru_TypesAndValues.UtVamInitialize") == 0) {
    encoding_buffer.put_c(static_cast<const unsigned char>(uppertester_vru_codec::c_utVamInitialize));
    encoding_buffer.put_c(static_cast<const uint8_t>(uppertester_vru_codec::c_utVamInitialize));
  } else { // Error
  } else { // Error
    data = OCTETSTRING(0, nullptr);
    data = OCTETSTRING(0, nullptr);
    loggers::get_instance().warning("<<< uppertester_vru_codec::encode: Failed to encode UT message");
    loggers::get_instance().warning("<<< uppertester_vru_codec::encode: Failed to encode UT message");
@@ -55,63 +56,10 @@ int uppertester_vru_codec::encode_(const Base_Type &type, const TTCN_Typedescrip
        encoding_buffer.put_c(0x00);
        encoding_buffer.put_c(0x00);
      }
      }
    } // End of 'for' statement
    } // End of 'for' statement
  } else {
    std::string s(field_descriptor.name);
    loggers::get_instance().log("uppertester_vru_codec::encode_: field to process %s", s.c_str());
    if ((s.rfind(".shape") != string::npos) || (s.rfind(".relevanceDistance") != string::npos) || (s.rfind(".relevanceTrafficDirection") != string::npos)) {
      encoding_buffer.put_c((unsigned char)static_cast<const Enum_Type &>(type).as_int());
    } else if (s.rfind(".payload") != string::npos) {
      const OCTETSTRING & os  = static_cast<const OCTETSTRING &>(type);
      const unsigned char s[] = {(unsigned char)((os.lengthof() & 0x0000FF00) >> 8), (unsigned char)os.lengthof()};
      encoding_buffer.put_s(2, s);
      if (os.lengthof() != 0) {
        encoding_buffer.put_string(os);
      }
    } else if (s.rfind(".detectionTime") != string::npos) {
      unsigned long long llu = static_cast<const INTEGER &>(type).get_long_long_val();
      loggers::get_instance().log("uppertester_vru_codec::encode_ : detectionTime=%llu", llu);
      std::vector<unsigned char> v;
      for (int i = 0; i < 6; i++) {
        v.insert(v.begin(), static_cast<unsigned char>(llu));
        llu >>= 8;
      } // End of 'for' statement
      OCTETSTRING os(v.size(), v.data());
      loggers::get_instance().log_msg("uppertester_vru_codec::encode_: timeDetection=", os);
      encoding_buffer.put_string(os);
    } else if ((s.rfind(".validityDuration") != string::npos) || (s.rfind(".repetitionDuration") != string::npos)) {
      if (type.is_present()) {
        const OPTIONAL<INTEGER> &o = dynamic_cast<const OPTIONAL<INTEGER> &>(type);
        const INTEGER &          i = static_cast<const INTEGER &>(*o.get_opt_value());
        loggers::get_instance().log_msg("uppertester_vru_codec::encode_: i=", i);
        encoding_buffer.put_string(int2oct(i, 3));
      }
    } else if ((s.rfind(".informationQuality") != string::npos) || (s.rfind(".causeCode") != string::npos) || (s.rfind(".subCauseCode") != string::npos)) {
      const INTEGER &i = static_cast<const INTEGER &>(type);
      encoding_buffer.put_string(int2oct(i, 1));
    } else if ((s.rfind(".linkedCause") != string::npos) || (s.rfind(".eventHistory") != string::npos)) {
      // Skip them
    } else if ((s.rfind(".transmissionInterval") != string::npos) || (s.rfind(".repetitionInterval") != string::npos)) {
      if (type.is_present()) {
        const OPTIONAL<INTEGER> &o = dynamic_cast<const OPTIONAL<INTEGER> &>(type);
        const INTEGER &          i = static_cast<const INTEGER &>(*o.get_opt_value());
        encoding_buffer.put_string(int2oct(i, 2));
      }
    } else if (s.rfind(".originatingStationID") != string::npos) {
      const INTEGER &i = static_cast<const INTEGER &>(type);
      encoding_buffer.put_string(int2oct(i, 4));
    } else if (s.rfind(".sequenceNumber") != string::npos) {
      const INTEGER &i = static_cast<const INTEGER &>(type);
      encoding_buffer.put_string(int2oct(i, 2));
    } else if (s.rfind(".AlacarteContainer") != string::npos) {
      const OPTIONAL<OCTETSTRING> &o  = dynamic_cast<const OPTIONAL<OCTETSTRING> &>(type);
      const OCTETSTRING &          os = static_cast<const OCTETSTRING &>(*o.get_opt_value());
      encoding_buffer.put_string(int2oct(os.lengthof(), 2));
      encoding_buffer.put_string(os);
  } else {
  } else {
    loggers::get_instance().log("uppertester_vru_codec::encode_ (else): processing type %s/%s", type.get_descriptor()->name, field_descriptor.name);
    loggers::get_instance().log("uppertester_vru_codec::encode_ (else): processing type %s/%s", type.get_descriptor()->name, field_descriptor.name);
    type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW);
    type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW);
  }
  }
  }


  loggers::get_instance().log_to_hexa("<<<uppertester_vru_codec::encode_: encoding_buffer=", encoding_buffer);
  loggers::get_instance().log_to_hexa("<<<uppertester_vru_codec::encode_: encoding_buffer=", encoding_buffer);
  return 0;
  return 0;
@@ -133,7 +81,7 @@ std::unique_ptr<Base_Type> uppertester_vru_codec::decode(const OCTETSTRING &data


  std::unique_ptr<Base_Type> result;
  std::unique_ptr<Base_Type> result;


  const unsigned char *ptr = static_cast<const unsigned char *>(data);
  const uint8_t *ptr = static_cast<const uint8_t *>(data);
  if (*ptr != uppertester_vru_codec::c_utVamEventInd) {
  if (*ptr != uppertester_vru_codec::c_utVamEventInd) {
    LibItsVru__TypesAndValues::UtVamResults res;
    LibItsVru__TypesAndValues::UtVamResults res;
    if (decode(data, res, params) == 0) {
    if (decode(data, res, params) == 0) {
@@ -153,7 +101,7 @@ std::unique_ptr<Base_Type> uppertester_vru_codec::decode(const OCTETSTRING &data
int uppertester_vru_codec::decode(const OCTETSTRING &data, LibItsVru__TypesAndValues::UtVamResults &msg, params_its *params) {
int uppertester_vru_codec::decode(const OCTETSTRING &data, LibItsVru__TypesAndValues::UtVamResults &msg, params_its *params) {
  loggers::get_instance().log_to_hexa(">>> uppertester_vru_codec::decode: decoding_buffer=", data);
  loggers::get_instance().log_to_hexa(">>> uppertester_vru_codec::decode: decoding_buffer=", data);


  const unsigned char *ptr = static_cast<const unsigned char *>(data);
  const uint8_t *ptr = static_cast<const uint8_t *>(data);
  if (*ptr == uppertester_vru_codec::c_utVamInitializeResult) {
  if (*ptr == uppertester_vru_codec::c_utVamInitializeResult) {
    msg.utVamInitializeResult() = BOOLEAN(*(ptr + 1) == 0x01);
    msg.utVamInitializeResult() = BOOLEAN(*(ptr + 1) == 0x01);
  } else if (*ptr == 0x24) { // TODO Use a constant for "Peer does not support is "Peer does not support the command"
  } else if (*ptr == 0x24) { // TODO Use a constant for "Peer does not support is "Peer does not support the command"
@@ -171,7 +119,7 @@ int uppertester_vru_codec::decode(const OCTETSTRING &data, LibItsVru__TypesAndVa
int uppertester_vru_codec::decode(const OCTETSTRING &data, LibItsVru__TypesAndValues::UtVamEventInd &msg, params_its *params) {
int uppertester_vru_codec::decode(const OCTETSTRING &data, LibItsVru__TypesAndValues::UtVamEventInd &msg, params_its *params) {
  loggers::get_instance().log_to_hexa(">>> uppertester_vru_codec::decode (1): decoding_buffer=", data);
  loggers::get_instance().log_to_hexa(">>> uppertester_vru_codec::decode (1): decoding_buffer=", data);


  const unsigned char *ptr = static_cast<const unsigned char *>(data) + 1;
  const uint8_t *ptr = static_cast<const uint8_t *>(data) + 1;
  OCTETSTRING          os(2, ptr);
  OCTETSTRING          os(2, ptr);
  const unsigned int   length = (const unsigned int)((*ptr << 8 & 0xff00) | *(ptr + 1));
  const unsigned int   length = (const unsigned int)((*ptr << 8 & 0xff00) | *(ptr + 1));
  ptr += 2;
  ptr += 2;
+4 −3
Original line number Original line Diff line number Diff line
@@ -28,9 +28,10 @@ namespace LibItsVru__TypesAndValues {


class uppertester_vru_codec : public codec<Record_Type, Record_Type> {
class uppertester_vru_codec : public codec<Record_Type, Record_Type> {
public:
public:
  static unsigned char c_utVamInitialize;
  static uint8_t c_utVamInitialize;
  static unsigned char c_utVamInitializeResult;
  static uint8_t c_utVamInitializeResult;
  static unsigned char c_utVamEventInd;
  static uint8_t c_utVamSetProfile;
  static uint8_t c_utVamEventInd;


private:
private:
  int encode_(const Base_Type &type, const TTCN_Typedescriptor_t &field_descriptor, TTCN_Buffer &encoding_buffer);
  int encode_(const Base_Type &type, const TTCN_Typedescriptor_t &field_descriptor, TTCN_Buffer &encoding_buffer);
Loading