SECTION 2
Supporting DOS Applications
PEN*KEY
R
6200/6300 Hand-Held Computer Programmer’s Reference Guide 2-27
// and ioargs.ioctl_buf
FILE *modem;
int
hndl;
// do DOS IOCTL_IN CALL. Inline assembler works for Microsoft C.
// Other C compilers may support IOCTL directly.
void Ioctl(int handle, IOARGS *args, UI len)
{
_asm
{
mov
cx,len
; cx is the length of the buffer
mov
bx,handle
; bx is the file handle
mov
dx,args
; dx is the pointer to our IOARGS buffer
mov
ax,4402h
; 4402h is the DOS function to call
int
21h
; this is the DOS software interrupt call
}
}
// print a buffer
void printbuf()
{
int i;
for (i = 0; i < 64; i++ ) {
printf (“%2.2x ”,buffer[i]);
if (i % 16 == 0) printf (“\n”);
}
printf(“\n”);
}
// get manufacturer’s ID
void GetMfgId()
{
buffer[0] = GET_MFGID;
// insert the command
Ioctl(hndl,&ioargs,63);
printf(“mfgid = \n”);
// display the returned data
printbuf();
}
// get the product information
#define GET_PRODINFO
void GetProdInfo()
{
buffer[0] = GET_PRODINFO;
// insert the command
Ioctl(hndl,&ioargs,63);
printf(“prodinfo = \n”);
// display the returned data
printbuf();
}
// get the command line parameters
void GetDriverParms()
{
buffer[0] = GET_DRIVER_PARMS;
// insert the command
Ioctl(hndl,&ioargs,63);
printf(“driverparms = \n”);
// display the returned data
printbuf();
}
void main()
{
ioargs.ioctl_cmd = &buffer[0];
// assign pointer to cmd buffer
ioargs.ioctl_buf = &buffer[1];
// assign pointer to argument buffer
// open the driver;
// this applies power to the modem and initializes the PC Card.
if ((modem = fopen(“MODEM”,“r+”)) == NULL) {
2. DOS
Applications