User`s guide

104 IRSEND and IRECV Files
MX1 Reference Guide E-EQ-MX1RG-D
if (argc <= 1) {
fprintf(stderr, "enter a filename.\n");
return;
}
#if 0
/* comPort 0 for COMM1 */
if (((status = _bios_serialcom(_COM_STATUS, comPort, 0)) < 0)) {
fprintf(stderr, "IrPlus does not exit, status %x\n", status);
return;
}
#endif
fh = -1;
if (_dos_creat((const char *)argv[1], _A_NORMAL, &fh) != 0) {
fprintf(stderr, "cannot create a file %s\n", argv[1]);
return;
}
if (fh < 0){
fprintf(stderr, "cannot open a file %s\n", argv[1]);
return;
}
/* open connection */
fprintf(stderr, "connecting...\n");
__asm {
mov ax, 0fffeH
mov dx, comPort
int 14H
mov status, ax
}
if (status < 0) { /* cannot open connection */
close(fh);
fprintf(stderr, "connection timeout\n");
goto CLOSE_CONN; //return;
}
else
fprintf(stderr, "write to file %s\n", argv[1]);
/* read data */
for (i = 0, c = buf; (1); bytesRecvd++) {
#if 1
if (stopExec())
break;
#endif
if (! (bytesRecvd & 0x00ff))
putch('.');
status = _bios_serialcom(_COM_RECEIVE, comPort, 0);
if (status < 0)
{ /* timeout */
if (i) {
putch('|');
if (_dos_write(fh, buf, i, &writen) != 0)
fprintf(stderr, "\nwrite file error3\n");
else {
if (i != writen)
fprintf(stderr, "\nwrite file error4\n");
}
}
break;
}