-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathmain_server.py
More file actions
57 lines (38 loc) · 1.15 KB
/
main_server.py
File metadata and controls
57 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/python3
#
# Copyright 2023 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
#
from typing import Optional
from erpc.basic_codec import BasicCodec
from erpc.simple_server import SimpleServer
from erpc.transport import TCPTransport
import config
from shim import hello_world
g_server: Optional[SimpleServer] = None
class MatrixMultiplyServiceHandler(hello_world.interface.ITextService):
""" eRPC call definition"""
def printText(self, text):
print(text)
return True
def stopServer(self):
if g_server:
g_server.stop()
def main():
global g_server
# load configuration macros from C header file
cfg = config.lead_config("../config.h")
# init service
handler = MatrixMultiplyServiceHandler()
service = hello_world.server.TextServiceService(handler)
# init eRPC server infrastructure
transport = TCPTransport(cfg["ERPC_HOSTNAME"], int(cfg["ERPC_PORT"]), True)
g_server = SimpleServer(transport, BasicCodec)
g_server.add_service(service)
print("Starting server.")
# run server
g_server.run()
print("Server stopped.")
if __name__ == "__main__":
main()