* [9fans] telco tweaks
@ 1998-09-07 0:57 Scott
0 siblings, 0 replies; only message in thread
From: Scott @ 1998-09-07 0:57 UTC (permalink / raw)
Hi all,
Here's a little hack to telco to give it "remote" and "status"
files. Originally I was thinking about having the status file pause
the conversation, send a +++, send a modem-specific query string, and
return the status that way, but I wasn't sure it could be made to work
reliably, so I ended up just returning the connect string, which is
useful enough since it tells you if you really got a V.90 connection or
not. :-)
I really wish modems had a nice way to report status. For instance,
they could have a second serial port, or use ethernet. In fact, they
should run Inferno, so we could mount them directly.
Anyway, here's the diff of telco.c against the cdrom.
48a49,50
> enum { MSGSIZE=64 };
>
60a63,64
> char status[MSGSIZE];
> char remote[MSGSIZE];
88a93,94
> Qstatus= 6,
> Qremote= 7,
105a112,113
> [Qstatus] "status",
> [Qremote] "remote",
150a159,175
> { "USR Courier", "ati3", "Courier", 0,
> 0,0,0,0,0,0
> },
> { "Telebit", 0, 0, 0,
> "ATS180=2\rATS181=1", /* V.42 error control with detection phase */
> "ATS190=1", /* compression allowed */
> "ATS58=2\rATS68=255", /* CTS/RTS flow control */
> "ATS51=253\rATS50=0", /* automatic modulation speed determination */
> 0, /* can't do fax */
> "ATS61=0\rATS63=0" /* pass break thru */
>
> },
> {
> "T1600", "ATI3", "T1600", "Telebit",
> 0,0,0,0,0,0
> },
>
253c278
< int maxspeed = 56000;
---
> int maxspeed = 115200;
275a301,304
> void status_connected(Dev *, char *);
> void status_closed(Dev *);
> void status_dialing(Dev *, char *);
> char *get_connect_msg(char *);
487a517,522
> case 2:
> d->qid.path = MKQID(Qremote, DEV(q));
> break;
> case 3:
> d->qid.path = MKQID(Qstatus, DEV(q));
> break;
665a701,705
> case Qstatus:
> case Qremote:
> if(mode==OWRITE || mode==ORDWR)
> return Eperm;
> break;
690a731,745
> static int
> outbuf(long off, int i, int cnt, char *obuf, char *ibuf)
> {
> int n;
>
> if(off < i){
> n = cnt;
> if(off + n > i)
> n = i - off;
> memmove(obuf, ibuf + off, n);
> } else
> n = 0;
> return n;
> }
>
698a754
> char msg[MSGSIZE];
706a763
> d = &dev[DEV(f->qid)];
720a778,779
> n = outbuf(off, i, cnt, buf, num);
> /*
727a787
> */
728a789,799
> case Qremote:
> i = snprint(msg, MSGSIZE, "%s\n",
> d->open ? d->remote : "-");
> n = outbuf(off, i, cnt, buf, msg);
> break;
> case Qstatus:
> i = snprint(msg, MSGSIZE, "telco/%d 1 %s\n",
> DEV(f->qid),
> d->open ? d->status : "Closed");
> n = outbuf(off, i, cnt, buf, msg);
> break;
730d800
< d = &dev[DEV(f->qid)];
766a837,839
> case Qremote:
> case Qstatus:
> return Eperm;
819a893
> status_closed(d);
1006a1081,1082
> if (p == &buf[127])
> return Failure;
1064c1140
< int portspeed[] = { 56000, 38400, 19200, 14400, 9600, 4800, 2400, 1200, 600, 300, 0 };
---
> int portspeed[] = { 230400, 115200, 56000, 38400, 19200, 14400, 9600, 4800, 2400, 1200, 600, 300, 0 };
1343a1420
> status_dialing(d, number);
1349c1426,1427
< switch(readmsg(d, 120, 0)){
---
> switch(readmsg(d, 120, "CONNECT")){
> case Found:
1350a1429
> status_connected(d, get_connect_msg(d->msgbuf));
1352a1432
> status_closed(d);
1355a1436
> #ifdef notdef
1359c1440
<
---
> #endif
1514a1596,1607
> * get the message after CONNECT
> */
> char *
> get_connect_msg(char *msg)
> {
> char *p = msg + sizeof("CONNECT") - 1;
> while (*p == ' ' || *p == '\t')
> p++;
> return p;
> }
>
> /*
1526a1620,1643
> }
>
> /*
> *
> */
>
> void
> status_connected(Dev *d, char *msg)
> {
> snprint(d->status, MSGSIZE, "%s %s", "Established", msg);
> }
>
> void
> status_closed(Dev *d)
> {
> snprint(d->status, MSGSIZE, "%s", "Closed");
> snprint(d->remote, MSGSIZE, "");
> }
>
> void
> status_dialing(Dev *d, char *addr)
> {
> snprint(d->status, MSGSIZE, "%s", "Dialing");
> snprint(d->remote, MSGSIZE, "%s", addr);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-09-07 0:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-07 0:57 [9fans] telco tweaks Scott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).