aboutsummaryrefslogtreecommitdiffstats
path: root/tools/abcprintd.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-06 21:47:00 -0800
committerH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-06 21:47:00 -0800
commit53acd7741afbf5be3e2b2042ce5ff085e90ebec8 (patch)
tree7ffbea13dc24386055a89a39ee906ea889e1d03d /tools/abcprintd.c
parent9a543f3c52184488f5c9451298130afc124e8ccc (diff)
downloadabc80-53acd7741afbf5be3e2b2042ce5ff085e90ebec8.tar.gz
abc80-53acd7741afbf5be3e2b2042ce5ff085e90ebec8.tar.xz
abc80-53acd7741afbf5be3e2b2042ce5ff085e90ebec8.zip
Snapshot the file operations work
Snapshot the file operations work. Basic block download now works (I'm even testing this by downloading new versions of printer.bin via a small BASIC stub.) "turbo mode" (460800 bps) doesn't seem to work, however, not really sure why. Not that it really matters. Plenty of more work to be done, though.
Diffstat (limited to 'tools/abcprintd.c')
-rw-r--r--tools/abcprintd.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/abcprintd.c b/tools/abcprintd.c
index 15ff502..554b4eb 100644
--- a/tools/abcprintd.c
+++ b/tools/abcprintd.c
@@ -27,6 +27,13 @@
#include <sys/wait.h>
#include <fcntl.h>
+#ifndef O_TEXT
+# define O_TEXT 0
+#endif
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
static int lpr_argc;
static const char **lpr_argv;
@@ -70,13 +77,13 @@ static void print_setup(FILE **tfp, enum print_state *psp)
*psp = ps_first;
}
-static int open_port(const char *path)
+static int open_port(const char *path, speed_t speed)
{
struct termios tio;
int fd;
int flags;
- if ( (fd = open(path, O_RDWR|O_NONBLOCK)) < 0 )
+ if ( (fd = open(path, O_RDWR|O_NONBLOCK|O_BINARY)) < 0 )
return -1;
if ( tcgetattr(fd, &tio) )
@@ -96,8 +103,9 @@ static int open_port(const char *path)
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0;
- cfsetispeed(&tio, B115200);
- cfsetospeed(&tio, B115200);
+
+ cfsetispeed(&tio, speed);
+ cfsetospeed(&tio, speed);
tcflush(fd, TCIFLUSH);
@@ -194,14 +202,18 @@ int main(int argc, char *argv[])
extern char *optarg;
extern int optind, opterr, optopt;
bool badopt = false;
+ speed_t speed = B115200;
file_op_dir = NULL;
- while ((o = getopt(argc, argv, "d:")) != EOF) {
+ while ((o = getopt(argc, argv, "d:t")) != EOF) {
switch (o) {
case 'd':
file_op_dir = optarg;
break;
+ case 't':
+ speed = B460800;
+ break;
default:
badopt = true;
break;
@@ -210,12 +222,15 @@ int main(int argc, char *argv[])
if ( badopt || optind >= argc ) {
fprintf(stderr,
- "Usage: %s [options] port lpr_program [lpr_args...]]\n",
+ "Usage: %s [options] port lpr_program [lpr_args...]]\n"
+ "Options:\n"
+ " -d dir enable file access to directory dir\n"
+ " -t turbo mode (460800 bps)\n",
argv[0]);
exit(1);
}
- if ( (fd = open_port(argv[optind])) < 0 ) {
+ if ( (fd = open_port(argv[optind], speed)) < 0 ) {
perror(argv[optind]);
exit(1);
}