logger.debug("Starting writer...");
while(true) {
try {
// this call blocks until the lock on the queue is released
logger.trace("writer checking message queue");
Msg msg = m_writeQueue.take();
if (msg.getData() == null) {
logger.error("found null message in write queue!");
} else {
logger.debug("writing ({}): {}", msg.getQuietTime(), msg);
// To debug race conditions during startup (i.e. make the .items
// file definitions be available *before* the modem link records,
// slow down the modem traffic with the following statement:
// Thread.sleep(500);
m_out.write(msg.getData());
while (m_reader.waitForReply()) {
Thread.sleep(WAIT_TIME);
logger.trace("retransmitting msg: {}", msg);
m_out.write(msg.getData());
}
// if rate limited, need to sleep now.
if (msg.getQuietTime() > 0) {
Thread.sleep(msg.getQuietTime());
}
}
} catch (InterruptedException e) {
logger.error("got interrupted exception in write thread:", e);
} catch (IOException e) {