Protobuf prototype

This commit is contained in:
Konstantin Lampalzer 2022-03-18 18:11:16 +01:00
parent e277a83c5f
commit 9b567b8c6c
119 changed files with 8599 additions and 0 deletions

36
client_s2/main.py Normal file
View file

@ -0,0 +1,36 @@
import socket
import sys
import os
import CompLib_pb2
SOCKET_PATH = "/tmp/compLib"
def send(data, size):
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
sock.connect(SOCKET_PATH)
sock.sendall(size.to_bytes(1, byteorder='big'))
sock.sendall(data)
responseSizeBytes = sock.recv(1)
responseSize = int.from_bytes(responseSizeBytes, byteorder="big")
print(responseSize)
responseBytes = sock.recv(responseSize)
genericResponse = CompLib_pb2.GenericResponse()
genericResponse.ParseFromString(responseBytes)
print(genericResponse)
# reponseBytes =
def main():
readSensorsRequest = CompLib_pb2.ReadSensorsRequest()
# readSensorsRequest.header = CompLib_pb2.Header()
readSensorsRequest.header.message_type = readSensorsRequest.DESCRIPTOR.full_name
send(readSensorsRequest.SerializeToString(), readSensorsRequest.ByteSize())
main()