sim: serial: Send '\r\n' instead of just '\n'

This fixes an issue when running with the HDMI2USB firmware which
expects \r\n to come from the UART.  Since the verilator adapter
is just sending \n commands cannot be executed.

Also, one minor whitespace cleanup. (could remove if needed)
This commit is contained in:
Stafford Horne 2018-10-09 11:16:05 +09:00
parent 6e327cda26
commit 8877dba7e9
1 changed files with 6 additions and 1 deletions

View File

@ -76,6 +76,11 @@ void read_handler(int fd, short event, void *arg)
int i;
read_len = read(fd, buffer, 1024);
for(i = 0; i < read_len; i++) {
/* If we are reading a newline make sure its \r\n. */
if (buffer[i] == '\n') {
s->databuf[(s->data_start + s->datalen ) % 2048] = '\r';
s->datalen++;
}
s->databuf[(s->data_start + s->datalen ) % 2048] = buffer[i];
s->datalen++;
}
@ -157,7 +162,7 @@ static int serial2console_tick(void *sess) {
*s->rx_valid = 0;
if(s->datalen) {
*s->rx=s->databuf[s->data_start];
*s->rx = s->databuf[s->data_start];
s->data_start = (s->data_start + 1) % 2048;
s->datalen--;
*s->rx_valid = 1;