Skip to content

Commit 3f470f6

Browse files
Proposal to remove --app-pid and --app-pipe-prefix for out of band commands. (project-chip#38778)
* Updated linux apps to read the FIFO without using the app_pid. Now uses a value from a env variable or static value. This will be usefull on tests to use only -app_pipe <app_prefix>+ instead of two paramters. * Update write_to_app_pipe to only use app_pipe argument which is the full path to pipe file <prefix>_<id>, raises FileNotFound error if the pipe file is not found from start. Removed arguments app_pid and app_pipe_prefix as they are not needed anymore. * Removed arguments --app-pid and --app-pipe-prefix * Updated app-pipe_prefix to app-pipe with APP_ID in test cases * Updated OPSTATE testcases and OVENOPSTATE test cases to use --app-pippe with id instead of PID of the app. * Fix not found when the parameter is not available * Removed unused ci actions * Added APP_IDs for workflows. Currently those are static values for CI. * Remove automatically appended --app-pid on execution. Now it dependes on the CI parameters provided by the user. * Fix typo and restyle * Restyled by whitespace * Restyled by clang-format * fix: Solved typo for TC_RVCRUM_2_1. Added quotes for APP_ID. * fix: Fixed id for bridge app. Added --app-pipe for BRBINFO. Added missing app-pipe for TC_SWITCH * Typo in variable name * Typo RCV_CHIP * Missing file exists check when the app_pipe is send from the test case. * fix: code review fix, optimize for string. * Removed vars from yaml file * Removed APP_ID from Test case CI arguments from --app-pipe * Removed env variable for custom app-id. Replaced for app argument --app-id * Restyled by whitespace * Restore change. * fix: Fixed from comments, app_id set to empty string instead of nullptr, this will avoid uneeded check on each of the apps. * fix: removed comma * Added app-pipe from scripts args to app-args if present. This is to avoid having the fifo path in scripts args and app-args and avoid posible run errors. * Added custom fifo path for each one of the test cases. * Removed prefix. Updated app-id to app-pipe. Now app pipe gets the full path of the fifo path. If not defined avoid sChipNamedPipeCommands.Start() * Restyled by clang-format * Updated empty string compare * Added --app-pipe into app-args. Removed auto append --app-pipe this will need repeated value but will not force same fifo and allow more scenarios. * Updated tc_soil_2_2 with new fifo format. --------- Co-authored-by: Restyled.io <[email protected]>
1 parent f18e596 commit 3f470f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+121
-207
lines changed

examples/air-quality-sensor-app/linux/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ using namespace chip::app;
3636
using namespace chip::app::Clusters;
3737

3838
namespace {
39-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_air_quality_fifo_";
4039
NamedPipeCommands sChipNamedPipeCommands;
4140
AirQualitySensorAppAttrUpdateDelegate sAirQualitySensorAppCommandDelegate;
4241
} // namespace
@@ -52,9 +51,9 @@ int main(int argc, char * argv[])
5251
{
5352
VerifyOrDie(ChipLinuxAppInit(argc, argv) == 0);
5453

55-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
54+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
5655

57-
if (sChipNamedPipeCommands.Start(path, &sAirQualitySensorAppCommandDelegate) != CHIP_NO_ERROR)
56+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sAirQualitySensorAppCommandDelegate) != CHIP_NO_ERROR))
5857
{
5958
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
6059
sChipNamedPipeCommands.Stop();

examples/all-clusters-app/linux/main-common.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ using chip::Protocols::InteractionModel::Status;
7878

7979
namespace {
8080

81-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_all_clusters_fifo_";
8281
LowPowerManager sLowPowerManager;
8382
NamedPipeCommands sChipNamedPipeCommands;
8483
AllClustersCommandDelegate sAllClustersCommandDelegate;
@@ -176,9 +175,8 @@ static Identify gIdentify1 = {
176175

177176
void ApplicationInit()
178177
{
179-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
180-
181-
if (sChipNamedPipeCommands.Start(path, &sAllClustersCommandDelegate) != CHIP_NO_ERROR)
178+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
179+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sAllClustersCommandDelegate) != CHIP_NO_ERROR))
182180
{
183181
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
184182
sChipNamedPipeCommands.Stop();

examples/bridge-app/linux/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ std::vector<Action *> gActions;
6868

6969
namespace {
7070

71-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_bridge_fifo_";
7271
NamedPipeCommands sChipNamedPipeCommands;
7372
BridgeCommandDelegate sBridgeCommandDelegate;
7473

@@ -1052,9 +1051,9 @@ void ApplicationInit()
10521051
}
10531052
}
10541053

1055-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
1054+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
10561055

1057-
if (sChipNamedPipeCommands.Start(path, &sBridgeCommandDelegate) != CHIP_NO_ERROR)
1056+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sBridgeCommandDelegate) != CHIP_NO_ERROR))
10581057
{
10591058
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
10601059
sChipNamedPipeCommands.Stop();

examples/lighting-app-data-mode-no-unique-id/linux/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ using namespace chip::app::Clusters;
4242

4343
namespace {
4444

45-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_lighting_fifo_";
4645
NamedPipeCommands sChipNamedPipeCommands;
4746
LightingAppCommandDelegate sLightingAppCommandDelegate;
4847
} // namespace
@@ -78,9 +77,9 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint)
7877

7978
void ApplicationInit()
8079
{
81-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
80+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
8281

83-
if (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR)
82+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR))
8483
{
8584
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
8685
sChipNamedPipeCommands.Stop();

examples/lighting-app/linux/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ using namespace chip::app::Clusters;
4242

4343
namespace {
4444

45-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_lighting_fifo_";
4645
NamedPipeCommands sChipNamedPipeCommands;
4746
LightingAppCommandDelegate sLightingAppCommandDelegate;
4847
} // namespace
@@ -78,9 +77,9 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint)
7877

7978
void ApplicationInit()
8079
{
81-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
80+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
8281

83-
if (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR)
82+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR))
8483
{
8584
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
8685
sChipNamedPipeCommands.Stop();

examples/lock-app/linux/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ using namespace chip::app;
2727

2828
namespace {
2929
// Variables for handling named pipe commands
30-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_lock_app_fifo-";
3130
NamedPipeCommands sChipNamedPipeCommands;
3231
LockAppCommandDelegate sLockAppCommandDelegate;
3332

3433
} // anonymous namespace
3534

3635
void ApplicationInit()
3736
{
38-
auto path = kChipEventFifoPathPrefix + std::to_string(getpid());
39-
if (sChipNamedPipeCommands.Start(path, &sLockAppCommandDelegate) != CHIP_NO_ERROR)
37+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
38+
39+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sLockAppCommandDelegate) != CHIP_NO_ERROR))
4040
{
4141
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
4242
sChipNamedPipeCommands.Stop();

examples/platform/linux/Options.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum
8888
kDeviceOption_PICS,
8989
kDeviceOption_KVS,
9090
kDeviceOption_InterfaceId,
91+
kDeviceOption_AppPipe,
9192
kDeviceOption_Spake2pVerifierBase64,
9293
kDeviceOption_Spake2pSaltBase64,
9394
kDeviceOption_Spake2pIterations,
@@ -190,6 +191,7 @@ OptionDef sDeviceOptionDefs[] = {
190191
{ "PICS", kArgumentRequired, kDeviceOption_PICS },
191192
{ "KVS", kArgumentRequired, kDeviceOption_KVS },
192193
{ "interface-id", kArgumentRequired, kDeviceOption_InterfaceId },
194+
{ "app-pipe", kArgumentRequired, kDeviceOption_AppPipe },
193195
#if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
194196
{ "trace_file", kArgumentRequired, kDeviceOption_TraceFile },
195197
{ "trace_log", kArgumentRequired, kDeviceOption_TraceLog },
@@ -346,6 +348,9 @@ const char * sDeviceOptionHelp =
346348
"\n"
347349
" --interface-id <interface>\n"
348350
" A interface id to advertise on.\n"
351+
"\n"
352+
" --app-pipe <filepath>\n"
353+
" Custom path for the current application to send out of band commands.\n"
349354
#if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
350355
"\n"
351356
" --trace_file <file>\n"
@@ -680,6 +685,10 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier,
680685
LinuxDeviceOptions::GetInstance().KVS = aValue;
681686
break;
682687

688+
case kDeviceOption_AppPipe:
689+
LinuxDeviceOptions::GetInstance().app_pipe = aValue;
690+
break;
691+
683692
case kDeviceOption_InterfaceId:
684693
LinuxDeviceOptions::GetInstance().interfaceId =
685694
Inet::InterfaceId(static_cast<chip::Inet::InterfaceId::PlatformType>(atoi(aValue)));

examples/platform/linux/Options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct LinuxDeviceOptions
7474
const char * command = nullptr;
7575
const char * PICS = nullptr;
7676
const char * KVS = nullptr;
77+
const char * app_pipe = "";
7778
chip::Inet::InterfaceId interfaceId = chip::Inet::InterfaceId::Null();
7879
#if CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
7980
bool traceStreamDecodeEnabled = false;

examples/rvc-app/linux/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ using namespace chip::app;
2828
using namespace chip::app::Clusters;
2929

3030
namespace {
31-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_rvc_fifo_";
3231
NamedPipeCommands sChipNamedPipeCommands;
3332
RvcAppCommandDelegate sRvcAppCommandDelegate;
3433
} // namespace
@@ -37,9 +36,9 @@ RvcDevice * gRvcDevice = nullptr;
3736

3837
void ApplicationInit()
3938
{
40-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
39+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
4140

42-
if (sChipNamedPipeCommands.Start(path, &sRvcAppCommandDelegate) != CHIP_NO_ERROR)
41+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sRvcAppCommandDelegate) != CHIP_NO_ERROR))
4342
{
4443
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
4544
sChipNamedPipeCommands.Stop();

examples/water-leak-detector-app/linux/main.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ using namespace chip::app;
3636
using namespace chip::app::Clusters;
3737

3838
namespace {
39-
constexpr char kChipEventFifoPathPrefix[] = "/tmp/chip_water_leak_detector_fifo_";
4039
NamedPipeCommands sChipNamedPipeCommands;
4140
WaterLeakDetectorAppAttrUpdateDelegate sWaterLeakDetectorAppAttrUpdateDelegate;
4241
} // namespace
@@ -51,10 +50,9 @@ void ApplicationShutdown() {}
5150
int main(int argc, char * argv[])
5251
{
5352
VerifyOrDie(ChipLinuxAppInit(argc, argv) == 0);
53+
std::string path = std::string(LinuxDeviceOptions::GetInstance().app_pipe);
5454

55-
std::string path = kChipEventFifoPathPrefix + std::to_string(getpid());
56-
57-
if (sChipNamedPipeCommands.Start(path, &sWaterLeakDetectorAppAttrUpdateDelegate) != CHIP_NO_ERROR)
55+
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sWaterLeakDetectorAppAttrUpdateDelegate) != CHIP_NO_ERROR))
5856
{
5957
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
6058
sChipNamedPipeCommands.Stop();

0 commit comments

Comments
 (0)