summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tool/con.c33
-rwxr-xr-xtool/download.tcl6
2 files changed, 27 insertions, 12 deletions
diff --git a/tool/con.c b/tool/con.c
index 8522786..92014e5 100644
--- a/tool/con.c
+++ b/tool/con.c
@@ -1,4 +1,5 @@
1/* con device */ 1/* con device */
2/* vim: set noexpandtab sw=8 : */
2 3
3#include <signal.h> 4#include <signal.h>
4#include <stdio.h> 5#include <stdio.h>
@@ -14,24 +15,27 @@ void
14host(int fd) 15host(int fd)
15{ 16{
16 int cc; 17 int cc;
17 char buf[128]; 18 char buf;
19#ifndef HEX
20 char last = '\r';
21#endif
18 22
19 for (;;) { 23 for (;;) {
20 cc = read(fd, buf, sizeof buf); 24 cc = read(fd, &buf, 1);
21#ifdef HEX
22 if (cc < 0) 25 if (cc < 0)
23 break; 26 break;
24 for (int i = 0; i < cc; ++i) { 27 if (cc) {
28#ifdef HEX
25 char hex[3]; 29 char hex[3];
26 sprintf(hex, "%02X", (unsigned char) buf[i]); 30 sprintf(hex, "%02X", (unsigned char) buf);
27 write(1, hex, 2); 31 write(1, hex, 2);
28 }
29#else 32#else
30 if (cc > 0) 33 if (buf == '\n' && last != '\r')
31 write(1, buf, cc); 34 write(1, "\r", 1);
32 else if (cc < 0) 35 write(1, &buf, 1);
33 break; 36 last = buf;
34#endif 37#endif
38 }
35 } 39 }
36} 40}
37 41
@@ -57,6 +61,15 @@ user(int fd)
57 if (c == '.') 61 if (c == '.')
58 return; 62 return;
59 } 63 }
64#ifdef HEX
65 char hex[5];
66 sprintf(hex, "<%02X>", (unsigned char) c);
67 write(1, hex, 4);
68#endif
69#ifdef SEND_CRLF
70 if (c == '\n' && last != '\r')
71 write(fd, "\r", 1);
72#endif
60 write(fd, &c, 1); 73 write(fd, &c, 1);
61 last = c; 74 last = c;
62 } 75 }
diff --git a/tool/download.tcl b/tool/download.tcl
index c0dca55..96fc03b 100755
--- a/tool/download.tcl
+++ b/tool/download.tcl
@@ -14,11 +14,13 @@ if {$::argc > 1} {
14 14
15spawn tool/connect 15spawn tool/connect
16 16
17send "@[format %x [expr $core * 32768 / $wordsperline]]\n" 17set atline "@[format %x [expr $core * 32768 / $wordsperline]]"
18send "$atline\n"
19expect -ex "$atline\r\n"
18 20
19while {[gets stdin line] >= 0} { 21while {[gets stdin line] >= 0} {
20 send "$line\n" 22 send "$line\n"
21 expect -ex "$line\n" 23 expect -ex "$line\r\n"
22} 24}
23 25
24# It's likely we ended with a very large zero-memory operation. We want to see 26# It's likely we ended with a very large zero-memory operation. We want to see