mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
tooling: claralogConverter changed path and ignore already decoded files
This commit is contained in:
parent
c0bc567f01
commit
80aec67c4d
1 changed files with 12 additions and 6 deletions
|
@ -27,7 +27,7 @@ from helpers import combineValueAndMultiplier
|
|||
import json
|
||||
|
||||
# The path where the script will search for pcap files:
|
||||
directory = 'local/pcaps_to_convert'
|
||||
directory = '../clara-logs'
|
||||
|
||||
# stop the evaluation after this number of packets. Set to zero to have no limit.
|
||||
nLimitNumberOfPackets = -1
|
||||
|
@ -42,8 +42,13 @@ nLimitNumberOfPackets = -1
|
|||
def convertClaralogToTxt(inputFileName):
|
||||
global nLimitNumberOfPackets
|
||||
global directory
|
||||
outputFileName = inputFileName + '.decoded.txt'
|
||||
# todo: if output file exists
|
||||
if (os.path.isfile(os.path.join(directory, outputFileName))):
|
||||
print("output file " + outputFileName + " already exists. Nothing to do.")
|
||||
return
|
||||
fileIn = open(inputFileName, 'r')
|
||||
fileOut = open(inputFileName + '.decoded.txt', 'w')
|
||||
fileOut = open(outputFileName, 'w')
|
||||
print("# generated by claralogConverter.py", file=fileOut)
|
||||
print("# https://github.com/uhi22/pyPLC", file=fileOut)
|
||||
fileOutValues = open(inputFileName + '.values.txt', 'w')
|
||||
|
@ -60,12 +65,13 @@ def convertClaralogToTxt(inputFileName):
|
|||
numberOfPackets+=1
|
||||
#print(packet)
|
||||
print(line.strip(), file=fileOut)
|
||||
posTcpPayload = line.find(": 01 fe 80 01 00")
|
||||
lineWithoutBlanks = line.replace(" ", "")
|
||||
posTcpPayload = lineWithoutBlanks.find(":01fe800100")
|
||||
if posTcpPayload>0:
|
||||
# we found the V2GTP header.
|
||||
tcppayload = line[posTcpPayload + 2:] # everything until the end of the line is the data
|
||||
tcppayload = lineWithoutBlanks[posTcpPayload + 1:] # everything until the end of the line is the data
|
||||
# this gives a string of hex values, separated by " ", e.g. "01fe8001"
|
||||
s = tcppayload.replace(" ", "") # remove spaces
|
||||
s = tcppayload
|
||||
if (s[0:8]=="01fe8001"):
|
||||
# it is a V2GTP header with EXI content
|
||||
strExi = s[16:] # remove V2GTP header (8 bytes, means 16 hex characters)
|
||||
|
|
Loading…
Reference in a new issue