MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / main

Function main

examples/hello_world/c/main_server.cpp:63–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61////////////////////////////////////////////////////////////////////////////////
62
63int main()
64{
65 erpc_status_t status;
66
67 /* Init eRPC server components */
68 TCPTransport transport(ERPC_HOSTNAME, ERPC_PORT, true);
69 MyMessageBufferFactory msgFactory;
70 BasicCodecFactory codecFactory;
71 SimpleServer server;
72 Crc16 crc16;
73
74 /* Init service implementation and handler */
75 TextService textServiceImpl;
76 TextService_service textService(&textServiceImpl);
77
78 /* Setup transport */
79 transport.setCrc16(&crc16);
80 status = transport.open();
81
82 if (status != kErpcStatus_Success)
83 {
84 /* Print error description */
85 erpc_error_handler(status, 0);
86 return -1;
87 }
88
89 /* Setup server */
90 server.setTransport(&transport);
91 server.setCodecFactory(&codecFactory);
92 server.setMessageBufferFactory(&msgFactory);
93
94 /* add custom service implementation to the server */
95 server.addService(&textService);
96
97 std::cout << "Starting server." << std::endl;
98
99 while (g_server_run)
100 {
101 /* poll for requests */
102 status = server.poll();
103
104 /* handle error status */
105 if (status != kErpcStatus_Success)
106 {
107 /* print error description */
108 erpc_error_handler(status, 0);
109 }
110 }
111
112 std::cout << "Server stopped." << std::endl;
113
114 /* Close transport */
115 transport.close();
116}

Callers

nothing calls this directly

Calls 7

openMethod · 0.80
setTransportMethod · 0.80
pollMethod · 0.80
erpc_error_handlerFunction · 0.70
closeMethod · 0.65
setCrc16Method · 0.45
addServiceMethod · 0.45

Tested by

no test coverage detected