Fixes for interrupts

This commit is contained in:
rparedis 2024-02-15 10:17:58 +01:00
parent 30064b7101
commit cc31d606a7
4 changed files with 13 additions and 2 deletions

View file

@ -1095,7 +1095,15 @@ class BaseSimulator(Solver):
self.threading_backend.wait(wait_time, self.runsim)
return True
try:
portname, event_value = interrupt.split(" ")
info = interrupt.split(" ")
portname = info[0]
event_value = " ".join(info[1:])
if event_value[0] in "([{": # also allow tuples, lists or dictionaries
try:
event_value = eval(event_value)
except: pass
# event_value = eval(" ".join(info[1:]))
# portname, event_value = interrupt.split(" ")
event_port = self.portmap[portname]
except ValueError:
# Couldn't split, means we should stop

View file

@ -15,6 +15,7 @@
from threading import Event, Thread, Lock
import pypdevs.accurate_time as time
from pypdevs.infinity import INFINITY
class ThreadingPython(object):
"""
@ -34,6 +35,8 @@ class ThreadingPython(object):
:param delay: time to wait
:param func: the function to call
"""
if delay == INFINITY:
return
#NOTE this call has a granularity of 5ms in Python <= 2.7.x in the worst case, so beware!
# the granularity seems to be much better in Python >= 3.x
p = Thread(target=ThreadingPython.callFunc, args=[self, delay, func])

View file

@ -82,4 +82,4 @@ class ThreadingTkInter(object):
"""
if not self.last_infinity:
self.queue.append(None)
self.unlock()
self.unlock()