author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 13 Nov 2024 23:10:36 +0100 | |
changeset 4037 | 4127c64df073 |
parent 3957 | 2510c1f935d1 |
permissions | -rw-r--r-- |
3940
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
1 |
/* |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
2 |
* Beremiz C++ runtime |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
3 |
* |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
4 |
* This file implements Beremiz C++ runtime Command Line Interface for POSIX |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
5 |
* |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
6 |
* Based on erpcsniffer.cpp, BSD-3-Clause, Copyright 2017 NXP |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
7 |
* |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
8 |
* Copyright 2024 Beremiz SAS |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
9 |
* |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
10 |
* See COPYING for licensing details |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
11 |
*/ |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
12 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
13 |
#include <stdlib.h> |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
14 |
#include <vector> |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
15 |
#include <filesystem> |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
16 |
|
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
17 |
// eRPC includes |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
18 |
#include "erpc_basic_codec.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
19 |
#include "erpc_serial_transport.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
20 |
#include "erpc_tcp_transport.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
21 |
#include "erpc_simple_server.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
22 |
|
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
23 |
// eRPC generated includes |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
24 |
#include "erpc_PLCObject_server.hpp" |
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
25 |
|
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
26 |
// erpcgen includes (re-uses erpcgen's logging system and options parser) |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
27 |
#include "Logging.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
28 |
#include "options.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
29 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
30 |
#include "PLCObject.hpp" |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
31 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
32 |
using namespace erpc; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
33 |
using namespace std; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
34 |
|
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
35 |
#define MSG_SIZE 1024*6 |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
36 |
class MyMessageBufferFactory : public MessageBufferFactory |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
37 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
38 |
public: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
39 |
virtual MessageBuffer create() |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
40 |
{ |
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
41 |
uint8_t *buf = new uint8_t[MSG_SIZE]; |
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
42 |
return MessageBuffer(buf, MSG_SIZE); |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
43 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
44 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
45 |
virtual void dispose(MessageBuffer *buf) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
46 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
47 |
erpc_assert(buf); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
48 |
if (*buf) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
49 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
50 |
delete[] buf->get(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
51 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
52 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
53 |
}; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
54 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
55 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
56 |
namespace beremizRuntime { |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
57 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
58 |
/*! The tool's name. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
59 |
const char k_toolName[] = "beremizRuntime"; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
60 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
61 |
/*! Current version number for the tool. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
62 |
const char k_version[] = __STRING(BEREMIZ_VERSION); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
63 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
64 |
/*! Copyright string. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
65 |
const char k_copyright[] = "Copyright 2024 Beremiz SAS. All rights reserved."; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
66 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
67 |
static const char *k_optionsDefinition[] = { "?|help", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
68 |
"V|version", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
69 |
"v|verbose", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
70 |
"t:transport <transport>", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
71 |
"b:baudrate <baudrate>", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
72 |
"p:port <port>", |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
73 |
"h:host <host>", |
3957
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
74 |
"a|autoload", |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
75 |
NULL }; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
76 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
77 |
/*! Help string. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
78 |
const char k_usageText[] = |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
79 |
"\nOptions:\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
80 |
-?/--help Show this help\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
81 |
-V/--version Display tool version\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
82 |
-v/--verbose Print extra detailed log information\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
83 |
-t/--transport <transport> Type of transport.\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
84 |
-b/--baudrate <baudrate> Baud rate.\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
85 |
-p/--port <port> Port name or port number.\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
86 |
-h/--host <host> Host definition.\n\ |
3957
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
87 |
-a/--autoload Autoload.\n\ |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
88 |
\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
89 |
Available transports (use with -t option):\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
90 |
tcp Tcp transport type (host, port number).\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
91 |
serial Serial transport type (port name, baud rate).\n\ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
92 |
\n"; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
93 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
94 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
95 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
96 |
* @brief Class that encapsulates the beremizRuntime tool. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
97 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
98 |
* A single global logger instance is created during object construction. It is |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
99 |
* never freed because we need it up to the last possible minute, when an |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
100 |
* exception could be thrown. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
101 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
102 |
class beremizRuntimeCLI |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
103 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
104 |
protected: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
105 |
enum class verbose_type_t |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
106 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
107 |
kWarning, |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
108 |
kInfo, |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
109 |
kDebug, |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
110 |
kExtraDebug |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
111 |
}; /*!< Types of verbose outputs from beremizRuntime application. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
112 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
113 |
enum class transports_t |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
114 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
115 |
kNoneTransport, |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
116 |
kTcpTransport, |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
117 |
kSerialTransport |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
118 |
}; /*!< Type of transport to use. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
119 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
120 |
typedef vector<string> string_vector_t; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
121 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
122 |
int m_argc; /*!< Number of command line arguments. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
123 |
char **m_argv; /*!< String value for each command line argument. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
124 |
StdoutLogger *m_logger; /*!< Singleton logger instance. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
125 |
verbose_type_t m_verboseType; /*!< Which type of log is need to set (warning, info, debug). */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
126 |
const char *m_workingDir; /*!< working directory. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
127 |
string_vector_t m_positionalArgs; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
128 |
transports_t m_transport; /*!< Transport used for receiving messages. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
129 |
uint32_t m_baudrate; /*!< Baudrate rate speed. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
130 |
const char *m_port; /*!< Name or number of port. Based on used transport. */ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
131 |
const char *m_host; /*!< Host name */ |
3957
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
132 |
bool m_autoload = false; /*!< Autoload flag. */ |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
133 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
134 |
public: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
135 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
136 |
* @brief Constructor. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
137 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
138 |
* @param[in] argc Count of arguments in argv variable. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
139 |
* @param[in] argv Pointer to array of arguments. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
140 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
141 |
* Creates the singleton logger instance. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
142 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
143 |
beremizRuntimeCLI(int argc, char *argv[]) : |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
144 |
m_argc(argc), m_argv(argv), m_logger(0), m_verboseType(verbose_type_t::kWarning), |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
145 |
m_workingDir(NULL), m_transport(transports_t::kNoneTransport), m_baudrate(115200), m_port(NULL), |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
146 |
m_host(NULL) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
147 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
148 |
// create logger instance |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
149 |
m_logger = new StdoutLogger(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
150 |
m_logger->setFilterLevel(Logger::log_level_t::kWarning); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
151 |
Log::setLogger(m_logger); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
152 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
153 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
154 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
155 |
* @brief Destructor. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
156 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
157 |
~beremizRuntimeCLI() {} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
158 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
159 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
160 |
* @brief Reads the command line options passed into the constructor. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
161 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
162 |
* This method can return a return code to its caller, which will cause the |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
163 |
* tool to exit immediately with that return code value. Normally, though, it |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
164 |
* will return -1 to signal that the tool should continue to execute and |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
165 |
* all options were processed successfully. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
166 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
167 |
* The Options class is used to parse command line options. See |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
168 |
* #k_optionsDefinition for the list of options and #k_usageText for the |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
169 |
* descriptive help for each option. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
170 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
171 |
* @retval -1 The options were processed successfully. Let the tool run normally. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
172 |
* @return A zero or positive result is a return code value that should be |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
173 |
* returned from the tool as it exits immediately. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
174 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
175 |
int processOptions() |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
176 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
177 |
Options options(*m_argv, k_optionsDefinition); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
178 |
OptArgvIter iter(--m_argc, ++m_argv); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
179 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
180 |
// process command line options |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
181 |
int optchar; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
182 |
const char *optarg; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
183 |
while ((optchar = options(iter, optarg))) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
184 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
185 |
switch (optchar) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
186 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
187 |
case '?': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
188 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
189 |
printUsage(options); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
190 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
191 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
192 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
193 |
case 'V': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
194 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
195 |
printf("%s %s\n%s\n", k_toolName, k_version, k_copyright); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
196 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
197 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
198 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
199 |
case 'v': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
200 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
201 |
if (m_verboseType != verbose_type_t::kExtraDebug) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
202 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
203 |
m_verboseType = (verbose_type_t)(((int)m_verboseType) + 1); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
204 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
205 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
206 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
207 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
208 |
case 't': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
209 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
210 |
string transport = optarg; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
211 |
if (transport == "tcp") |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
212 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
213 |
m_transport = transports_t::kTcpTransport; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
214 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
215 |
else if (transport == "serial") |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
216 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
217 |
m_transport = transports_t::kSerialTransport; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
218 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
219 |
else |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
220 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
221 |
Log::error("error: unknown transport type %s", transport.c_str()); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
222 |
return 1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
223 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
224 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
225 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
226 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
227 |
case 'b': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
228 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
229 |
m_baudrate = strtoul(optarg, NULL, 10); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
230 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
231 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
232 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
233 |
case 'p': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
234 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
235 |
m_port = optarg; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
236 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
237 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
238 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
239 |
case 'h': |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
240 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
241 |
m_host = optarg; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
242 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
243 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
244 |
|
3957
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
245 |
case 'a': |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
246 |
{ |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
247 |
m_autoload = true; |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
248 |
break; |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
249 |
} |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
250 |
|
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
251 |
default: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
252 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
253 |
Log::error("error: unrecognized option\n\n"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
254 |
printUsage(options); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
255 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
256 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
257 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
258 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
259 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
260 |
// handle positional args |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
261 |
if (iter.index() < m_argc) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
262 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
263 |
if (m_argc - iter.index() > 1){ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
264 |
Log::error("error: too many arguments\n\n"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
265 |
printUsage(options); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
266 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
267 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
268 |
int i; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
269 |
for (i = iter.index(); i < m_argc; ++i) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
270 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
271 |
m_positionalArgs.push_back(m_argv[i]); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
272 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
273 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
274 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
275 |
// all is well |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
276 |
return -1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
277 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
278 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
279 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
280 |
* @brief Prints help for the tool. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
281 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
282 |
* @param[in] options Options, which can be used. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
283 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
284 |
void printUsage(Options &options) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
285 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
286 |
options.usage(cout, "[path]"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
287 |
printf(k_usageText); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
288 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
289 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
290 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
291 |
* @brief Core of the tool. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
292 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
293 |
* Calls processOptions() to handle command line options before performing the |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
294 |
* real work the tool does. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
295 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
296 |
* @retval 1 The functions wasn't processed successfully. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
297 |
* @retval 0 The function was processed successfully. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
298 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
299 |
* @exception Log::error This function is called, when function wasn't |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
300 |
* processed successfully. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
301 |
* @exception runtime_error Thrown, when positional args is empty. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
302 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
303 |
int run() |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
304 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
305 |
try |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
306 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
307 |
// read command line options |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
308 |
int result; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
309 |
if ((result = processOptions()) != -1) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
310 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
311 |
return result; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
312 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
313 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
314 |
// set verbose logging |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
315 |
setVerboseLogging(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
316 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
317 |
if (!m_positionalArgs.size()) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
318 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
319 |
m_workingDir = std::filesystem::current_path().c_str(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
320 |
} else { |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
321 |
m_workingDir = m_positionalArgs[0].c_str(); |
3940
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
322 |
std::filesystem::current_path(m_workingDir); |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
323 |
} |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
324 |
|
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
325 |
// remove temporary directory if it already exists |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
326 |
if (std::filesystem::exists("tmp")) |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
327 |
{ |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
328 |
std::filesystem::remove_all("tmp"); |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
329 |
} |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
330 |
|
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
331 |
// Create temporary directory in working directory |
934bd46a7500
C++ runtime: WIP: untested PLCObject implementation. Still missing tracing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3937
diff
changeset
|
332 |
std::filesystem::create_directory("tmp"); |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
333 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
334 |
Transport *_transport; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
335 |
switch (m_transport) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
336 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
337 |
case transports_t::kTcpTransport: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
338 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
339 |
uint16_t portNumber = strtoul(m_port, NULL, 10); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
340 |
TCPTransport *tcpTransport = new TCPTransport(m_host, portNumber, true); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
341 |
if (erpc_status_t err = tcpTransport->open()) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
342 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
343 |
return err; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
344 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
345 |
_transport = tcpTransport; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
346 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
347 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
348 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
349 |
case transports_t::kSerialTransport: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
350 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
351 |
SerialTransport *serialTransport = new SerialTransport(m_port, m_baudrate); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
352 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
353 |
uint8_t vtime = 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
354 |
uint8_t vmin = 1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
355 |
while (kErpcStatus_Success != serialTransport->init(vtime, vmin)) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
356 |
; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
357 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
358 |
_transport = serialTransport; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
359 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
360 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
361 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
362 |
default: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
363 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
364 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
365 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
366 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
367 |
|
3949
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
368 |
Crc16 crc; |
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
369 |
_transport->setCrc16(&crc); |
f64dce4e2f62
C runtime: initial fixes. Now runs and traces first_steps example.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3940
diff
changeset
|
370 |
|
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
371 |
MyMessageBufferFactory _msgFactory; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
372 |
BasicCodecFactory _basicCodecFactory; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
373 |
SimpleServer _server; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
374 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
375 |
Log::info("Starting ERPC server...\n"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
376 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
377 |
_server.setMessageBufferFactory(&_msgFactory); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
378 |
_server.setTransport(_transport); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
379 |
_server.setCodecFactory(&_basicCodecFactory); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
380 |
|
3957
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
381 |
PLCObject plc_object = PLCObject(); |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
382 |
BeremizPLCObjectService_service svc = BeremizPLCObjectService_service(&plc_object); |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
383 |
|
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
384 |
_server.addService(&svc); |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
385 |
|
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
386 |
if(m_autoload) |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
387 |
{ |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
388 |
plc_object.AutoLoad(); |
2510c1f935d1
C runtime: add autoload
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3949
diff
changeset
|
389 |
} |
3937
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
390 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
391 |
_server.run(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
392 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
393 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
394 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
395 |
catch (exception &e) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
396 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
397 |
Log::error("error: %s\n", e.what()); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
398 |
return 1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
399 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
400 |
catch (...) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
401 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
402 |
Log::error("error: unexpected exception\n"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
403 |
return 1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
404 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
405 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
406 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
407 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
408 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
409 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
410 |
* @brief Turns on verbose logging. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
411 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
412 |
void setVerboseLogging() |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
413 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
414 |
// verbose only affects the INFO and DEBUG filter levels |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
415 |
// if the user has selected quiet mode, it overrides verbose |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
416 |
switch (m_verboseType) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
417 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
418 |
case verbose_type_t::kWarning: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
419 |
Log::getLogger()->setFilterLevel(Logger::log_level_t::kWarning); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
420 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
421 |
case verbose_type_t::kInfo: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
422 |
Log::getLogger()->setFilterLevel(Logger::log_level_t::kInfo); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
423 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
424 |
case verbose_type_t::kDebug: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
425 |
Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
426 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
427 |
case verbose_type_t::kExtraDebug: |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
428 |
Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug2); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
429 |
break; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
430 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
431 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
432 |
}; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
433 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
434 |
} // namespace beremizRuntime |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
435 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
436 |
/*! |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
437 |
* @brief Main application entry point. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
438 |
* |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
439 |
* Creates a tool instance and lets it take over. |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
440 |
*/ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
441 |
int main(int argc, char *argv[], char *envp[]) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
442 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
443 |
(void)envp; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
444 |
try |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
445 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
446 |
return beremizRuntime::beremizRuntimeCLI(argc, argv).run(); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
447 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
448 |
catch (...) |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
449 |
{ |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
450 |
Log::error("error: unexpected exception\n"); |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
451 |
return 1; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
452 |
} |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
453 |
|
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
454 |
return 0; |
e13543d716b6
C++ runtime: add eRPC server, minimal CLI and Makefile. WIP.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
455 |
} |