mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
added status and error output for encoder
This commit is contained in:
parent
7e964a2af3
commit
19219e49a5
1 changed files with 5 additions and 1 deletions
|
@ -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."
|
||||||
|
|
Loading…
Reference in a new issue