[drv.uart] Read everything from the channel in uartnnMake sure to keep reading until the channel is empty so output isn't behindnby a keystroke.

This commit is contained in:
2024-04-26 00:32:06 -07:00
parent 182d3b0a6a
commit 3b9efc11d0
5 changed files with 25 additions and 26 deletions

View File

@@ -37,17 +37,13 @@ gather_command(j6::channel &cout, j6::ring_buffer &buf)
while (i < n) { while (i < n) {
start[i] = input[i]; start[i] = input[i];
outp[i] = input[i]; outp[i] = input[i];
j6::syslog(j6::logs::app, j6::log_level::spam, "Read: %x", start[i]);
if (start[i++] == '\r') { if (start[i++] == '\r') {
newline = true; newline = true;
break; break;
} }
} }
size_t written = i; cout.commit(i);
if (newline)
outp[written++] = '\n';
cout.commit(written);
cout.consume(i); cout.consume(i);
if (newline) if (newline)

View File

@@ -96,7 +96,8 @@ main(int argc, const char **argv)
uint64_t signals = 0; uint64_t signals = 0;
result = j6_event_wait(event, &signals, 500); result = j6_event_wait(event, &signals, 500);
if (result == j6_err_timed_out) { if (result == j6_err_timed_out) {
com1.handle_interrupt(); com1.do_read();
com1.do_write();
//com2.handle_interrupt(); //com2.handle_interrupt();
continue; continue;
} }

View File

@@ -91,6 +91,7 @@ serial_port::do_write()
{ {
util::scoped_lock lock {m_lock}; util::scoped_lock lock {m_lock};
while (true) {
uint8_t const *data = nullptr; uint8_t const *data = nullptr;
size_t n = m_chan.get_block(&data, false); size_t n = m_chan.get_block(&data, false);
@@ -113,6 +114,7 @@ serial_port::do_write()
m_chan.consume(n); m_chan.consume(n);
} }
}
void void
serial_port::handle_error(uint16_t reg, uint8_t value) serial_port::handle_error(uint16_t reg, uint8_t value)

View File

@@ -23,6 +23,7 @@ public:
void handle_interrupt(); void handle_interrupt();
void do_write(); void do_write();
void do_read();
private: private:
bool m_writing; bool m_writing;
@@ -30,6 +31,5 @@ private:
j6::channel &m_chan; j6::channel &m_chan;
util::spinlock m_lock; util::spinlock m_lock;
void do_read();
void handle_error(uint16_t reg, uint8_t value); void handle_error(uint16_t reg, uint8_t value);
}; };

View File

@@ -317,7 +317,7 @@ image::parse_rela_table(const util::counted<const rela> &table, image_list &ctx)
break; break;
default: default:
j6::syslog(j6::logs::app, j6::log_level::verbose, "Unknown rela relocation type %d in %s", rel.type, name); j6::syslog(j6::logs::app, j6::log_level::error, "Unknown rela relocation type %d in %s", rel.type, name);
exit(126); exit(126);
break; break;
} }