Repository navigation
Expand file tree
/
Copy pathcontrol_app_cli.cpp
More file actions
47 lines (43 loc) · 1.65 KB
/
Copy pathcontrol_app_cli.cpp
File metadata and controls
47 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include <iostream>
#include "control.hpp"
#include "score/mw/launch_manager/alive_monitor/details/ipc/socket.hpp"
int main(int argc, char** argv)
{
if (argc <= 1)
{
std::cout << "Usage: " << argv[0] << " MyRunTargetName" << std::endl;
return EXIT_FAILURE;
}
score::mw::lifecycle::internal::saf::ipc::
Socket<static_cast<size_t>(sizeof(RunTargetInfo)), control_socket_capacity>
sm_control_socket{};
if (sm_control_socket.connect(control_socket_path) != score::mw::lifecycle::internal::saf::ipc::ReturnCode::kOk)
{
std::cerr << "Could not connect to control socket" << std::endl;
return EXIT_FAILURE;
}
RunTargetInfo info{};
std::strncpy(info.runTargetName, argv[1], sizeof(info.runTargetName) - 1);
if (score::mw::lifecycle::internal::saf::ipc::ReturnCode::kOk == sm_control_socket.trySend(info))
{
std::cout << "Successfully sent request" << std::endl;
return EXIT_SUCCESS;
}
else
{
std::cerr << "Request could not be sent" << std::endl;
return EXIT_FAILURE;
}
}