mirror of
https://github.com/espressif/openthread.git
synced 2026-08-15 15:17:46 +00:00
[diag] implement diag stream command (#8975)
- Add `expect` simulation test. - Update the diag/README.md
This commit is contained in:
@@ -168,4 +168,12 @@ otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aEnable);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (312)
|
||||
#define OPENTHREAD_API_VERSION (313)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -260,6 +260,19 @@ otError otPlatDiagRadioRawPowerSettingEnable(otInstance *aInstance, bool aEnable
|
||||
*/
|
||||
otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Start/stop the platform layer to transmit stream of characters.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aEnable TRUE to enable or FALSE to disable the platform layer to transmit stream.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully enabled/disabled.
|
||||
* @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
|
||||
* @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented.
|
||||
*
|
||||
*/
|
||||
otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable);
|
||||
|
||||
/**
|
||||
* Get the power settings for the given channel.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ The diagnostics module supports common diagnostics features that are listed belo
|
||||
- [diag start](#diag-start)
|
||||
- [diag channel](#diag-channel)
|
||||
- [diag cw](#diag-cw-start)
|
||||
- [diag stream](#diag-stream-start)
|
||||
- [diag power](#diag-power)
|
||||
- [diag powersettings](#diag-powersettings)
|
||||
- [diag send](#diag-send-packets-length)
|
||||
@@ -76,6 +77,24 @@ Stop transmitting continuous carrier wave.
|
||||
Done
|
||||
```
|
||||
|
||||
### diag stream start
|
||||
|
||||
Start transmitting a stream of characters.
|
||||
|
||||
```bash
|
||||
> diag stream start
|
||||
Done
|
||||
```
|
||||
|
||||
### diag stream stop
|
||||
|
||||
Stop transmitting a stream of characters.
|
||||
|
||||
```bash
|
||||
> diag stream stop
|
||||
Done
|
||||
```
|
||||
|
||||
### diag power
|
||||
|
||||
Get the tx power value(dBm) for diagnostics module.
|
||||
|
||||
@@ -79,6 +79,7 @@ const struct Diags::Command Diags::sCommands[] = {
|
||||
{"rawpowersetting", &Diags::ProcessRawPowerSetting},
|
||||
{"start", &Diags::ProcessStart},
|
||||
{"stop", &Diags::ProcessStop},
|
||||
{"stream", &Diags::ProcessStream},
|
||||
};
|
||||
|
||||
Diags::Diags(Instance &aInstance)
|
||||
@@ -196,6 +197,7 @@ const struct Diags::Command Diags::sCommands[] = {
|
||||
{"start", &Diags::ProcessStart},
|
||||
{"stats", &Diags::ProcessStats},
|
||||
{"stop", &Diags::ProcessStop},
|
||||
{"stream", &Diags::ProcessStream},
|
||||
};
|
||||
|
||||
Diags::Diags(Instance &aInstance)
|
||||
@@ -573,6 +575,27 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Diags::ProcessStream(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
Error error = kErrorInvalidArgs;
|
||||
|
||||
VerifyOrExit(otPlatDiagModeGet(), error = kErrorInvalidState);
|
||||
VerifyOrExit(aArgsLength > 0, error = kErrorInvalidArgs);
|
||||
|
||||
if (strcmp(aArgs[0], "start") == 0)
|
||||
{
|
||||
error = otPlatDiagRadioTransmitStream(&GetInstance(), true);
|
||||
}
|
||||
else if (strcmp(aArgs[0], "stop") == 0)
|
||||
{
|
||||
error = otPlatDiagRadioTransmitStream(&GetInstance(), false);
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendErrorResult(error, aOutput, aOutputMaxLen);
|
||||
return error;
|
||||
}
|
||||
|
||||
Error Diags::GetPowerSettings(uint8_t aChannel, PowerSettings &aPowerSettings)
|
||||
{
|
||||
aPowerSettings.mRawPowerSetting.mLength = RawPowerSetting::kMaxDataSize;
|
||||
@@ -939,6 +962,14 @@ OT_TOOL_WEAK otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aEnable);
|
||||
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK otError otPlatDiagRadioGetPowerSettings(otInstance *aInstance,
|
||||
uint8_t aChannel,
|
||||
int16_t *aTargetPower,
|
||||
|
||||
@@ -193,6 +193,7 @@ private:
|
||||
Error ProcessStart(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
|
||||
Error ProcessStats(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
|
||||
Error ProcessStop(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
|
||||
Error ProcessStream(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
|
||||
#if OPENTHREAD_RADIO && !OPENTHREAD_RADIO_CLI
|
||||
Error ProcessEcho(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen);
|
||||
#endif
|
||||
|
||||
@@ -735,6 +735,16 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
char cmd[OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "stream %s", aEnable ? "start" : "stop");
|
||||
return sRadioSpinel.PlatDiagProcess(cmd, nullptr, 0);
|
||||
}
|
||||
|
||||
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
@@ -181,6 +181,12 @@ expect_line "Done"
|
||||
send "diag cw stop\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stream start\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag stream stop\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "diag rawpowersetting 112233\n"
|
||||
expect_line "Done"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user