COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
udp_send.cpp File Reference
#include "agent/agentclass.h"
#include "support/jsondef.h"
#include "support/sliplib.h"
Include dependency graph for udp_send.cpp:

Functions

int main (int argc, char *argv[])
 

Variables

char address [] = "127.0.0.1"
 
uint16_t port = 6868
 
uint16_t bsize = 1500
 
uint16_t delay = 1
 
uint32_t packets = 10000
 
float speed = 281250.
 
double cmjd
 
double mjd
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
45 {
46 
47  int32_t iretn;
48  uint32_t count=0;
49  socket_channel chan;
50  char buf3[10000];
51  int32_t lsleep, lat, lon, alt;
52  uint16_t len3;
53  int32_t hour, min;
54  float sec;
55  double imjd, elapsed;
56 
57 
59  {
60  printf("Unable to open connection to [%s:6101]\n",address);
61  }
62 
63  COSMOS_USLEEP(1*1000000);
64  lat = 3705459;
65  lon = -12083358;
66  alt = 50;
67  imjd = currentmjd(0.);
68 
69  while (true)
70  {
71 
72  count++;
73  mjd = currentmjd(0.);
74  elapsed = 86400. * (mjd - imjd);
75  mjd -= (int)mjd;
76  hour = mjd * 24;
77  min = 1400 * (mjd - hour/24.);
78  sec = 86400 * (mjd - (hour/24. + min/1400.));
79  sprintf(buf3,"%02d%02d%02d%02d %7d %9d %d 1 100 293 293 27 0.09 0.00 1.01\n",hour,min,(int)sec,(int)(100*(sec-(int)sec)),(int)(lat+elapsed*2),(int)(lon+elapsed*1),(int)(alt+elapsed*5));
80  len3 = strlen(buf3);
81 
82  // Send packet
83  sendto(chan.cudp, (const char *)buf3, len3, 0, (struct sockaddr *)&chan.caddr, sizeof(struct sockaddr_in));
84 
85  printf("[%s]\r", buf3);
86  fflush(stdout);
87  lsleep = 1*1000000;
88  COSMOS_USLEEP(lsleep);
89  }
90 
91 }
char address[]
Definition: udp_send.cpp:34
Agent socket using Unicast UDP.
int count
Definition: rw_test.cpp:36
int iretn
Definition: rw_test.cpp:37
#define SOCKET_TALK
Talk followed by optional listen (sendto address)
Definition: socketlib.h:82
int32_t cudp
Definition: socketlib.h:120
Definition: socketlib.h:115
struct sockaddr_in caddr
Definition: socketlib.h:122
#define SOCKET_BLOCKING
Blocking Agent.
Definition: socketlib.h:78
#define AGENTRCVTIMEO
Default AGENT socket RCVTIMEO (100 msec)
Definition: agentclass.h:208
double mjd
Definition: udp_send.cpp:41
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
uint16_t port
Definition: udp_send.cpp:35
int32_t socket_open(socket_channel *channel, NetworkType ntype, const char *address, uint16_t port, uint16_t role, bool blocking, uint32_t usectimeo, uint32_t rcvbuf, uint32_t sndbuf)
Open UDP socket.
Definition: socketlib.cpp:51

Variable Documentation

char address[] = "127.0.0.1"
uint16_t port = 6868
uint16_t bsize = 1500
uint16_t delay = 1
uint32_t packets = 10000
float speed = 281250.
double cmjd
double mjd