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

MUDPI Publisher. More...

#include "math.h"
#include "mudpi.h"
#include "rtms.h"
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <vector>
#include <iostream>
#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 SigInt (int sig)
 
int BindSrc (int sockfd, char const *if_name)
 
int ParseArgs (int argc, char **argv, char *&hostname, int &portno, int &topic_id, int &n_frames_per_sample, long &delay_us, char *&data_file, int &buf_size, bool &wait_trigger, bool &rolling_ramp, int &sample_size, int &limit, int &rtms)
 
void FillSample (int sample_payload_floats, int sample_id)
 
void ReadSamples (char *filename, int sample_payload_floats)
 
void CreateShm ()
 
void RemoveShm ()
 
void SignalShm (int value)
 
void WaitShm (int value)
 
int main (int argc, char **argv)
 Application entrypoint. More...
 

Variables

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

Detailed Description

MUDPI Publisher.

Macro Definition Documentation

◆ IFNAMSIZ

#define IFNAMSIZ   16

◆ LINESIZE

#define LINESIZE   1024 * 500

Function Documentation

◆ BindSrc()

int BindSrc ( int  sockfd,
char const *  if_name 
)

◆ CreateShm()

void CreateShm ( )

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  sample_payload_floats,
int  sample_id 
)

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

◆ ParseArgs()

int ParseArgs ( int  argc,
char **  argv,
char *&  hostname,
int &  portno,
int &  topic_id,
int &  n_frames_per_sample,
long &  delay_us,
char *&  data_file,
int &  buf_size,
bool &  wait_trigger,
bool &  rolling_ramp,
int &  sample_size,
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  sample_payload_floats 
)

Read one line at a time with a big LINESIZE

Space separated floats up to the maximum allowed

Add to the vector of samples

◆ RemoveShm()

void RemoveShm ( )

◆ SigInt()

void SigInt ( int  sig)

◆ SignalShm()

void SignalShm ( int  value)

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

◆ WaitShm()

void WaitShm ( int  value)

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

Variable Documentation

◆ samples_vector

std::vector<std::vector<float> > samples_vector

◆ shm_fd

int shm_fd

◆ shm_ptr

int* shm_ptr

◆ time_to_die

int time_to_die = 0