aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2014-05-14 21:52:01 -0700
committerH. Peter Anvin <hpa@zytor.com>2014-05-14 21:53:17 -0700
commit002a8c757003dd7e67d79ba6c420b7a377b23221 (patch)
treed6be098659d6d5dc09aa9d2ec3aa4f4973e9799d
parentfbd3070fba255b7ec16fd8eb91abd3156916bb63 (diff)
downloadabc80-002a8c757003dd7e67d79ba6c420b7a377b23221.tar.gz
abc80-002a8c757003dd7e67d79ba6c420b7a377b23221.tar.xz
abc80-002a8c757003dd7e67d79ba6c420b7a377b23221.zip
abcprintd: add support for debug messages
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--tools/abcprint.txt10
-rw-r--r--tools/abcprintd.c27
2 files changed, 32 insertions, 5 deletions
diff --git a/tools/abcprint.txt b/tools/abcprint.txt
index acd64d3..d63c367 100644
--- a/tools/abcprint.txt
+++ b/tools/abcprint.txt
@@ -58,3 +58,13 @@ FF A9 ss xxxx CLOSE ALL NO REPLY
All files are closed and forgotten. xxxx ignored.
No response token is sent.
+
+Debug console
+-------------
+
+FF C0 .... 00
+
+ Text between FF C0 and terminating 00 are written out on
+ stdout for abcprintd if the -c option was given. Intended to
+ be used for debugging messages.
+
diff --git a/tools/abcprintd.c b/tools/abcprintd.c
index 04a2590..832d9f0 100644
--- a/tools/abcprintd.c
+++ b/tools/abcprintd.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
+ * Copyright 2004-2014 H. Peter Anvin - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -154,7 +154,6 @@ static void output(int c, FILE *tf, enum print_state *psp)
return;
} else {
*psp = ps_text;
- // fwrite(text_prefix, 1, sizeof text_prefix - 1, tf);
}
output(c, tf, psp);
break;
@@ -164,7 +163,6 @@ static void output(int c, FILE *tf, enum print_state *psp)
*psp = ps_binary;
} else {
*psp = ps_text;
- // fwrite(text_prefix, 1, sizeof text_prefix - 1, tf);
}
output('%', tf, psp);
output(c, tf, psp);
@@ -194,6 +192,7 @@ int main(int argc, char *argv[])
st_normal, /* Normal operation */
st_ff, /* 0xFF received */
st_file, /* File operation in progress */
+ st_cons, /* Console output in progress */
} state;
char ibuf[BUF_SIZE];
unsigned char c;
@@ -204,6 +203,7 @@ int main(int argc, char *argv[])
extern char *optarg;
extern int optind, opterr, optopt;
bool fg = false;
+ bool console = false;
bool badopt = false;
speed_t speed = B115200;
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
fileops = false;
- while ((o = getopt(argc, argv, "fd:")) != EOF) {
+ while ((o = getopt(argc, argv, "fd:c")) != EOF) {
switch (o) {
case 'd':
if (chdir(optarg)) {
@@ -224,6 +224,9 @@ int main(int argc, char *argv[])
case 'f':
fg = true;
break;
+ case 'c':
+ console = true;
+ break;
default:
badopt = true;
break;
@@ -236,6 +239,7 @@ int main(int argc, char *argv[])
"Options:\n"
" -f run in the foreground\n"
" -d dir enable file access to directory dir\n"
+ " -c enable debug console output\n"
,
argv[0]);
exit(1);
@@ -259,7 +263,7 @@ int main(int argc, char *argv[])
}
if (!fg)
- daemon(fileops,0);
+ daemon(fileops, console);
print_setup(&tf, &ps);
@@ -289,6 +293,9 @@ int main(int argc, char *argv[])
} else if ( c >= 0xa0 && c <= 0xbf ) {
/* Opcode range reserved for file ops */
state = file_op(c, fd) ? st_file : st_normal;
+ } else if ( c == 0xc0 ) {
+ /* Debug console output */
+ state = st_cons;
} else {
output(c, tf, &ps);
state = st_normal;
@@ -298,6 +305,16 @@ int main(int argc, char *argv[])
case st_file:
state = file_op(c, fd) ? st_file : st_normal;
break;
+
+ case st_cons:
+ if ( c == 0x00 ) {
+ if (console)
+ fflush(stdout);
+ state = st_normal;
+ } else if (console) {
+ putchar(c);
+ }
+ break;
}
}
}