-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathmain_server.py
More file actions
38 lines (28 loc) · 943 Bytes
/
main_server.py
File metadata and controls
38 lines (28 loc) · 943 Bytes
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
#!/bin/python3
import sys
sys.path.insert(1, '../../../erpc_python') # nopep8
sys.path.insert(2, '../../') # nopep8
sys.path.insert(3, '../') # nopep8
import erpc
import config
from shim.py import hello_world
class MatrixMultiplyServiceHandler(hello_world.interface.ITextService):
def printText(self, text):
'''eRPC call definition'''
print(text)
def main():
# load configuration macros from C header file
cfg = config.loadConfig("../../config.h")
# init service
handler = MatrixMultiplyServiceHandler()
service = hello_world.server.TextServiceService(handler)
# init eRPC server infrastructure
transport = erpc.transport.TCPTransport(cfg["ERPC_HOSTNAME"], int(cfg["ERPC_PORT"]), True)
server = erpc.simple_server.SimpleServer(transport, erpc.basic_codec.BasicCodec)
server.add_service(service)
# run server
try:
server.run()
except:
pass
main()