Commit 229430e8 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

minor changes

parent 2b0588ac
......@@ -277,7 +277,7 @@ def worker_gpiotracing(queueitem=None, nodeid=None, resultfile_path=None, logque
for line in infile:
try:
(timestamp, ticks, pin, level) = line.strip().split(',', 3)
outfile.write("%s,%s,%s,%s,%s,%s\n" % (timestamp, ticks, obsid, nodeid, pin, level))
outfile.write("%s,%s,%d,%s,%s,%s\n" % (timestamp, ticks, obsid, nodeid, pin, level))
except ValueError:
logqueue.put_nowait((loggername, logging.ERROR, "Could not parse line '%s' in gpiotracing worker process." % line))
break
......@@ -362,7 +362,7 @@ def worker_logs(queueitem=None, nodeid=None, resultfile_path=None, logqueue=None
infile = open(inputfilename, "r")
for line in infile:
(timestamp, msg) = line.strip().split(',', 1)
outfile.write("%s,%s,%s,%s\n" % (timestamp, obsid, nodeid, msg))
outfile.write("%s,%d,%s,%s\n" % (timestamp, obsid, nodeid, msg))
infile.close()
os.remove(inputfilename)
except:
......@@ -403,7 +403,7 @@ def worker_serial(queueitem=None, nodeid=None, resultfile_path=None, logqueue=No
(timestamp, msg) = line.strip().split(',', 1)
except:
continue
result = "%s,%s,%s,r,%s\n" % (timestamp, obsid, nodeid, msg.rstrip())
result = "%s,%d,%s,r,%s\n" % (timestamp, obsid, nodeid, msg.rstrip())
outfile.write(result)
infile.close()
os.remove(inputfilename)
......@@ -454,16 +454,16 @@ def worker_datatrace(queueitem=None, nodeid=None, resultfile_path=None, logqueue
if flocklab.parse_int(var) < len(varnames):
var = varnames[flocklab.parse_int(var)]
# output format: timestamp,observer_id,node_id,variable,value,access,pc
outfile.write("%s,%s,%s,%s,%s,%s,%s\n" % (timestamp, obsid, nodeid, var, val, access, pc))
outfile.write("%s,%d,%s,%s,%s,%s,%s\n" % (timestamp, obsid, nodeid, var, val, access, pc))
infile.close()
# debug
#shutil.copyfile(input_filename, "%s_raw" % resultfile_path)
#shutil.copyfile(tmpfile1, "%s_uncorrected.csv" % resultfile_path)
except:
msg = "Error in datatrace worker process: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
_errors.append((msg, obsid))
logqueue.put_nowait((loggername, logging.ERROR, msg))
finally:
# debug
#shutil.copyfile(input_filename, "%s_raw" % resultfile_path)
#shutil.copyfile(tmpfile1, "%s_uncorrected.csv" % resultfile_path)
# delete files
os.remove(input_filename)
os.remove(tmpfile1)
......@@ -489,10 +489,10 @@ def worker_callback(result):
if len(result[0]) > 0:
try:
for (err, obsid) in result[0]:
msg = "Error %d when processing results for Observer ID %s: %s" % (obsid, err)
msg = "An error occurred when processing the results for Observer %d: %s" % (obsid, str(err))
errors.append(msg)
except:
errors.append("Failed to convert the error list in worker_callback.")
errors.append("Failed to convert the error list in worker_callback (%s)." % str(result[0]))
# 2nd: a list of the processed elements
try:
......
......@@ -82,11 +82,6 @@ def parse_dwt_output(input_file='swo_read_log', output_file='swo_read_log.csv',
global_ts_queue = collections.deque()
# df_queue = queue.Queue()
# Output the information about the program.
if logging_on:
sys.stdout.write('configure and read demo\n')
sys.stdout.write('Press Ctrl-C to Exit\n')
if threads:
# Create threads
read_thread = threading.Thread(target=read_fun, args=(swo_queue, global_ts_queue, input_file))
......@@ -136,7 +131,6 @@ def read_fun(swo_queue, global_ts_queue, input_file):
with open(input_file) as open_file_object:
for line in open_file_object:
if data_is_next: # Test if this is a line with data
data_is_next = False
numbers = [] # initialise again, else has the numbers from previous line also
for word in line.split(): # extract the numbers in the line into a python list
......@@ -169,6 +163,9 @@ def read_fun(swo_queue, global_ts_queue, input_file):
swo_queue.appendleft(byte) # put all the data into the queue that the parsing thread will read from
# now indicate that this is the end of a line
# swo_queue.appendleft(LINE_ENDS)
if numbers:
data_is_next = False
else: # If not it is a line with a global timestamp
data_is_next = True
global_ts_count += 1
......@@ -186,7 +183,7 @@ def read_fun(swo_queue, global_ts_queue, input_file):
open_file_object.close()
read_thread_ended = True
if logging_on:
print("read thread ended")
print("read thread ended (timestamp queue size: %d, swo queue size: %d)" % (len(global_ts_queue), len(swo_queue)))
def parse_fun(swo_queue, global_ts_queue):
......@@ -244,7 +241,7 @@ def parser(swo_byte, swo_queue, global_ts_queue):
pars_hard(swo_byte, swo_queue)
else:
if logging_on:
print("this is a SWIT packet (SW source)")
print("unrecognized SWO byte: %d" % swo_byte)
def pars_hard(header_swo_byte, swo_queue):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment