RTC Toolkit  1.0.0
Macros | Functions | Variables
main.cpp File Reference

MUDPI Publisher. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include "mudpi.h"
#include "rtms.h"
#include "math.h"
#include <vector>
#include <sstream>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/stat.h>

Macros

#define IFNAMSIZ   16
 
#define LINESIZE   1024*500
 

Functions

void error (const char *msg)
 
void sig_int (int sig)
 
int bind_src (int sockfd, char const *ifName)
 
int parse_args (int argc, char **argv, char *&hostname, int &portno, int &topicId, int &nFramesPerSample, long &delayUs, char *&data_file, int &bufSize, bool &waitTrigger, bool &rollingRamp, int &sampleSize, int &limit, int &rtms)
 
void fillSample (int samplePayloadFloats, int sampleId)
 
void readSamples (char *filename, int samplePayloadFloats)
 
void create_shm ()
 
void remove_shm ()
 
void signal_shm (int value)
 
void wait_shm (int value)
 
int main (int argc, char **argv)
 Application entrypoint. More...
 

Variables

int time_to_die =0
 
std::vector< std::vector< float > > samplesVector
 
int shm_fd
 
int * shm_ptr
 

Detailed Description

MUDPI Publisher.

Macro Definition Documentation

◆ IFNAMSIZ

#define IFNAMSIZ   16

◆ LINESIZE

#define LINESIZE   1024*500

Function Documentation

◆ bind_src()

int bind_src ( int  sockfd,
char const *  ifName 
)

◆ create_shm()

void create_shm ( )

we want the shm to be writeable by all so disable the umask

open or create

◆ error()

void error ( const char *  msg)

◆ fillSample()

void fillSample ( int  samplePayloadFloats,
int  sampleId 
)

If we just ramp forever with increasing sample Id we will run out of numerical precision so when we get to 1000 increments start again

◆ parse_args()

int parse_args ( int  argc,
char **  argv,
char *&  hostname,
int &  portno,
int &  topicId,
int &  nFramesPerSample,
long &  delayUs,
char *&  data_file,
int &  bufSize,
bool &  waitTrigger,
bool &  rollingRamp,
int &  sampleSize,
int &  limit,
int &  rtms 
)

If the sample size is set, we need to work out how many frames of buffsize we need to transport the sample

For some reason the way I would have done this in the past does not seem to work with the implementation of round on eltrtctk40 which "rounds away from 0" so that round 2.5 is 3 not 2 so the first check catches the case where sampleSize is a multiple of payloadsize

If the sample size is not set, then it's just nframes * payload

◆ readSamples()

void readSamples ( char *  filename,
int  samplePayloadFloats 
)

Read one line at a time with a big LINESIZE

Space separated floats up to the maximum allowed

Add to the vector of samples

◆ remove_shm()

void remove_shm ( )

◆ sig_int()

void sig_int ( int  sig)

◆ signal_shm()

void signal_shm ( int  value)

Just write the value into the shm after checking the segment is good

◆ wait_shm()

void wait_shm ( int  value)

Wait for a value(sampleId) to be present in the shm or bail out if we get a signal

Variable Documentation

◆ samplesVector

std::vector<std::vector<float> > samplesVector

◆ shm_fd

int shm_fd

◆ shm_ptr

int* shm_ptr

◆ time_to_die

int time_to_die =0