Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
Pipe.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020, Cascoda Ltd.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef POSIX_APP_CHILICTL_PIPE_PIPE_HPP_
30#define POSIX_APP_CHILICTL_PIPE_PIPE_HPP_
31
32#include <mutex>
33#include <string>
34
35#include "ca821x_error.h"
36
37#include "common/Args.hpp"
38#include "common/Command.hpp"
39#include "common/DeviceList.hpp"
40
41namespace ca {
42
43class Pipe : public Command
44{
45public:
46 Pipe();
47
51 ca_error Process(int argc, const char *argv[]);
52
53private:
54 Args mArgParser;
55 ArgOpt mHelpArg;
56 ArgOpt mSerialArg;
57 ArgOpt mAnyArg;
58 ArgOpt mResetArg;
59 ArgOpt mEnumerateUartDevicesArg;
60 DeviceList mDeviceList;
61 DeviceListFilter mDeviceListFilter;
62 std::mutex mIoMutex;
63
64 ca_error print_help_string(const char *aArg);
65 ca_error set_serialno_filter(const char *aArg);
66
67 static ca_error exchange_callback(const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef);
68 ca_error exchange_callback(const uint8_t *buf, size_t len);
69
70 ca_error run_pipe(const DeviceInfo &di);
71};
72
73} /* namespace ca */
74
75#endif /* POSIX_APP_CHILICTL_PIPE_PIPE_HPP_ */
Global error declarations for use across the Cascoda SDK.
Structure for holding the definition of potential options to pass on the command line.
Definition Args.hpp:45
Class for parsing and handling options passed as command line arguments.
Definition Args.hpp:133
Abstract class for handling command positional arguments, to be implemented by the command classes.
Definition Command.hpp:40
C++ wrapper for the C ca_device_info struct, which owns its own memory.
Definition DeviceInfo.hpp:40
Definition DeviceList.hpp:40
Class to assist in obtaining a list of connected ca821x devices, filtering as required.
Definition DeviceList.hpp:121
Definition Pipe.hpp:44
Pipe()
Definition Pipe.cpp:43
ca_error Process(int argc, const char *argv[])
Run the command, processing the arguments passed in argv.
Definition Pipe.cpp:73
ca_error
Cascoda error type.
Definition ca821x_error.h:51
Definition Args.cpp:34
CA-821x Device reference struct.
Definition ca821x_api.h:123