Accept both CR and LF to denote newline.
[uccvend-snackrom.git] / ROM2 / sci.c
index 2346b28..739d706 100644 (file)
@@ -40,7 +40,9 @@ void sci_rx_int() {
                return;
        }
        sci_rx_buf[sci_rx_buf_ptr] = _io_ports[M6811_SCDR];
-       if (sci_rx_buf[sci_rx_buf_ptr] == '\n') {
+       if (sci_rx_buf[sci_rx_buf_ptr] == '\n' ||
+                       sci_rx_buf[sci_rx_buf_ptr] == '\r') {
+               if (sci_rx_buf_ptr == 0) return; /* we've read a blank packet in */
                sci_rx_buf[sci_rx_buf_ptr] = '\0';
                sci_have_packet = 1;
                sci_rx_buf_ptr = 0;
@@ -68,15 +70,11 @@ void msg_clr() {
 }
 
 void send_ack() {
-       sci_tx_buf[0] = '!';
-       sci_tx_buf[1] = '\n';
-       sci_tx_buf[2] = '\0';
+       my_strncpy(sci_tx_buf, "!\n", BUFFER_LEN);
        send_packet();
 }
 
 void send_nack() {
-       sci_tx_buf[0] = '?';
-       sci_tx_buf[1] = '\n';
-       sci_tx_buf[2] = '\0';
+       my_strncpy(sci_tx_buf, "?\n", BUFFER_LEN);
        send_packet();
 }

UCC git Repository :: git.ucc.asn.au