Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rtos_mon_arch.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  * Copyright (C) 2016 Michal Podhradsky <michal.podhradsky@aggiemail.usu.edu>
4  *
5  * This file is part of paparazzi
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
29 #include <stdlib.h> /* atof */
30 #include <stdio.h> /* printf, fgets */
31 #include <string.h>
32 
33 void rtos_mon_init_arch(void) {}
34 
35 // Ask for CPU usage of the process
37 {
38  char line[20];
39  FILE *cmd = popen("ps -C simsitl -o %CPU", "r");
40 
41  char *ret;
42  ret = fgets(line, sizeof(line), cmd);
43  ret = fgets(line, sizeof(line), cmd);
44  if (ret != NULL) {
45  double cpu = atof(ret);
46  rtos_mon.cpu_load = (uint8_t)cpu;
47  }
48  pclose(cmd);
49 }
50 
void rtos_mon_init_arch(void)
Definition: rtos_mon_arch.c:39
void rtos_mon_periodic_arch(void)
Definition: rtos_mon_arch.c:46
struct rtos_monitoring rtos_mon
Definition: rtos_mon.c:30
uint8_t cpu_load
global CPU/MCU load in %
Definition: sys_mon_rtos.h:49
unsigned char uint8_t
Definition: types.h:14
System monitoring for RTOS targets return cpu load, average exec time, ...