|
RTC Toolkit 5.1.0
|
MUDPI Publisher. More...
#include "math.h"#include "rtms.h"#include <inetcsum/inetcsum.hpp>#include <llnetio/mudpi/mudpi.hpp>#include <iostream>#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 <arpa/inet.h>#include <fcntl.h>#include <sys/mman.h>#include <sys/shm.h>#include <sys/stat.h>Macros | |
| #define | IFNAMSIZ 16 |
| #define | LINESIZE 1024 * 500 |
Typedefs | |
| using | MudpiHeader = llnetio::mudpi::Header |
| using | MudpiTrailer = llnetio::mudpi::Trailer |
Functions | |
| void | Error (const char *msg) |
| void | SigInt (int sig) |
| int | BindSrc (int sockfd, const char *if_name) |
| int | ParseArgs (int argc, char **argv, char *&hostname, int &portno, char *&multicast_group, 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, int &sample_id_increment) |
| void | FillSample (int sample_payload_floats, std::uint32_t sample_id) |
| void | ReadSamples (const 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. | |
Variables | |
| int | time_to_die = 0 |
| std::vector< std::vector< float > > | samples_vector |
| int | shm_fd |
| int * | shm_ptr |
MUDPI Publisher.
| #define IFNAMSIZ 16 |
| #define LINESIZE 1024 * 500 |
| using MudpiHeader = llnetio::mudpi::Header |
| using MudpiTrailer = llnetio::mudpi::Trailer |
| int BindSrc | ( | int | sockfd, |
| const char * | if_name ) |
| void CreateShm | ( | ) |
we want the shm to be writeable by all so disable the umask
open or create
| void Error | ( | const char * | msg | ) |
| void FillSample | ( | int | sample_payload_floats, |
| std::uint32_t | 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
| int main | ( | int | argc, |
| char ** | argv ) |
Application entrypoint.
Announce the amount of data we are sending
Either read sample values from a file or generate a ramp if no file is given
Fill in some fixed values for MUDPI constant fields
Create the shm seg where we coordinate instances
terminate on signal
If waiting for a trigger process, them wait, otherwise signal
If the rollingRamp flag is set then update the ramp for this sample_id if not coming from a file
Fill in some of the more interesting MUDPI fields
fill in this frame of data from the relevant part of the sample
move to the next sample and wrap around if needed
| int ParseArgs | ( | int | argc, |
| char ** | argv, | ||
| char *& | hostname, | ||
| int & | portno, | ||
| char *& | multicast_group, | ||
| 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, | ||
| int & | sample_id_increment ) |
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 | ( | const 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
| void RemoveShm | ( | ) |
| void SigInt | ( | int | sig | ) |
| void SignalShm | ( | int | value | ) |
Just write the value into the shm after checking the segment is good
| void WaitShm | ( | int | value | ) |
Wait for a value(sample_id) to be present in the shm or bail out if we get a signal
| std::vector<std::vector<float> > samples_vector |
| int shm_fd |
| int* shm_ptr |
| int time_to_die = 0 |