changeset 38:0a148f362097

Use \r\n instead of \n\r (keeps pexpect happy)
author darius
date Fri, 23 Nov 2007 12:01:54 +1030
parents 25fa387ef7e9
children 599d013ce3f2
files testavr.c
diffstat 1 files changed, 68 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/testavr.c	Tue Oct 23 11:03:22 2007 +0930
+++ b/testavr.c	Fri Nov 23 12:01:54 2007 +1030
@@ -81,7 +81,7 @@
 	/* End of line? */
 	if (c == '\n' || c == '\r') {
 	    cmd.buf[cmd.state + 1] = '\0';
-	    uart_putsP(PSTR("\n\r"));
+	    uart_putsP(PSTR("\r\n"));
 	    cmd.len = cmd.state;
 	    cmd.state = 255;
 	    continue;
@@ -108,7 +108,7 @@
 	cmd.state++;
 	/* Over flow? */
 	if (cmd.state == ((sizeof(cmd.buf) / sizeof(cmd.buf[0])) - 1)) {
-	    uart_putsP(PSTR("\n\rLine too long"));
+	    uart_putsP(PSTR("\r\nLine too long"));
 	    cmd.state = 0;
 	    continue;
 	}
@@ -162,8 +162,8 @@
     UCSRA = 0;
     UCSRB = _BV(RXEN) | _BV(TXEN) | _BV(RXCIE);
     UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);
-    uart_putsP(PSTR("\n\r\n\r===============\n\r"
-		    "Inited!\n\r\n\r"));
+    uart_putsP(PSTR("\r\n\r\n===============\r\n"
+		    "Inited!\r\n\r\n"));
 
     /* Ready to go! */
     sei();
@@ -172,25 +172,25 @@
     DDRA = 0xff;
     DDRC = 0xff;
     while (1) {
-	uart_putsP(PSTR("1\n\r"));
+	uart_putsP(PSTR("1\r\n"));
 	PORTA = 0xff;
-	uart_putsP(PSTR("2\n\r"));
+	uart_putsP(PSTR("2\r\n"));
 	PORTC = 0x00;
-	uart_putsP(PSTR("3\n\r"));
+	uart_putsP(PSTR("3\r\n"));
 	_delay_us(1);
-	uart_putsP(PSTR("4\n\r"));
+	uart_putsP(PSTR("4\r\n"));
 	PORTA = 0x80;
-	uart_putsP(PSTR("5\n\r"));
+	uart_putsP(PSTR("5\r\n"));
 	PORTC = 0xff;
-	uart_putsP(PSTR("6\n\r"));
+	uart_putsP(PSTR("6\r\n"));
     }
 #endif    
     
 #ifdef WITHUSB
-    uart_putsP(PSTR("Calling usb_init\n\r"));
+    uart_putsP(PSTR("Calling usb_init\r\n"));
     usb_init();
 #endif
-    uart_putsP(PSTR("done\n\r"));
+    uart_putsP(PSTR("done\r\n"));
     _delay_us(1000);
     uart_putsP(PSTR("> "));
     cmd.state = 0;
@@ -224,17 +224,17 @@
 	return;
 	     
     if (cmd.buf[0] == '?') {
-        uart_putsP(PSTR("rs               Reset and check for presence\n\r"
-                        "sr               Search the bus for ROMs\n\r"
-                        "re               Read a bit\n\r"
-                        "rb               Read a byte\n\r"
-                        "wr  bit          Write a bit\n\r"
-                        "wb  byte         Write a byte (hex)\n\r"
-                        "wc  cmd [ROMID]  Write command\n\r"
-                        "te  ROMID        Read the temperature from a DS1820\n\r"
-                        "in  port         Read from a port\n\r"
-                        "out port val     Write to a port\n\r"
-                        "ddr port [val]   Read/write DDR for a port\n\r"));
+        uart_putsP(PSTR("rs               Reset and check for presence\r\n"
+                        "sr               Search the bus for ROMs\r\n"
+                        "re               Read a bit\r\n"
+                        "rb               Read a byte\r\n"
+                        "wr  bit          Write a bit\r\n"
+                        "wb  byte         Write a byte (hex)\r\n"
+                        "wc  cmd [ROMID]  Write command\r\n"
+                        "te  ROMID        Read the temperature from a DS1820\r\n"
+                        "in  port         Read from a port\r\n"
+                        "out port val     Write to a port\r\n"
+                        "ddr port [val]   Read/write DDR for a port\r\n"));
 	    
 	return;
     }
@@ -247,37 +247,37 @@
 	uart_putsP(PSTR("Resetting... "));
 	    
 	if (OWTouchReset() == 1)
-	    uart_putsP(PSTR("No presence pulse found\n\r"));
+	    uart_putsP(PSTR("No presence pulse found\r\n"));
 	else
-	    uart_putsP(PSTR("Presence pulse found\n\r"));
+	    uart_putsP(PSTR("Presence pulse found\r\n"));
     } else if (cmd.buf[0] == 'r' && cmd.buf[1] == 'e') {
 	if (OWReadBit())
-	    uart_putsP(PSTR("Read a 1\n\r"));
+	    uart_putsP(PSTR("Read a 1\r\n"));
 	else
-	    uart_putsP(PSTR("Read a 0\n\r"));
+	    uart_putsP(PSTR("Read a 0\r\n"));
     } else if (cmd.buf[0] == 'r' && cmd.buf[1] == 'b') {
 	uart_putsP(PSTR("Read a 0x"));
 	uart_puts_hex(OWReadByte());
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
     } else if (cmd.buf[0] == 'w' && cmd.buf[1] == 'r') {
 	arg = strtol((char *)cmd.buf + 3, (char **)NULL, 10);
 	OWWriteBit(arg);
 	uart_putsP(PSTR("Wrote a "));
 	if (arg)
-	    uart_putsP(PSTR("1\n\r"));
+	    uart_putsP(PSTR("1\r\n"));
 	else
-	    uart_putsP(PSTR("0\n\r"));
+	    uart_putsP(PSTR("0\r\n"));
     } else if (cmd.buf[0] == 'w' && cmd.buf[1] == 'b') {
 	arg = (int)strtol((char *)cmd.buf + 3, (char **)NULL, 16); 
 	OWWriteByte(arg);
     } else if (cmd.buf[0] == 'r' && cmd.buf[1] == 't') {
 	if (cmd.len < 26) {
-	    uart_putsP(PSTR("Unable to parse ROM ID\n\r"));
+	    uart_putsP(PSTR("Unable to parse ROM ID\r\n"));
 	    return;
 	}
 
 	if (OWTouchReset() != 0) {
-	    uart_putsP(PSTR("No presence\n\r"));
+	    uart_putsP(PSTR("No presence\r\n"));
 	    return;
 	}
 
@@ -285,12 +285,12 @@
 	    ROM[i] = (int)strtol((char *)cmd.buf + 3 * (i + 1), (char **)NULL, 16);
 
 	if (ROM[0] != OW_FAMILY_ROM) {
-	    uart_putsP(PSTR("ROM specified isn't a DS2502\n\r"));
+	    uart_putsP(PSTR("ROM specified isn't a DS2502\r\n"));
 	    return;
 	}
 
 	if (OWTouchReset() != 0) {
-	    uart_putsP(PSTR("No presence\n\r"));
+	    uart_putsP(PSTR("No presence\r\n"));
 	    return;
 	}
 	
@@ -306,7 +306,7 @@
 	OWCRC(0x00, &crc);
 	
 	if (crc != OWReadByte()) {
-	    uart_putsP(PSTR("CRC mismatch on command & address\n\r"));
+	    uart_putsP(PSTR("CRC mismatch on command & address\r\n"));
 	    return;
 	}
 	
@@ -317,14 +317,14 @@
 	    OWCRC(temp, &crc);
 	    uart_putsP(PSTR(" "));
 	}
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
 	if (crc != OWReadByte()) {
-	    uart_putsP(PSTR("CRC mismatch on data\n\r"));
+	    uart_putsP(PSTR("CRC mismatch on data\r\n"));
 	    return;
 	}
     } else if (cmd.buf[0] == 'w' && cmd.buf[1] == 'e') {
 	if (cmd.len < 26) {
-	    uart_putsP(PSTR("Unable to parse ROM ID\n\r"));
+	    uart_putsP(PSTR("Unable to parse ROM ID\r\n"));
 	    return;
 	}
 
@@ -332,7 +332,7 @@
 	    ROM[i] = (int)strtol((char *)cmd.buf + 3 * (i + 1), (char **)NULL, 16);
 
 	if (ROM[0] != OW_FAMILY_ROM) {
-	    uart_putsP(PSTR("ROM specified isn't a ROM\n\r"));
+	    uart_putsP(PSTR("ROM specified isn't a ROM\r\n"));
 	    return;
 	}
 
@@ -341,17 +341,17 @@
 	buf[2] = (int)strtol((char *)cmd.buf + 33, (char **)NULL, 16);
 	
 	if (OWTouchReset() != 0) {
-	    uart_putsP(PSTR("No presence\n\r"));
+	    uart_putsP(PSTR("No presence\r\n"));
 	    return;
 	}
 
 	i = OWProgROM(ROM, buf[0], 2, &buf[1], 0, 0);
 	uart_putsP(PSTR("OWProgROM returned "));
 	uart_puts_dec(i, 0);
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
     } else if (cmd.buf[0] == 'r' && cmd.buf[1] == 'r') {
 	if (cmd.len < 26) {
-	    uart_putsP(PSTR("Unable to parse ROM ID\n\r"));
+	    uart_putsP(PSTR("Unable to parse ROM ID\r\n"));
 	    return;
 	}
 
@@ -359,7 +359,7 @@
 	    ROM[i] = (int)strtol((char *)cmd.buf + 3 * (i + 1), (char **)NULL, 16);
 
 	if (ROM[0] != OW_FAMILY_ROM) {
-	    uart_putsP(PSTR("ROM specified isn't a ROM\n\r"));
+	    uart_putsP(PSTR("ROM specified isn't a ROM\r\n"));
 	    return;
 	}
 
@@ -374,7 +374,7 @@
 	OWCRC(0x00, &crc);
 
 	if (crc != OWReadByte()) {
-	    uart_putsP(PSTR("CRC mismatch on command & address\n\r"));
+	    uart_putsP(PSTR("CRC mismatch on command & address\r\n"));
 	    return;
 	}
 
@@ -385,27 +385,27 @@
 		if (buf[0] % 16 != 0)
 		    uart_putsP(PSTR(" "));
 		else
-		    uart_putsP(PSTR("\n\r"));
+		    uart_putsP(PSTR("\r\n"));
 	    }
 	    
 	    uart_puts_hex(buf[1]);
 	    OWCRC(buf[1], &crc);
 	}
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
 	if (crc != OWReadByte()) {
-	    uart_putsP(PSTR("CRC mismatch on data\n\r"));
+	    uart_putsP(PSTR("CRC mismatch on data\r\n"));
 	    return;
 	}
 	
     } else if (cmd.buf[0] == 'w' && cmd.buf[1] == 'c') {
 	if (cmd.len < 5) {
-	    uart_putsP(PSTR("No arguments\n\r"));
+	    uart_putsP(PSTR("No arguments\r\n"));
 	    return;
 	}
 	    
 	arg = (int)strtol((char *)cmd.buf + 3, (char **)NULL, 16);
 	if (arg == 0) {
-	    uart_putsP(PSTR("Unparseable command\n\r"));
+	    uart_putsP(PSTR("Unparseable command\r\n"));
 	    return;
 	}
 
@@ -415,7 +415,7 @@
 	}
 	    
 	if (i < 29) {
-	    uart_putsP(PSTR("Can't parse ROM ID\n\r"));
+	    uart_putsP(PSTR("Can't parse ROM ID\r\n"));
 	    return;
 	}
 	for (i = 0; i < 8; i++)
@@ -424,7 +424,7 @@
 	OWSendCmd(ROM, arg);
     } else if (cmd.buf[0] == 't' && cmd.buf[1] == 'e') {
 	if (cmd.len < 26) {
-	    uart_putsP(PSTR("Unable to parse ROM ID\n\r"));
+	    uart_putsP(PSTR("Unable to parse ROM ID\r\n"));
 	    return;
 	}
 
@@ -432,7 +432,7 @@
 	    ROM[i] = (int)strtol((char *)cmd.buf + 3 * (i + 1), (char **)NULL, 16);
 
 	if (ROM[0] != OW_FAMILY_TEMP) {
-	    uart_putsP(PSTR("ROM specified isn't a temperature sensor\n\r"));
+	    uart_putsP(PSTR("ROM specified isn't a temperature sensor\r\n"));
 	    return;
 	}
 	    
@@ -451,7 +451,7 @@
 	}
 	    
 	if (crc != buf[8]) {
-	    uart_putsP(PSTR("CRC mismatch\n\r"));
+	    uart_putsP(PSTR("CRC mismatch\r\n"));
 	    return;
 	}
 	    
@@ -460,7 +460,7 @@
 	uart_puts_dec(temp >> 4, 0);
 	uart_putsP(PSTR("."));
 	uart_puts_dec((temp << 12) / 6553, 0);
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
 #else
 	/* 0	Temperature LSB
 	 * 1	Temperature MSB
@@ -475,7 +475,7 @@
 #if 0
 	for (i = 0; i < 9; i++) {
 	    uart_puts_dec(buf[i], 0);
-	    uart_putsP(PSTR("\n\r"));
+	    uart_putsP(PSTR("\r\n"));
 	}
 #endif
 	temp = buf[0];
@@ -500,7 +500,7 @@
 	    uart_puts_dec(temp, 0);
 	uart_putsP(PSTR("."));
 	uart_puts_dec(tfrac, 1);
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
 	    
 #endif
     } else if (cmd.buf[0] == 's' && cmd.buf[1] == 'r') {
@@ -510,15 +510,15 @@
 	do {
 	    switch (i) {
 		case OW_BADWIRE:
-		    uart_putsP(PSTR("Presence pulse, but no module found, bad module/cabling?\n\r"));
+		    uart_putsP(PSTR("Presence pulse, but no module found, bad module/cabling?\r\n"));
 		    break;
 
 		case OW_NOPRESENCE:
-		    uart_putsP(PSTR("No presence pulse found\n\r"));
+		    uart_putsP(PSTR("No presence pulse found\r\n"));
 		    break;
 		    
 		case OW_BADCRC:
-		    uart_putsP(PSTR("Bad CRC\n\r"));
+		    uart_putsP(PSTR("Bad CRC\r\n"));
 		    break;
 
 		case OW_NOMODULES:
@@ -526,7 +526,7 @@
 		    break;
 		    
 		default:
-		    uart_putsP(PSTR("Unknown error from 1 wire library\n\r"));
+		    uart_putsP(PSTR("Unknown error from 1 wire library\r\n"));
 		    break;
 	    }
 		
@@ -538,7 +538,7 @@
 		uart_putc(':');
 	    }
 	    uart_puts_hex(ROM[7]);
-	    uart_putsP(PSTR("\n\r"));
+	    uart_putsP(PSTR("\r\n"));
 
 	    i = OWNext(ROM, 1, 0);
 	} while (1);
@@ -561,12 +561,12 @@
 		break;
 		
 	    default:
-		uart_putsP(PSTR("Unknown port\n\r"));
+		uart_putsP(PSTR("Unknown port\r\n"));
 		return;
 	}
 	uart_putsP(PSTR("0x"));
 	uart_puts_hex(crc);
-	uart_putsP(PSTR("\n\r"));
+	uart_putsP(PSTR("\r\n"));
     } else if (cmd.buf[0] == 'o' && cmd.buf[1] == 'u') {
 	crc = strtol((char *)cmd.buf + 8, (char **)NULL, 16);
 	switch (tolower(cmd.buf[4])) {
@@ -587,12 +587,12 @@
 		break;
 		
 	    default:
-		uart_putsP(PSTR("Unknown port\n\r"));
+		uart_putsP(PSTR("Unknown port\r\n"));
 		return;
 	}
 	uart_putsP(PSTR("0x"));
 	uart_puts_hex(crc);
-	uart_putsP(PSTR("\n\r")); 
+	uart_putsP(PSTR("\r\n")); 
     } else if (cmd.buf[0] == 'd' && cmd.buf[1] == 'd') {
 	crc = strtol((char *)cmd.buf + 8, (char **)NULL, 16);
 	switch (tolower(cmd.buf[4])) {
@@ -613,19 +613,19 @@
 		break;
 		
 	    default:
-		uart_putsP(PSTR("Unknown port\n\r"));
+		uart_putsP(PSTR("Unknown port\r\n"));
 		return;
 	}
 	uart_putsP(PSTR("0x"));
 	uart_puts_hex(crc);
-	uart_putsP(PSTR("\n\r")); 
+	uart_putsP(PSTR("\r\n")); 
 #ifdef WITHUSB
     } else if (cmd.buf[0] == 'u' && cmd.buf[1] == 's') {
 	usb_gendata();
 #endif
     } else {
       badcmd:
-	uart_putsP(PSTR("Unknown command, ? for a list\n\r"));
+	uart_putsP(PSTR("Unknown command, ? for a list\r\n"));
     }
 }