Go to the documentation of this file.
52 std::cout <<
"Usage\n";
54 std::cout <<
"FirmwareUpdateUtility\n";
56 std::cout <<
"FirmwareUpdateUtility <options>\n";
57 std::cout <<
"-a [address] Ip Address of camera (Default 10.66.171.21)\n";
58 std::cout <<
"-f [filepath] Path of firmware update (Default update.img)\n";
59 std::cout <<
"-v Print verbose file upload status (default false)\n";
60 std::cout <<
"-h Print this menu and exit.\n\n";
67 #define PATH_MAX MAX_PATH
71 int main(
int argc,
char *argv[]) {
73 bool verbose_progress =
false;
74 std::string ipAddress =
"10.66.171.21";
76 bool UpdateComplete =
false;
80 while ((opt =
getopt(argc, argv,
"a:f:vh")) != -1) {
83 ipAddress = std::string(
optarg);
86 filePath = std::string(
optarg);
89 verbose_progress =
true;
100 if (ipAddress.empty()) {
101 std::cerr <<
"Missing IP address\n";
105 if (filePath.empty())
107 std::cerr <<
"Please specify a file path\n";
112 std::cerr <<
"Error: File " << filePath <<
" Does not exist\n";
118 if (i.
Setup(ipAddress.c_str()) < 0) {
119 std::cerr <<
"Error Failed to setup Network\n";
124 std::cerr <<
"Error Failed to bind to camera server\n";
130 if (u.
SendFile(filePath, verbose_progress) < 0) {
131 std::cerr <<
"Error failed to send the file " << filePath <<
" to the camera!\n";
140 ret = u.
Receive((uint8_t *)&UpdateStatus,
sizeof(UpdateStatus), &MsgLen);
148 std::cerr <<
"Error: Failed to get message from camera\n";
153 std::cerr <<
"Error: Connection closed by camera\n";
159 std::cerr <<
"Error: Received an error from Camera\n";
166 std::cout <<
"Notice: Update is complete, camera will power cycle!\n";
169 ret = u.
Send((uint8_t*)&UpdateStatus,
sizeof(UpdateStatus));
176 ret = u.
Send((uint8_t *)&UpdateStatus,
sizeof(UpdateStatus));
179 std::cerr <<
"Error Failed to send ack to camera\n";
193 std::cout <<
"Exit Signal Received Cancelling Update\n";
int SendFile(std::string &FilePath, bool verbose)
int Receive(uint8_t *buf, const size_t len, long int *rxlen)
bool FileExists(const char *FilePath)
int main(int argc, char *argv[])
int getopt(int argc, char **argv, char *opts)
void PrintStatus(StatusMessage s)
int Send(uint8_t *buf, const size_t len)
int Setup(std::string _IpAddress)
static CRL_CONSTEXPR StatusMessage Status_UpdateComplete
static CRL_CONSTEXPR UpdateStatusMessage UpdateStatus_Done
static CRL_CONSTEXPR StatusMessage Status_Error
std::atomic< int > ExitReceived(0)
static CRL_CONSTEXPR UpdateStatusId UpdateStatusId_ACK
static void signal_handler(int signal)
static CRL_CONSTEXPR UpdateStatusMessage UpdateStatus_Ok