Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Flash.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_FLASH_FLASH_HPP_
30 #define POSIX_APP_CHILICTL_FLASH_FLASH_HPP_
31 
32 #include <string>
33 
34 #include "ca821x_error.h"
35 
36 #include "common/Args.hpp"
37 #include "common/Command.hpp"
38 #include "common/DeviceList.hpp"
39 #include "Flasher.hpp"
40 
41 namespace ca {
42 
43 class Flash : public Command
44 {
45 public:
46  Flash();
47 
51  ca_error Process(int argc, const char *argv[]);
52 
53 private:
54  Args mArgParser;
55  ArgOpt mHelpArg;
56  ArgOpt mSerialArg;
57  ArgOpt mBatchArg;
58  ArgOpt mAppFileArg;
59  ArgOpt mOtaBootFileArg;
60  ArgOpt mManuDataFileArg;
61  ArgOpt mDfuUpdateArg;
62  ArgOpt mExtFlashUpdateArg;
63  ArgOpt mClearAPROM;
64  ArgOpt mIgnoreVersionArg;
65  ArgOpt mEnumerateUartDevicesArg;
66  DeviceList mDeviceList;
67  DeviceListFilter mDeviceListFilter;
68  std::string mAppFilePath;
69  std::string mOtaBootFilePath;
70  std::string mManuDataFilePath;
71 
72  ca_error flash_process(const DeviceInfo &aDeviceInfo, Flasher::FlashType flashType);
73  ca_error external_flash_process(const DeviceInfo &aDeviceInfo);
74 
75  ca_error print_help_string(const char *aArg);
76  ca_error set_serialno_filter(const char *aArg);
77  ca_error set_application_file(const char *aArg);
78  ca_error set_manufacturer_data_file(const char *aArg);
79  ca_error set_ota_bootloader_file(const char *aArg);
80 };
81 
82 } /* namespace ca */
83 
84 #endif /* POSIX_APP_CHILICTL_FLASH_FLASH_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: Flash.hpp:44
ca_error Process(int argc, const char *argv[])
Run the command, processing the arguments passed in argv.
Definition: Flash.cpp:162
Flash()
Definition: Flash.cpp:100
FlashType
Enumeration of different areas of flash to rewrite.
Definition: Flasher.hpp:46
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
Definition: Args.cpp:34