RTC Toolkit
1.0.0
|
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 |
MUDPI Publisher.
#define IFNAMSIZ 16 |
#define LINESIZE 1024*500 |
int bind_src | ( | int | sockfd, |
char const * | ifName | ||
) |
void create_shm | ( | ) |
we want the shm to be writeable by all so disable the umask
open or create
void error | ( | const char * | msg | ) |
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
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
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
void remove_shm | ( | ) |
void sig_int | ( | int | sig | ) |
void signal_shm | ( | int | value | ) |
Just write the value into the shm after checking the segment is good
void wait_shm | ( | int | value | ) |
Wait for a value(sampleId) to be present in the shm or bail out if we get a signal
std::vector<std::vector<float> > samplesVector |
int shm_fd |
int* shm_ptr |
int time_to_die =0 |