Commit 99554e95 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

dvblastctl: Add XML output support for fe_status command.

parent 0c40683f
...@@ -477,6 +477,7 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -477,6 +477,7 @@ int main( int i_argc, char **ppsz_argv )
case RET_FRONTEND_STATUS: case RET_FRONTEND_STATUS:
{ {
int ret = 1;
struct ret_frontend_status *p_ret = struct ret_frontend_status *p_ret =
(struct ret_frontend_status *)&p_buffer[COMM_HEADER_SIZE]; (struct ret_frontend_status *)&p_buffer[COMM_HEADER_SIZE];
if ( i_size != COMM_HEADER_SIZE + sizeof(struct ret_frontend_status) ) if ( i_size != COMM_HEADER_SIZE + sizeof(struct ret_frontend_status) )
...@@ -485,9 +486,15 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -485,9 +486,15 @@ int main( int i_argc, char **ppsz_argv )
exit(255); exit(255);
} }
if ( i_print_type == PRINT_XML )
printf("<FRONTEND>\n");
#define PRINT_TYPE( x ) \ #define PRINT_TYPE( x ) \
do { \ do { \
printf("type: %s\n", STRINGIFY(x) ); \ if ( i_print_type == PRINT_XML ) \
printf( " <TYPE type=\"%s\"/>\n", STRINGIFY(x) ); \
else \
printf( "type: %s\n", STRINGIFY(x) ); \
} while(0) } while(0)
switch ( p_ret->info.type ) switch ( p_ret->info.type )
{ {
...@@ -500,7 +507,12 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -500,7 +507,12 @@ int main( int i_argc, char **ppsz_argv )
#undef PRINT_TYPE #undef PRINT_TYPE
#define PRINT_INFO( x ) \ #define PRINT_INFO( x ) \
printf( STRINGIFY(x) ": %u\n", p_ret->info.x ); do { \
if ( i_print_type == PRINT_XML ) \
printf( " <SETTING %s=\"%u\"/>\n", STRINGIFY(x), p_ret->info.x ); \
else \
printf( "%s: %u\n", STRINGIFY(x), p_ret->info.x ); \
} while(0)
PRINT_INFO( frequency_min ); PRINT_INFO( frequency_min );
PRINT_INFO( frequency_max ); PRINT_INFO( frequency_max );
PRINT_INFO( frequency_stepsize ); PRINT_INFO( frequency_stepsize );
...@@ -511,11 +523,19 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -511,11 +523,19 @@ int main( int i_argc, char **ppsz_argv )
PRINT_INFO( notifier_delay ); PRINT_INFO( notifier_delay );
#undef PRINT_INFO #undef PRINT_INFO
if ( i_print_type == PRINT_TEXT )
printf("\ncapability list:\n"); printf("\ncapability list:\n");
#define PRINT_CAPS( x ) \ #define PRINT_CAPS( x ) \
if ( p_ret->info.caps & (FE_##x) ) \ do { \
printf( STRINGIFY(x) "\n" ); if ( p_ret->info.caps & (FE_##x) ) { \
if ( i_print_type == PRINT_XML ) { \
printf( " <CAPABILITY %s=\"1\"/>\n", STRINGIFY(x) ); \
} else { \
printf( "%s\n", STRINGIFY(x) ); \
} \
} \
} while(0)
PRINT_CAPS( IS_STUPID ); PRINT_CAPS( IS_STUPID );
PRINT_CAPS( CAN_INVERSION_AUTO ); PRINT_CAPS( CAN_INVERSION_AUTO );
PRINT_CAPS( CAN_FEC_1_2 ); PRINT_CAPS( CAN_FEC_1_2 );
...@@ -556,11 +576,19 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -556,11 +576,19 @@ int main( int i_argc, char **ppsz_argv )
#endif #endif
#undef PRINT_CAPS #undef PRINT_CAPS
if ( i_print_type == PRINT_TEXT )
printf("\nstatus:\n"); printf("\nstatus:\n");
#define PRINT_STATUS( x ) \ #define PRINT_STATUS( x ) \
if ( p_ret->i_status & (FE_##x) ) \ do { \
printf( STRINGIFY(x) "\n" ); if ( p_ret->i_status & (FE_##x) ) { \
if ( i_print_type == PRINT_XML ) { \
printf( " <STATUS status=\"%s\"/>\n", STRINGIFY(x) ); \
} else { \
printf( "%s\n", STRINGIFY(x) ); \
} \
} \
} while(0)
PRINT_STATUS( HAS_SIGNAL ); PRINT_STATUS( HAS_SIGNAL );
PRINT_STATUS( HAS_CARRIER ); PRINT_STATUS( HAS_CARRIER );
PRINT_STATUS( HAS_VITERBI ); PRINT_STATUS( HAS_VITERBI );
...@@ -571,13 +599,23 @@ int main( int i_argc, char **ppsz_argv ) ...@@ -571,13 +599,23 @@ int main( int i_argc, char **ppsz_argv )
if ( p_ret->i_status & FE_HAS_LOCK ) if ( p_ret->i_status & FE_HAS_LOCK )
{ {
if ( i_print_type == PRINT_XML )
{
printf(" <VALUE bit_error_rate=\"%d\"/>\n", p_ret->i_ber);
printf(" <VALUE signal_strength=\"%d\"/>\n", p_ret->i_strength);
printf(" <VALUE SNR=\"%d\"/>\n", p_ret->i_snr);
} else {
printf("\nBit error rate: %d\n", p_ret->i_ber); printf("\nBit error rate: %d\n", p_ret->i_ber);
printf("Signal strength: %d\n", p_ret->i_strength); printf("Signal strength: %d\n", p_ret->i_strength);
printf("SNR: %d\n", p_ret->i_snr); printf("SNR: %d\n", p_ret->i_snr);
exit(0); }
ret = 0;
} }
exit(1); if ( i_print_type == PRINT_XML )
printf("</FRONTEND>\n" );
exit(ret);
break; break;
} }
......
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