Commit 80b4c2c3 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: don't display HAL and PPSI info in wr_mon when they crash

Also support HAL and PPSI restarts in wr_mon.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent a26170b2
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <libwr/shmem.h> #include <libwr/shmem.h>
#include <libwr/hal_shmem.h> #include <libwr/hal_shmem.h>
#include <minipc.h> #include <minipc.h>
#include <signal.h>
#include "term.h" #include "term.h"
...@@ -30,6 +31,7 @@ static struct pp_globals *ppg; ...@@ -30,6 +31,7 @@ static struct pp_globals *ppg;
static struct wr_servo_state_t *ppsi_servo; static struct wr_servo_state_t *ppsi_servo;
static struct wr_servo_state_t ppsi_servo_local; /* local copy of static struct wr_servo_state_t ppsi_servo_local; /* local copy of
servo status */ servo status */
static pid_t ptp_ch_pid; /* pid of ppsi connected via minipc */
static struct hal_temp_sensors *temp_sensors; static struct hal_temp_sensors *temp_sensors;
static struct hal_temp_sensors temp_sensors_local; static struct hal_temp_sensors temp_sensors_local;
...@@ -76,6 +78,22 @@ int read_servo(void){ ...@@ -76,6 +78,22 @@ int read_servo(void){
} }
void ppsi_connect_minipc()
{
if (ptp_ch) {
/* close minipc, if connected before */
minipc_close(ptp_ch);
}
ptp_ch = minipc_client_create("ptpd", 0);
if (!ptp_ch) {
fprintf(stderr, "Can't establish WRIPC connection "
"to the PTP daemon!\n");
exit(-1);
}
/* store pid of ppsi connected via minipc */
ptp_ch_pid = ppsi_head->pid;
}
void init_shm(void) void init_shm(void)
{ {
struct hal_shmem_header *h; struct hal_shmem_header *h;
...@@ -132,13 +150,7 @@ void init_shm(void) ...@@ -132,13 +150,7 @@ void init_shm(void)
exit(-1); exit(-1);
} }
ptp_ch = minipc_client_create("ptpd", 0); ppsi_connect_minipc();
if (!ptp_ch)
{
fprintf(stderr,"Can't establish WRIPC connection "
"to the PTP daemon!\n");
exit(-1);
}
} }
void show_ports(void) void show_ports(void)
...@@ -415,14 +427,35 @@ int track_onoff = 1; ...@@ -415,14 +427,35 @@ int track_onoff = 1;
void show_all() void show_all()
{ {
int hal_alive;
int ppsi_alive;
if (mode == SHOW_GUI) { if (mode == SHOW_GUI) {
term_clear(); term_clear();
term_pcprintf(1, 1, C_BLUE, term_pcprintf(1, 1, C_BLUE,
"WR Switch Sync Monitor v 1.0 [q = quit]"); "WR Switch Sync Monitor v 1.0 [q = quit]\n");
} }
show_ports();
show_servo(); hal_alive = (hal_head->pid && (kill(hal_head->pid, 0) == 0));
show_temperatures(); ppsi_alive = (ppsi_head->pid && (kill(ppsi_head->pid, 0) == 0));
if (hal_alive)
show_ports();
else if (mode == SHOW_GUI)
term_cprintf(C_RED, "\nHAL is dead!\n");
else if (mode == SHOW_STATS)
printf("HAL is dead!\n");
if (ppsi_alive)
show_servo();
else if (mode == SHOW_GUI)
term_cprintf(C_RED, "\nPPSI is dead!\n");
else if (mode == SHOW_STATS)
printf("PPSI is dead!\n");
if (hal_alive)
show_temperatures();
fflush(stdout); fflush(stdout);
} }
...@@ -465,6 +498,11 @@ int main(int argc, char *argv[]) ...@@ -465,6 +498,11 @@ int main(int argc, char *argv[])
if(c=='t') { if(c=='t') {
int rval; int rval;
track_onoff = 1-track_onoff; track_onoff = 1-track_onoff;
if (ptp_ch_pid != ppsi_head->pid) {
/* ppsi was restarted since minipc
* connection, reconnect now */
ppsi_connect_minipc();
}
minipc_call(ptp_ch, 200, &__rpcdef_cmd, minipc_call(ptp_ch, 200, &__rpcdef_cmd,
&rval, PTPDEXP_COMMAND_TRACKING, &rval, PTPDEXP_COMMAND_TRACKING,
track_onoff); track_onoff);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment