Trammell Hudson avatar Trammell Hudson committed 1868fc2 Draft

Strings version or raw dumper

Comments (0)

Files changed (1)

 	// "AT command", which can still be buffered.
 	usb_serial_flush_input();
 
-	// print a nice welcome message
-	send_str(PSTR("\r\nRTTY decoder\r\n"));
+#if 0
 
 	uint16_t addr = 0;
+	char line[64];
+	uint8_t off = 0;
 
 	while (1)
 	{
 		if (byte == 0)
 			continue;
 
-		char line[32];
-		uint8_t i = 0;
-		line[i++] = hexdigit(addr >> 12);
-		line[i++] = hexdigit(addr >>  8);
-		line[i++] = hexdigit(addr >>  4);
-		line[i++] = hexdigit(addr >>  0);
-		line[i++] = '=';
-		line[i++] = hexdigit(byte >> 4);
-		line[i++] = hexdigit(byte >> 0);
-		line[i++] = ' ';
-		line[i++] = printable(byte) ? byte : '.';
-		line[i++] = '\r';
-		line[i++] = '\n';
-		usb_serial_write(line, i);
+		if (off == 0)
+		{
+			line[off++] = hexdigit(addr >> 12);
+			line[off++] = hexdigit(addr >>  8);
+			line[off++] = hexdigit(addr >>  4);
+			line[off++] = hexdigit(addr >>  0);
+			line[off++] = '=';
+		}
+
+		if (printable(byte))
+		{
+			line[off++] = byte;
+			if (off < sizeof(line) - 2)
+				continue;
+		} else {
+			line[off++] = hexdigit(byte >> 4);
+			line[off++] = hexdigit(byte >> 0);
+		}
+
+		line[off++] = '\r';
+		line[off++] = '\n';
+		usb_serial_write(line, off);
+		off = 0;
 	}
+#else
+	uint16_t addr = 0;
+	while (1)
+	{
+		if (addr == 0)
+		{
+			// wait for input
+			while (!usb_serial_available())
+				continue;
+			while (usb_serial_available())
+				usb_serial_getchar();
+		}
+	
+		uint8_t byte = read_byte(addr++);
+		usb_serial_putchar(byte);
+	}
+#endif
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.