Skip to content
Snippets Groups Projects
Select Git revision
  • bc56db49fbe5ab0ddd3cd61bbc694f198484c69f
  • master default protected
  • cmp_tool-improvement
  • v0.15
  • v0.14
  • v0.13
  • v0.12
  • v0.11
  • v0.09
  • v0.08
  • v0.07
  • v0.06
  • v0.05
13 results

rdcu_pkt_to_file.c

Blame
  • rdcu_pkt_to_file.c 10.72 KiB
    /**
     * @file   rdcu_pkt_to_file.c
     * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
     * @date   2020
     *
     * @copyright GPLv2
     * This program is free software; you can redistribute it and/or modify it
     * under the terms and conditions of the GNU General Public License,
     * version 2, as published by the Free Software Foundation.
     *
     * This program is distributed in the hope it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * @brief RDCU packets to file library
     *
     * This library provided a rmap_rx and rmap_tx function for the rdcu_rmap
     * library to write generated packets into text files.
     * @warning this part of the software is not intended to run on-board on the ICU.
     */
    
    #include <stdint.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <limits.h>
    #include <errno.h>
    #include <sys/stat.h>
    
    #include <cmp_support.h>
    #include <rdcu_pkt_to_file.h>
    #include <cmp_rdcu.h>
    #include <rdcu_rmap.h>
    #include <rdcu_ctrl.h>
    #include <rdcu_cmd.h>
    #include <cmp_rdcu_testing.h>
    
    
    /* Name of directory were the RMAP packages are stored */
    static char tc_folder_dir[MAX_TC_FOLDER_DIR_LEN] = "TC_FILES";
    
    
    /**
     * @brief set the directory name were the RMAP packages are stored
     *
     * @param dir_name	Name of directory were the RMAP packages are stored
     */
    
    void set_tc_folder_dir(const char *dir_name)
    {
    	if (!dir_name)
    		return;
    
    	strncpy(tc_folder_dir, dir_name, sizeof(tc_folder_dir));
    	/*  Ensure null-termination. */
    	tc_folder_dir[sizeof(tc_folder_dir) - 1] = '\0';
    }
    
    
    /**
     * @brief return a file to write with the name format dir_name/XXX.tc, where XXX
     *	is n_tc in decimal representation
     *
     * @param dir_name	name of directory were the RMAP packages are stored
     * @param n_tc		number of TC commands
     *
     * @return	pointer to the new file stream
     * @see https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/
     */