// ----------------------------------------------------------------------- void cchar_term_queue_char(struct cchar_unit_proto_t *unit, char data) { int report_int = 0; LOG(L_TERM, "enqueue char: #%02x", data); pthread_mutex_lock(&UNIT->buf_mutex); UNIT->buf[UNIT->buf_wpos] = data; UNIT->buf_len++; if (UNIT->buf_wpos >= TERM_BUF_LEN-2) { UNIT->buf_wpos = 0; } else { UNIT->buf_wpos++; } if (UNIT->empty_read) { UNIT->empty_read = 0; report_int = 1; } pthread_mutex_unlock(&UNIT->buf_mutex); if (report_int) { LOG(L_TERM, "new char available, sending interrupt"); cchar_int(unit->chan, unit->num, CCHAR_TERM_INT_READY); } }
// ----------------------------------------------------------------------- void cchar_term_queue_char(struct cchar_unit_proto_t *unit, char data) { pthread_mutex_lock(&UNIT->buf_mutex); UNIT->buf[UNIT->buf_wpos] = data; UNIT->buf_len++; if (UNIT->buf_wpos >= TERM_BUF_LEN-2) { UNIT->buf_wpos = 0; } else { UNIT->buf_wpos++; } if (UNIT->empty_read) { cchar_int(unit->chan, unit->num, CCHAR_TERM_INT_READY); UNIT->empty_read = 0; } pthread_mutex_unlock(&UNIT->buf_mutex); }