User`s guide

102 IRSEND and IRECV Files
MX1 Reference Guide E-EQ-MX1RG-D
//delay_ms(2000);
start = clock();
status = 0;
while (status >= 0) {
if (stopExec())
break;
putchar('|');
count = read(fh, buf, sizeof(buf));
if (! count) {
fprintf(stderr, "\nsend complete\n");
break;
}
if (count == -1) {
fprintf(stderr, "\nreading %s error\n", argv[1]);
break;
}
/* send data */
for (c = buf, i = 0; i < count; i++, bytesSend++) {
//while (_bios_serialcom(_COM_STATUS, comPort, 0) < 0){;}
/* send a char */
if ((status = _bios_serialcom(_COM_SEND, comPort, *c++)) < 0) {
fprintf(stderr, "\nsend error %x\n", status);
break;
}
if (! (bytesSend & 0x00ff))
putchar('.');
}
}
start = clock() - start;
fprintf(stderr, "\n%lu ms\n", start);
fprintf(stderr, "send %lu bytes\n", bytesSend);
#if 0
// close 5 second later
start = clock() + 5000;
while (1) {
tmp = clock();
if (tmp > start)
break;
}
#endif
close(fh);
CLOSE_CONN:
/* close connection */
__asm {
mov ax, 0ffffH
mov dx, comPort
int 14H
mov status, ax
}
if (status < 0) {/* cannot disconnection */
fprintf(stderr, "disconection failured, status %x\n", status);
}
}