From 77c888569359a0b47a160715d4376a4e55a432dd Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 20:11:13 +0000 Subject: [PATCH 1/8] Display basic usage if no arguments are given --- host_applications/linux/apps/gencmd/gencmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index 9b48cf902..77881df0e 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -50,6 +50,15 @@ int main( int argc, char **argv ) argv++; argc--; } + } else { + // no arguments passed, so show basic 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 an error occurred\n" ); } vcos_init(); From d28e7ab59c76535d6649608ab53a3d4b767461a9 Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 20:16:47 +0000 Subject: [PATCH 2/8] Fix indent --- host_applications/linux/apps/gencmd/gencmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index 77881df0e..a9349222b 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -58,7 +58,7 @@ int main( int argc, char **argv ) printf( " commands Display a list of commands\n\n" ); printf( "Exit status:\n" ); printf( " 0 command completed successfully\n" ); - printf( " -1 an error occurred\n" ); + printf( " -1 an error occurred\n" ); } vcos_init(); From b9b2005e887dfd34214583e6733f20ad36339fcc Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 22:29:37 +0000 Subject: [PATCH 3/8] Add -? and --help options to show basic usage --- buildme | 4 +-- host_applications/linux/apps/gencmd/gencmd.c | 29 +++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/buildme b/buildme index b8fd4408e..fadbb1dff 100755 --- a/buildme +++ b/buildme @@ -14,9 +14,9 @@ if [ "armv6l" = `arch` ] || [ "armv7l" = `arch` ]; then pushd build/raspberry/$BUILDSUBDIR cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. if [ "armv6l" = `arch` ]; then - make + make VERBOSE=1 else - make -j4 + make -j4 VERBOSE=1 fi if [ "$1" != "" ]; then sudo make install DESTDIR=$1 diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index a9349222b..a5a612e45 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -36,6 +36,17 @@ 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 an error occurred\n" ); +} + int main( int argc, char **argv ) { int instNum = 0; @@ -52,13 +63,7 @@ int main( int argc, char **argv ) } } else { // no arguments passed, so show basic 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 an error occurred\n" ); + show_usage(); } vcos_init(); @@ -80,6 +85,16 @@ 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; From 58f78b5818e913de6edcfd8f06c272a6eb995597 Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 22:32:43 +0000 Subject: [PATCH 4/8] Add copyright --- host_applications/linux/apps/gencmd/gencmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index a5a612e45..c2d25453e 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -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 @@ -85,8 +88,6 @@ 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 ) From 49a6f36e41b00d42b25dac8ccf0b4c289e273f73 Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 23:16:42 +0000 Subject: [PATCH 5/8] Detect when an unrecognised command is issued and suggest 'vcgencmd commands' --- host_applications/linux/apps/gencmd/gencmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index c2d25453e..80c57e036 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -155,6 +155,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 -1; + } } } From f0fa0dacc85985702dcb4cec26a6820257f0013e Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 23:25:05 +0000 Subject: [PATCH 6/8] Make errors returned by videocore result in return value of -2 --- host_applications/linux/apps/gencmd/gencmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index 80c57e036..8c7e2b147 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -47,7 +47,8 @@ void show_usage() printf( " commands Display a list of commands\n\n" ); printf( "Exit status:\n" ); printf( " 0 command completed successfully\n" ); - printf( " -1 an error occurred\n" ); + printf( " -1 problem with VCHI\n" ); + printf( " -2 videcore returned error" ); } int main( int argc, char **argv ) @@ -161,7 +162,7 @@ int main( int argc, char **argv ) { printf( "Use 'vcgencmd commands' to get a list of commands\n" ); } - return -1; + return -2; } } } From 19d476fd59136914a63d93e89da31e0a0704d5d8 Mon Sep 17 00:00:00 2001 From: andrum99 Date: Tue, 15 Jan 2019 23:27:49 +0000 Subject: [PATCH 7/8] Fix typo --- host_applications/linux/apps/gencmd/gencmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host_applications/linux/apps/gencmd/gencmd.c b/host_applications/linux/apps/gencmd/gencmd.c index 8c7e2b147..4227bfd5b 100644 --- a/host_applications/linux/apps/gencmd/gencmd.c +++ b/host_applications/linux/apps/gencmd/gencmd.c @@ -48,7 +48,7 @@ void show_usage() printf( "Exit status:\n" ); printf( " 0 command completed successfully\n" ); printf( " -1 problem with VCHI\n" ); - printf( " -2 videcore returned error" ); + printf( " -2 Videocore returned error\n" ); } int main( int argc, char **argv ) From 6d4df45878cd40ab34a9e9788a9f9524ed5ff957 Mon Sep 17 00:00:00 2001 From: andrum99 <31110555+andrum99@users.noreply.github.com> Date: Tue, 15 Jan 2019 23:29:07 +0000 Subject: [PATCH 8/8] Don't include my changes to buildme in this pull request --- buildme | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100755 buildme diff --git a/buildme b/buildme deleted file mode 100755 index fadbb1dff..000000000 --- a/buildme +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -BUILDTYPE=Release - -if [ "$1" = "--debug" ]; then - BUILDTYPE=Debug - shift -fi - -BUILDSUBDIR=`echo $BUILDTYPE | tr '[A-Z]' '[a-z]'`; - -if [ "armv6l" = `arch` ] || [ "armv7l" = `arch` ]; then - # Native compile on the Raspberry Pi - mkdir -p build/raspberry/$BUILDSUBDIR - pushd build/raspberry/$BUILDSUBDIR - cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - if [ "armv6l" = `arch` ]; then - make VERBOSE=1 - else - make -j4 VERBOSE=1 - fi - if [ "$1" != "" ]; then - sudo make install DESTDIR=$1 - else - sudo make install - fi -elif [ "$1" = "--native" ]; then - # Build natively on the host - mkdir -p build/native/$BUILDSUBDIR - pushd build/native/$BUILDSUBDIR - cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - shift - make -j `nproc` $* -else - # Cross compile on a more capable machine - mkdir -p build/arm-linux/$BUILDSUBDIR - pushd build/arm-linux/$BUILDSUBDIR - cmake -DCMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../.. - make -j `nproc` - - if [ "$1" != "" ]; then - sudo make install DESTDIR=$1 - fi -fi -popd