# HG changeset patch # User Daniel O'Connor # Date 1364993956 -37800 # Node ID 5b7d21698a8004a7c7637557b1cf69411ddd91fa # Parent 6466e8720e04c7884c793805b9ee6e61b4cf3b92 When writing to stdout/stderr translate \n to \r\n. diff -r 6466e8720e04 -r 5b7d21698a80 main.c --- a/main.c Tue Apr 02 14:49:50 2013 +1030 +++ b/main.c Wed Apr 03 23:29:16 2013 +1030 @@ -66,7 +66,7 @@ /* End of line? */ if (c == '\n' || c == '\r') { cmd.buf[cmd.state] = '\0'; - fputs("\r\n", stdout); + fputs("\n", stdout); cmd.len = cmd.state; cmd.state = 255; continue; @@ -101,7 +101,7 @@ cmd.state++; /* Over flow? */ if (cmd.state == LINEBUF - 1) { - fputs("\r\nLine too long", stdout); + fputs("\nLine too long", stdout); cmd.state = 0; continue; } @@ -129,7 +129,7 @@ /* Setup SysTick Timer rate, also enables Systick and Systick-Interrupt */ if (SysTick_Config(SystemCoreClock / TICK_FREQ)) { /* Capture error */ - comm_puts("Can't setup SysTick\r\n"); + comm_puts("Can't setup SysTick\n"); while (1) ; } @@ -138,7 +138,7 @@ setvbuf(stdout, NULL, _IONBF, 0); /* Say hello */ - fputs("\r\n\r\n\r\nHello world\r\n", stdout); + fputs("\n\n\nHello world\n", stdout); lcd_stripes(); @@ -189,11 +189,11 @@ now = time(NULL); gmtime_r(&now, &nowtm); strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S UTC", &nowtm); - printf("Time is %s (%d)\r\n", buf, (int)now); + printf("Time is %s (%d)\n", buf, (int)now); } else if (!strcmp("sc", argv[0])) { struct timeval tv; if (argc != 2) { - fputs("Incorrect number of arguments\r\n", stdout); + fputs("Incorrect number of arguments\n", stdout); goto out; } @@ -201,11 +201,11 @@ tv.tv_usec = 0; settimeofday(&tv, NULL); } else if (!strcmp("read", argv[0])) { - printf("PB5 = %d\r\n", GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)); + printf("PB5 = %d\n", GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)); } else if (!strcmp("touch", argv[0])) { for (int i = 0; i < 10; i++) { tp_getcoords(&x, &y, &z1, &z2, &t, &t2); - printf("X = %5d Y = %5d Z1 = %5d Z2 = %5d T = %7.2f T2 = %7.2f\r\n", x, y, z1, z2, t, t2); + printf("X = %5d Y = %5d Z1 = %5d Z2 = %5d T = %7.2f T2 = %7.2f\n", x, y, z1, z2, t, t2); } } else if (!strcmp("fl", argv[0])) { flashcmd(argc - 1, argv + 1); @@ -215,7 +215,7 @@ lcd_setpwm(atoi(argv[1])); } else if (!strcmp("circ", argv[0])) { if (argc != 5) { - fputs("Unable to parse circ args\r\n", stdout); + fputs("Unable to parse circ args\n", stdout); goto out; } x = atoi(argv[1]); @@ -225,7 +225,7 @@ lcd_circle(x, y, r, 0, c); } else if (!strncmp("ellip", cmd.buf, 6)) { if (argc != 5) { - fputs("Unable to parse ellip args\r\n", stdout); + fputs("Unable to parse ellip args\n", stdout); goto out; } @@ -238,7 +238,7 @@ lcd_ellipse(x, y, rx, ry, 0, c); } else if (!strncmp("line", cmd.buf, 5)) { if (argc != 5) { - fputs("Unable to parse line args\r\n", stdout); + fputs("Unable to parse line args\n", stdout); goto out; } @@ -258,7 +258,7 @@ } } else if (!strcmp("cyc", argv[0])) { if (argc != 2) { - fputs("Incorrect number of arguments\r\n", stdout); + fputs("Incorrect number of arguments\n", stdout); goto out; } @@ -266,9 +266,9 @@ delay(atoi(argv[1])); GPIO_ResetBits(GPIOE, GPIO_Pin_2); - fputs("Done\r\n", stdout); + fputs("Done\n", stdout); } else if (!strcmp("rs", argv[0])) { - printf("Reset got %d\r\n", OWTouchReset()); + printf("Reset got %d\n", OWTouchReset()); } else if (!strcmp("sr", argv[0])) { uint8_t ROM[8]; int8_t i; @@ -286,7 +286,7 @@ case OW_NOPRESENCE: case OW_BADCRC: default: - printf("Err %d\r\n", i); + printf("Err %d\n", i); break; } @@ -294,21 +294,21 @@ break; for (i = 0; i < 8; i++) - printf("%02x%s", ROM[i], i == 7 ? "\r\n" : ":"); + printf("%02x%s", ROM[i], i == 7 ? "\n" : ":"); i = OWNext(ROM, 1, 0); } while (1); } else if (!strcmp("rb", argv[0])) { - printf("Read bit returned %d\r\n", OWReadBit()); + printf("Read bit returned %d\n", OWReadBit()); } else if (!strcmp("wb", argv[0])) { if (argc != 2) { - fputs("Incorrect number of arguments\r\n", stdout); + fputs("Incorrect number of arguments\n", stdout); goto out; } x = atoi(argv[1]); OWWriteBit(x); - printf("Wrote %d\r\n", x); + printf("Wrote %d\n", x); } else if (!strcmp("te", argv[0])) { uint8_t ROM[8]; int16_t res; @@ -316,26 +316,26 @@ if (sscanf(argv[1], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &ROM[0], &ROM[1], &ROM[2], &ROM[3], &ROM[4], &ROM[5], &ROM[6], &ROM[7]) != 8) { - fputs("Unable to parse ROM ID\r\n", stdout); + fputs("Unable to parse ROM ID\n", stdout); goto out; } res = OWGetTemp(ROM); switch (res) { case OW_TEMP_WRONG_FAM: - printf("ROM specified isn't a temperature sensor\r\n"); + printf("ROM specified isn't a temperature sensor\n"); break; case OW_TEMP_CRC_ERR: - printf("CRC mismatch\r\n"); + printf("CRC mismatch\n"); break; case OW_TEMP_NO_ROM: - printf("No ROM found\r\n"); + printf("No ROM found\n"); break; default: - printf("%hd.%02hd\r\n", GETWHOLE(res), GETFRAC(res)); + printf("%hd.%02hd\n", GETWHOLE(res), GETFRAC(res)); break; } } else if (!strcmp("rtc", argv[0])) { @@ -347,17 +347,17 @@ d = RTC_PS2USEC(32768 - i); f = ((float)i * 1e6) / (float)RTC_PRESCALE; err = fabs(d - f); - //rtcprintf("i = %d, d = %d, f = %.3f, err = %.3f\r\n", i, d, f, err); + //rtcprintf("i = %d, d = %d, f = %.3f, err = %.3f\n", i, d, f, err); if (err > maxerr) maxerr = err; } - printf("Max err = %.3f\r\n", maxerr); + printf("Max err = %.3f\n", maxerr); } else if (!strcmp("assert", argv[0])) { assert(0 == 1); } else if (!strcmp("zz", argv[0])) { NVIC_SystemReset(); } else { - printf("Unknown command\r\n"); + printf("Unknown command\n"); } out: cmd.state = 0; diff -r 6466e8720e04 -r 5b7d21698a80 syscalls.c --- a/syscalls.c Tue Apr 02 14:49:50 2013 +1030 +++ b/syscalls.c Wed Apr 03 23:29:16 2013 +1030 @@ -115,9 +115,12 @@ _write(int file, char *ptr, int len) { int todo; - file = file; /* avoid warning */ for (todo = 0; todo < len; todo++) { - comm_put(*ptr++); + if (file == 1 || file == 2) + if (*ptr == '\n') + comm_put('\r'); + comm_put(*ptr); + ptr++; } return len; }