1 //
2 // Copyright 2023 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15
16 #include "host/commands/run_cvd/launch/launch.h"
17
18 #include <string>
19 #include <unordered_set>
20 #include <utility>
21 #include <vector>
22
23 #include <fruit/fruit.h>
24
25 #include "common/libs/utils/result.h"
26 #include "host/libs/config/command_source.h"
27 #include "host/libs/config/known_paths.h"
28
29 constexpr const size_t kBufferSize = 1024;
30
31 namespace cuttlefish {
32
NfcConnector(const CuttlefishConfig & config,const CuttlefishConfig::InstanceSpecific & instance)33 Result<MonitorCommand> NfcConnector(
34 const CuttlefishConfig& config,
35 const CuttlefishConfig::InstanceSpecific& instance) {
36 std::vector<std::string> fifo_paths = {
37 instance.PerInstanceInternalPath("nfc_fifo_vm.in"),
38 instance.PerInstanceInternalPath("nfc_fifo_vm.out"),
39 };
40 std::vector<SharedFD> fifos;
41 for (const auto& path : fifo_paths) {
42 fifos.emplace_back(CF_EXPECT(SharedFD::Fifo(path, 0660)));
43 }
44 return Command(TcpConnectorBinary())
45 .AddParameter("-fifo_out=", fifos[0])
46 .AddParameter("-fifo_in=", fifos[1])
47 .AddParameter("-data_port=", config.casimir_nci_port())
48 .AddParameter("-buffer_size=", kBufferSize)
49 .AddParameter("-dump_packet_size=", 10);
50 }
51
52 } // namespace cuttlefish
53