65 lines
1.4 KiB
C
65 lines
1.4 KiB
C
/*
|
|
T_ATIM.C - Test the attached timer a bit
|
|
|
|
Written by John, February 1992
|
|
*/
|
|
|
|
#include <p_std.h>
|
|
#include <p_file.h>
|
|
#include <epoc.h>
|
|
|
|
LOCAL_C VOID panic(
|
|
INT num,
|
|
INT errno)
|
|
{
|
|
UBYTE b[100];
|
|
|
|
p_errs(&b[p_atos(&b[0],"panic num %d - ",num)],errno);
|
|
t_panic(&b[0]);
|
|
}
|
|
|
|
GLDEF_C main(VOID)
|
|
{
|
|
UWORD len;
|
|
WORD stat;
|
|
INT ret;
|
|
UBYTE *pcb;
|
|
ULONG timeout;
|
|
UBYTE bb[10];
|
|
GLREF_D P_DEVICE p_wind,p_file;
|
|
|
|
p_inst(&p_wind,&p_file,NULL_D);
|
|
if (ret=p_loadldd("ATIMDVR.LDD"))
|
|
panic(1,ret);
|
|
if (ret=p_open(&pcb,"TTY:A"))
|
|
panic(2,ret);
|
|
if (ret=p_open(&pcb,"ATM:",0))
|
|
panic(3,ret);
|
|
timeout=50L; /* 5 second timeout */
|
|
if (ret=p_iow(pcb,P_FSET,&timeout))
|
|
panic(4,ret);
|
|
|
|
/*
|
|
Once the device driver hierarchy has been set up the I/O requests are
|
|
identical between a driver with and a driver without an attached timeout
|
|
driver, except of course that the attached timeout driver will not wait
|
|
forever if no characters can be read.
|
|
*/
|
|
len=10;
|
|
p_ioc(pcb,P_FREAD,&stat,&bb[0],&len);
|
|
p_iow(pcb,P_FCANCEL);
|
|
p_waitstat(&stat);
|
|
if (stat!=E_FILE_CANCEL)
|
|
panic(5,stat);
|
|
if ((ret=p_read(pcb,&bb[0],10))!=E_FILE_INACT)
|
|
panic(6,ret); /* times out after 5 seconds */
|
|
|
|
|
|
p_close(pcb);
|
|
p_close(pcb);
|
|
if (ret=p_devdel("ATM",E_LDD))
|
|
panic(7,ret);
|
|
return(0);
|
|
}
|
|
|