| 61 | //////////////////////////////////////////////////////////////////////////////// |
| 62 | |
| 63 | int 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 | } |
nothing calls this directly
no test coverage detected