Esempio n. 1
0
std::string filename_formatter(
  const std::string& format,
  FilenameInfo& info,
  bool replaceFrame)
{
  const std::string& filename = info.filename();
  std::string path = base::get_file_path(filename);
  if (path.empty())
    path = ".";

  std::string output = format;
  base::replace_string(output, "{fullname}", filename);
  base::replace_string(output, "{path}", path);
  base::replace_string(output, "{name}", base::get_file_name(filename));
  base::replace_string(output, "{title}", base::get_file_title(filename));
  base::replace_string(output, "{extension}", base::get_file_extension(filename));
  base::replace_string(output, "{layer}", info.layerName());

  if (replaceFrame) {
    base::replace_string(output, "{tag}", info.innerTagName());
    base::replace_string(output, "{innertag}", info.innerTagName());
    base::replace_string(output, "{outertag}", info.outerTagName());
    replace_frame("{frame", info.frame(), output);
    replace_frame("{tagframe", info.tagFrame(), output);
  }

  return output;
}
int clock_domain_descriptor_imp::proc_get_counters_resp(void *& notification_id, const uint8_t * frame, size_t frame_len, int & status)
{
    struct jdksavdecc_frame cmd_frame;
    struct jdksavdecc_aem_command_get_counters_response clock_domain_counters_resp;
    ssize_t aem_cmd_get_counters_resp_returned;
    uint32_t msg_type;
    bool u_field;

    memcpy(cmd_frame.payload, frame, frame_len);
    memset(&clock_domain_counters_resp, 0, sizeof(jdksavdecc_aem_command_get_counters_response));

    aem_cmd_get_counters_resp_returned = jdksavdecc_aem_command_get_counters_response_read(&clock_domain_counters_resp,
                                                                                           frame,
                                                                                           ETHER_HDR_SIZE,
                                                                                           frame_len);
    if (aem_cmd_get_counters_resp_returned < 0)
    {
        log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "aem_cmd_get_clock_domain_counters_resp_read error\n");
        assert(aem_cmd_get_counters_resp_returned >= 0);
        return -1;
    }

    replace_frame(frame, ETHER_HDR_SIZE, frame_len);

    msg_type = clock_domain_counters_resp.aem_header.aecpdu_header.header.message_type;
    status = clock_domain_counters_resp.aem_header.aecpdu_header.header.status;
    u_field = clock_domain_counters_resp.aem_header.command_type >> 15 & 0x01; // u_field = the msb of the uint16_t command_type

    aecp_controller_state_machine_ref->update_inflight_for_rcvd_resp(notification_id, msg_type, u_field, &cmd_frame);

    return 0;
}
int stream_input_descriptor_imp::proc_get_rx_state_resp(void *& notification_id, const uint8_t * frame, size_t frame_len, int & status)
{
    struct jdksavdecc_frame cmd_frame;
    struct jdksavdecc_acmpdu acmp_cmd_get_rx_state_resp; // Store the response received after sending a GET_RX_STATE command.
    ssize_t acmp_cmd_get_rx_state_resp_returned;

    memcpy(cmd_frame.payload, frame, frame_len);
    acmp_cmd_get_rx_state_resp_returned = jdksavdecc_acmpdu_read(&acmp_cmd_get_rx_state_resp,
                                                                 frame,
                                                                 ETHER_HDR_SIZE,
                                                                 frame_len);

    if (acmp_cmd_get_rx_state_resp_returned < 0)
    {
        log_imp_ref->post_log_msg(LOGGING_LEVEL_ERROR, "acmp_cmd_get_rx_state_read error");
        assert(acmp_cmd_get_rx_state_resp_returned >= 0);
        return -1;
    }

    replace_frame(frame, ETHER_HDR_SIZE, frame_len);

    status = acmp_cmd_get_rx_state_resp.header.status;

    acmp_controller_state_machine_ref->state_resp(notification_id, &cmd_frame);

    return 0;
}