#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/timeb.h>
#include <string.h>
#ifdef __linux__
#include <unistd.h>
#else
#include <windows.h>
#endif
unsigned int message_mask;
{
if (mess_struct_ptr->
category & message_mask)
{
}
}
void DeviceData(const char *device_key,
int packet_length,
unsigned char *packet_buffer_ptr)
{
unsigned int count;
for (count = 0; count*
sizeof(
cfdp_struct_type) < (
unsigned int)packet_length; count++)
{
{
printf("Progress Transaction_id %s -> %s\t file size=%lld\t bytes trans=%lld\t percent trans=%u%%\n",
}
{
{
printf("Error Failed to remove the file: %s.\n",
}
}
}
}
int CreateDataFile(char *pathname,
unsigned int file_size)
{
FILE *file_ptr = NULL;
char fill_data[250];
unsigned int i;
if ((file_ptr = fopen(pathname,"wb")) == NULL)
{
printf("Error Failed to open example data file.\n");
}
memset(fill_data,0xfe,sizeof(fill_data));
for (i = 0; i < file_size; i+=sizeof(fill_data))
fwrite(fill_data,1,sizeof(fill_data),file_ptr);
fflush(file_ptr);
fclose(file_ptr);
}
int InitExampleDataFiles(char *pathname1MB,
char *destination_pathname1MB,
char *pathname2MB,
char *destination_pathname2MB,
char *pathname3MB,
char *destination_pathname3MB)
{
struct timeb timebuffer;
char home_path[256];
{
}
sprintf(pathname1MB, "%s/put_example_2_data_file_1MB",home_path);
if (CreateDataFile(pathname1MB,1000000) ==
FAIL)
{
}
ftime(&timebuffer);
sprintf(destination_pathname1MB,"%s_%u",
pathname1MB,
(unsigned int)timebuffer.time);
sprintf(pathname2MB, "%s/put_example_2_data_file_2MB",home_path);
if (CreateDataFile(pathname2MB,2000000) ==
FAIL)
{
}
sprintf(destination_pathname2MB,"%s_%u",
pathname2MB,
(unsigned int)timebuffer.time);
sprintf(pathname3MB, "%s/put_example_2_data_file_3MB",home_path);
if (CreateDataFile(pathname3MB,3000000) ==
FAIL)
{
}
sprintf(destination_pathname3MB,"%s_%u",
pathname3MB,
(unsigned int)timebuffer.time);
}
int main(int argc, char *argv[])
{
int return_value;
char pathname[256];
char pathname1MB[256];
char destination_pathname1MB[256];
char pathname2MB[256];
char destination_pathname2MB[256];
char pathname3MB[256];
char destination_pathname3MB[256];
long long eid;
unsigned int transaction_count;
unsigned int timeout_in_sec;
unsigned int i;
char log_path[256];
char log_filename[256];
strcpy (pathname, "./cfdp_put_example_2_config.txt");
if (argc == 2)
{
strcpy(pathname,argv[1]);
}
else if (argc > 2)
{
printf("Error Command line contains too many arguments.\n");
return 0;
}
strcpy(log_path,"");
strcpy(log_filename,"cfdp_put_example_2_log_file");
log_filename,
{
strcpy(log_path,"");
strcpy(log_filename,"cfdp_put_example_2_metrics_file");
{
printf("Error Failed to GetDisplayMessageMask.\n");
}
{
printf("Error Failed to RegisterCFDPDeviceData.\n");
}
if (InitExampleDataFiles(pathname1MB,
destination_pathname1MB,
pathname2MB,
destination_pathname2MB,
pathname3MB,
destination_pathname3MB) !=
SUCCESS)
{
printf("Error Failed to InitExampleDataFiles.\n");
return 0;
}
eid = 100;
printf("\nPut Example 2\n\n");
destination_pathname1MB,
eid,
{
printf("Error Failed to AddPutComponentRequest.\n");
remove(pathname1MB);
remove(pathname2MB);
remove(pathname3MB);
return 0;
}
destination_pathname2MB,
eid,
{
printf("Error Failed to AddPutComponentRequest.\n");
return 0;
}
destination_pathname3MB,
eid,
{
printf("Error Failed to AddPutComponentRequest.\n");
remove(pathname1MB);
remove(pathname2MB);
remove(pathname3MB);
return 0;
}
{
printf("Error Failed to SendAllPutRequests.\n");
remove(pathname1MB);
remove(pathname2MB);
remove(pathname3MB);
return 0;
}
timeout_in_sec = 60;
transaction_count = 3;
&transaction_count,
&cfdp_struct_array_ptr);
{
for (i=0; i<transaction_count;i++)
{
if (cfdp_struct_array_ptr[i].cfdp_status ==
DS_SUCCESS)
{
cfdp_struct_array_ptr[i].destination_pathname,
cfdp_struct_array_ptr[i].eid);
}
else
{
printf("Info Failed to execute put file for destination pathname: %s and eid: %d.\n",
cfdp_struct_array_ptr[i].destination_pathname,
(int)cfdp_struct_array_ptr[i].eid);
}
}
}
else
{
printf("Error Failed to MonitorAllCFDPTransactions.\n");
}
}
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
return 0;
}
CFDP toolkit enumerations.
@ CFDP_CLASS_2
CFDP class 2 service.
Definition: cfdp_shared.h:23
Message codes and structure definition for the Device Service library.
#define DS_SUCCESS
40 DS message code for Success
Definition: ds_shared.h:65
@ FALSE_OR_NO
False.
Definition: ds_shared.h:105
Structure of parameters needed for CFDP transaction status.
Definition: ds_shared.h:145
char destination_pathname[256]
Destination path and filename.
Definition: ds_shared.h:147
unsigned long cfdp_status
(e.g., DS_PACKET_SENDING, DS_PACKET_RECEIVING, DS_SUSPEND, DS_RESUME, DS_CANCEL, DS_SUCCESS,...
Definition: ds_shared.h:164
unsigned short percent_transferred
Bytes transferred divided by file size. Will reset with packet/PDU retransmissions.
Definition: ds_shared.h:150
long long bytes_transferred
The current number of bytes transmitted or received.
Definition: ds_shared.h:151
char transaction_id[50]
The transaction ID string is a combination of the decimal dotted notation EID (NATIVE) or decimal EID...
Definition: ds_shared.h:149
char source_pathname[256]
Source path and filename.
Definition: ds_shared.h:146
long long file_size
The size of the file being transferred.
Definition: ds_shared.h:152
Structure of parameters needed for message support.
Definition: trek_toolkit_common_api_ansi_c.h:74
char message[MAX_MESSAGE_SIZE]
Message.
Definition: trek_toolkit_common_api_ansi_c.h:77
enum message_category category
Message category (e.g., MSG_CAT_ERROR, MSG_CAT_ERROR_ALERT, MSG_CAT_WARNING, MSG_CAT_WARNING_ALERT,...
Definition: trek_toolkit_common_api_ansi_c.h:76
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8
#define FAIL
The function failed for an unknown reason.
Definition: trek_error.h:9