mirror of
https://github.com/espressif/openthread.git
synced 2026-10-11 10:17:35 +00:00
[posix-app] add option to print version of radio spinel (#3205)
This commit is contained in:
+8
-11
@@ -60,7 +60,7 @@ void otTaskletsSignalPending(otInstance *aInstance)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
otInstance *sInstance;
|
otInstance *instance;
|
||||||
|
|
||||||
if (setjmp(gResetJump))
|
if (setjmp(gResetJump))
|
||||||
{
|
{
|
||||||
@@ -71,28 +71,25 @@ int main(int argc, char *argv[])
|
|||||||
execvp(argv[0], argv);
|
execvp(argv[0], argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
otSysInit(argc, argv);
|
instance = otSysInit(argc, argv);
|
||||||
|
|
||||||
sInstance = otInstanceInitSingle();
|
|
||||||
assert(sInstance);
|
|
||||||
|
|
||||||
#if OPENTHREAD_POSIX_APP == OPENTHREAD_POSIX_APP_NCP
|
#if OPENTHREAD_POSIX_APP == OPENTHREAD_POSIX_APP_NCP
|
||||||
otNcpInit(sInstance);
|
otNcpInit(instance);
|
||||||
#elif OPENTHREAD_POSIX_APP == OPENTHREAD_POSIX_APP_CLI
|
#elif OPENTHREAD_POSIX_APP == OPENTHREAD_POSIX_APP_CLI
|
||||||
otCliUartInit(sInstance);
|
otCliUartInit(instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OPENTHREAD_ENABLE_DIAG
|
#if OPENTHREAD_ENABLE_DIAG
|
||||||
otDiagInit(sInstance);
|
otDiagInit(instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
otTaskletsProcess(sInstance);
|
otTaskletsProcess(instance);
|
||||||
otSysProcessDrivers(sInstance);
|
otSysProcessDrivers(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
otInstanceFinalize(sInstance);
|
otInstanceFinalize(instance);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ extern "C" {
|
|||||||
* @param[in] argc Number of arguments in @p argv.
|
* @param[in] argc Number of arguments in @p argv.
|
||||||
* @param[in] argv Argument vector.
|
* @param[in] argv Argument vector.
|
||||||
*
|
*
|
||||||
|
* @returns A pointer to the OpenThread instance.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void otSysInit(int argc, char *argv[]);
|
otInstance *otSysInit(int argc, char *argv[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function performs all platform-specific deinitialization for OpenThread's drivers.
|
* This function performs all platform-specific deinitialization for OpenThread's drivers.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#include <openthread/tasklet.h>
|
#include <openthread/tasklet.h>
|
||||||
#include <openthread/platform/alarm-milli.h>
|
#include <openthread/platform/alarm-milli.h>
|
||||||
|
#include <openthread/platform/radio.h>
|
||||||
|
|
||||||
uint64_t gNodeId = 0;
|
uint64_t gNodeId = 0;
|
||||||
|
|
||||||
@@ -55,29 +56,34 @@ static void PrintUsage(const char *aProgramName, FILE *aStream, int aExitCode)
|
|||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" %s [Options] NodeId|Device|Command [DeviceConfig|CommandArgs]\n"
|
" %s [Options] NodeId|Device|Command [DeviceConfig|CommandArgs]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -s --time-speed factor Time speed up factor.\n"
|
|
||||||
" -n --dry-run Just verify if arguments is valid and radio spinel is compatible.\n"
|
" -n --dry-run Just verify if arguments is valid and radio spinel is compatible.\n"
|
||||||
|
" --radio-version Print radio firmware version\n"
|
||||||
|
" -s --time-speed factor Time speed up factor.\n"
|
||||||
" -h --help Display this usage information.\n",
|
" -h --help Display this usage information.\n",
|
||||||
aProgramName);
|
aProgramName);
|
||||||
exit(aExitCode);
|
exit(aExitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void otSysInit(int aArgCount, char *aArgVector[])
|
otInstance *otSysInit(int aArgCount, char *aArgVector[])
|
||||||
{
|
{
|
||||||
uint32_t speedUpFactor = 1;
|
const char *radioFile = NULL;
|
||||||
bool isDryRun = false;
|
const char *radioConfig = "";
|
||||||
const char *radioFile = NULL;
|
otInstance *instance = NULL;
|
||||||
const char *radioConfig = "";
|
uint32_t speedUpFactor = 1;
|
||||||
|
bool isDryRun = false;
|
||||||
|
bool printRadioVersion = false;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
int index = 0;
|
||||||
int option;
|
int option;
|
||||||
const struct option options[] = {{"dry-run", no_argument, NULL, 'n'},
|
const struct option options[] = {{"dry-run", no_argument, NULL, 'n'},
|
||||||
|
{"radio-version", no_argument, NULL, 0},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"time-speed", required_argument, NULL, 's'},
|
{"time-speed", required_argument, NULL, 's'},
|
||||||
{0, 0, 0, 0}};
|
{0, 0, 0, 0}};
|
||||||
|
|
||||||
option = getopt_long(aArgCount, aArgVector, "hns:", options, NULL);
|
option = getopt_long(aArgCount, aArgVector, "hns:", options, &index);
|
||||||
|
|
||||||
if (option == -1)
|
if (option == -1)
|
||||||
{
|
{
|
||||||
@@ -104,6 +110,12 @@ void otSysInit(int aArgCount, char *aArgVector[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0:
|
||||||
|
if (!strcmp(options[index].name, "radio-version"))
|
||||||
|
{
|
||||||
|
printRadioVersion = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
PrintUsage(aArgVector[0], stderr, OT_EXIT_INVALID_ARGUMENTS);
|
PrintUsage(aArgVector[0], stderr, OT_EXIT_INVALID_ARGUMENTS);
|
||||||
break;
|
break;
|
||||||
@@ -136,10 +148,20 @@ void otSysInit(int aArgCount, char *aArgVector[])
|
|||||||
platformUdpInit();
|
platformUdpInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
instance = otInstanceInitSingle();
|
||||||
|
assert(instance);
|
||||||
|
|
||||||
|
if (printRadioVersion)
|
||||||
|
{
|
||||||
|
printf("%s\n", otPlatRadioGetVersionString(instance));
|
||||||
|
}
|
||||||
|
|
||||||
if (isDryRun)
|
if (isDryRun)
|
||||||
{
|
{
|
||||||
exit(OT_EXIT_SUCCESS);
|
exit(OT_EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void otSysDeinit(void)
|
void otSysDeinit(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user