}
mockup::event_thread::event_thread(unsigned int chip_index,
- unsigned int line_offset, unsigned int freq)
+ unsigned int line_offset, unsigned int period_ms)
: _m_chip_index(chip_index),
_m_line_offset(line_offset),
- _m_freq(freq),
+ _m_period_ms(period_ms),
_m_stop(false),
_m_mutex(),
_m_cond(),
break;
::std::cv_status status = this->_m_cond.wait_for(lock,
- std::chrono::milliseconds(this->_m_freq));
+ std::chrono::milliseconds(this->_m_period_ms));
if (status == ::std::cv_status::timeout)
mockup::instance().chip_set_pull(this->_m_chip_index,
this->_m_line_offset, i % 2);
{
public:
- event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int freq);
+ event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int period_ms);
~event_thread(void);
event_thread(const event_thread& other) = delete;
unsigned int _m_chip_index;
unsigned int _m_line_offset;
- unsigned int _m_freq;
+ unsigned int _m_period_ms;
bool _m_stop;
class EventThread(threading.Thread):
- def __init__(self, chip_idx, line_offset, freq):
+ def __init__(self, chip_idx, line_offset, period_ms):
threading.Thread.__init__(self)
self.chip_idx = chip_idx
self.line_offset = line_offset
- self.freq = freq
+ self.period_ms = period_ms
self.lock = threading.Lock()
self.cond = threading.Condition(self.lock)
self.should_stop = False
if self.should_stop:
break;
- if not self.cond.wait(float(self.freq) / 1000):
+ if not self.cond.wait(float(self.period_ms) / 1000):
mockup.chip_set_pull(self.chip_idx,
self.line_offset, i % 2)
i += 1
gboolean should_stop;
guint chip_index;
guint line_offset;
- guint freq;
+ guint period_ms;
};
static struct {
break;
}
- end_time = g_get_monotonic_time() + thread->freq * 1000;
+ end_time = g_get_monotonic_time() + thread->period_ms * 1000;
signalled = g_cond_wait_until(&thread->cond,
&thread->lock, end_time);
}
GpiodTestEventThread *
-gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint freq)
+gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint period_ms)
{
GpiodTestEventThread *thread = g_malloc0(sizeof(*thread));
thread->chip_index = chip_index;
thread->line_offset = line_offset;
- thread->freq = freq;
+ thread->period_ms = period_ms;
thread->id = g_thread_new("event-worker", event_worker_func, thread);
GpiodTestEventThread *
gpiod_test_start_event_thread(guint chip_index,
- guint line_offset, guint freq);
+ guint line_offset, guint period_ms);
void gpiod_test_stop_event_thread(GpiodTestEventThread *thread);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GpiodTestEventThread,