我正在从事与DOS相关的项目。我想使用C从DOS的串行端口读取数据。
答案 0 :(得分:1)
我记得过去曾经使用过一种叫做Async Pro的产品。如果我没记错的话,它提供了可在Turbo Pascal中链接的库。
答案 1 :(得分:1)
#include <sdio.h>
#include <bios.h>
#define com1 0
#define settings (0xE3)
main ( )
{ /* declare PORTA and DOUT as integer numbers */
int PORTA,DOUT ;
/* set DOUT to integer 255 */
DOUT=255;
/* configure com1 9600 baud, 8 bit words, no parity */
bioscom (0,settings,com1);
/* send CPA00000000 command to ADR101 on com1 */
fprintf (stdaux,"CPA00000000 \xD");
/* send MAddd (ddd=DOUT) command to ADR101 on com1 */
fprintf (stdaux,"MA %d \xD",DOUT );
/* send PA command to ADR101 on com1 */
fprintf (stdaux,"PA \xD");
/* initialize com1 buffer */
fscanf (stdaux,"%d",&PORTA );
/* print data on screen */
rewind (stdaux);
/* read data from com1 and store at address of PORTA */
printf ("PORT A is %d DECIMAL \n",PORTA);
}