COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
kpc9612p_recv.cpp File Reference
Include dependency graph for kpc9612p_recv.cpp:

Functions

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

Variables

kpc9612p_handle handle
 
char device [35] ="/dev/ttyUSB3"
 
char source [15]
 
char destination [15]
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
38 {
39  int32_t count;
40  uint8_t buf[500];
41  double lmjd, mean;
42  bool waited;
43 
44  int32_t iretn;
45  size_t tcount = 2000;
46 
47  switch (argc)
48  {
49  case 3:
50  tcount = atol(argv[2]);
51  case 2:
52  strcpy(device,argv[1]);
53  case 1:
54  break;
55  default:
56  printf("Usage: kpc9612p_recv [device [tcount]]\n");
57  exit(-1);
58  break;
59  }
60 
61 
62 
63  if ((iretn=kpc9612p_connect(device, &handle, 0x00)) < 0)
64  {
65  printf("Failed to open KPC9612P on %s, error %d\n",device,iretn);
66  exit (-1);
67  }
68 
69  lmjd = currentmjd(0.);
70  count = 0;
71  for (uint16_t i=0; i<tcount; ++i)
72  {
73  waited = false;
74  while ((iretn=kpc9612p_recvframe(&handle)) < 0)
75  {
76  printf("Waiting: %f\r",86400.*(currentmjd(0.)-lmjd));
77  fflush(stdout);
78  waited = true;
79  }
80  if (waited) printf("\n");
81 
82  if ((iretn=kpc9612p_unloadframe(&handle, buf, 500)) >= 0)
83  {
84  ++count;
85  mean = 0.;
86  for (uint16_t j=0; j<handle.frame.size-17; ++j)
87  {
88  mean += handle.frame.part.payload[j];
89  }
90  mean /= handle.frame.size-17;
91  printf("[%f] Received: %u bytes [%f] #%d\n",86400.*(currentmjd(0.)-lmjd),handle.frame.size,mean,count);
92  fflush(stdout);
93  }
94 
95  lmjd = currentmjd(0.);
96  }
97 }
int32_t kpc9612p_connect(char *dev, kpc9612p_handle *handle, uint8_t flag)
Definition: kpc9612p_lib.cpp:78
int i
Definition: rw_test.cpp:37
int count
Definition: rw_test.cpp:36
struct kpc9612p_frame::@12::@14 part
int iretn
Definition: rw_test.cpp:37
kpc9612p_handle handle
Definition: kpc9612p_recv.cpp:33
int32_t kpc9612p_recvframe(kpc9612p_handle *handle)
Definition: kpc9612p_lib.cpp:111
int32_t kpc9612p_unloadframe(kpc9612p_handle *handle, uint8_t *data, uint16_t size)
Definition: kpc9612p_lib.cpp:192
kpc9612p_frame frame
Definition: kpc9612p_lib.h:91
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
char device[35]
Definition: kpc9612p_recv.cpp:34
char buf[128]
Definition: rw_test.cpp:40
uint16_t size
Definition: kpc9612p_lib.h:85

Variable Documentation

char device[35] ="/dev/ttyUSB3"
char source[15]
char destination[15]