Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcgencmd: Add some very basic usage info. Also detect when the videocore returns an error #527

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 0 additions & 44 deletions buildme

This file was deleted.

34 changes: 34 additions & 0 deletions host_applications/linux/apps/gencmd/gencmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.

Copyright (c) 2019 Andrew Pattison
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
Expand Down Expand Up @@ -36,6 +39,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "interface/vmcs_host/vc_vchi_gencmd.h"

void show_usage()
{
printf( "Usage: vcgencmd [-t] [COMMAND]\n" );
printf( "Send a command to the Videocore and print the result.\n\n" );
printf( " -t Time how long the command takes to complete\n");
printf( " commands Display a list of commands\n\n" );
printf( "Exit status:\n" );
printf( " 0 command completed successfully\n" );
printf( " -1 problem with VCHI\n" );
printf( " -2 Videocore returned error\n" );
}

int main( int argc, char **argv )
{
int instNum = 0;
Expand All @@ -50,6 +65,9 @@ int main( int argc, char **argv )
argv++;
argc--;
}
} else {
// no arguments passed, so show basic usage
show_usage();
}

vcos_init();
Expand All @@ -71,6 +89,14 @@ int main( int argc, char **argv )

if (argc > 1)
{
// first check if we were invoked with either -? or --help
// in which case show basic usage and exit
if( ( strcmp( argv[1], "-?" ) == 0) || strcmp( argv[1], "--help" ) == 0 )
{
show_usage();
return(0);
}

int i = 1;
char buffer[ 1024 ];
size_t buffer_offset = 0;
Expand Down Expand Up @@ -130,6 +156,14 @@ int main( int argc, char **argv )
{
printf("%s\n", buffer );
}
if (strncmp( buffer, "error=", 5) == 0 )
{
if ( strcmp( buffer, "error=1 error_msg=\"Command not registered\"" ) == 0 )
{
printf( "Use 'vcgencmd commands' to get a list of commands\n" );
}
return -2;
}
}
}

Expand Down