added status and error output for encoder

This commit is contained in:
uhi22 2022-11-16 19:31:45 +01:00
parent 7e964a2af3
commit 19219e49a5

View file

@ -164,11 +164,12 @@ def exiDecode(exiHex, prefix="DH"):
strConverterResult = result.stdout strConverterResult = result.stdout
return strConverterResult return strConverterResult
def exiEncode(strMessageName, params=""): def exiEncode(strMessageName):
# todo: handle the schema, the message name and the parameters # todo: handle the schema, the message name and the parameters
# param1 = "Eh" # Eh for encode handshake, SupportedApplicationProtocolResponse # param1 = "Eh" # Eh for encode handshake, SupportedApplicationProtocolResponse
# param1 = "EDa" # EDa for Encode, Din, SessionSetupResponse # param1 = "EDa" # EDa for Encode, Din, SessionSetupResponse
param1 = strMessageName param1 = strMessageName
print("[EXICONNECTOR] exiEncode " + param1)
result = subprocess.run([pathToOpenV2GExe, param1], capture_output=True, text=True) result = subprocess.run([pathToOpenV2GExe, param1], capture_output=True, text=True)
if (len(result.stderr)>0): if (len(result.stderr)>0):
strConverterResult = "exiEncode ERROR. stderr:" + result.stderr strConverterResult = "exiEncode ERROR. stderr:" + result.stderr
@ -184,6 +185,9 @@ def exiEncode(strMessageName, params=""):
try: try:
y = json.loads(result.stdout) y = json.loads(result.stdout)
strConverterResult = y["result"] strConverterResult = y["result"]
strConverterError = y["error"]
if (len(strConverterError)>0):
print("[EXICONNECTOR] exiEncode error " + strConverterError)
#print("strConverterResult is " + str(strConverterResult)) #print("strConverterResult is " + str(strConverterResult))
except: except:
strConverterResult = "exiEncode failed to convert json to dict." strConverterResult = "exiEncode failed to convert json to dict."