1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/*
* Copyright 1996, 1997, 1998, 1999 by Daniel B. Suthers,
* Pleasanton Ca. 94588 USA
* E-MAIL dbs@tanj.com
*
* You may freely copy, use, and distribute this software,
* in whole or in part, subject to the following restrictions:
*
* 1) You may not charge money for it.
* 2) You may not remove or alter this copyright notice.
* 3) You may not claim you wrote it.
* 4) If you make improvements (or other changes), you are requested
* to send them to me, so there's a focal point for distributing
* improved versions.
*
*/
#include <stdio.h>
#include <ctype.h>
#include "x10.h"
#include <time.h>
#include <unistd.h>
#ifdef LINUX
#include <asm/ioctls.h>
#include <linux/serial_reg.h>
#include <linux/serial.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <syslog.h>
#else
#include <sys/termios.h>
#endif
extern int verbose;
extern int sptty;
extern int lockpid(), ttylock(), munlock();
/* This process echoes all strings to the spool file as well as
* sending them to the CM11A's tty port
*/
int xwrite( tty, buf, size)
int tty;
char *buf;
int size;
{
char lbuf[160];
unsigned int ri_stat;
int max = 0;
extern int lock_for_write();
lbuf[1] = lbuf[2] = lbuf[0] = 0xff;
lbuf[3] = size;
write( sptty, lbuf , 4);
write( sptty, buf, size);
ri_stat = 0;
while ( (ri_stat != 6) && (max++ < 5000) )
ioctl(tty, TIOCMGET, &ri_stat);
max = -1;
if( lock_for_write() == 0 )
{
max = write( tty, buf, size);
munlock("heyu.write");
}
return(max);
}
|