rufeng
初级用户
积分 192
发帖 25
注册 2003-12-1
状态 离线
|
『楼 主』:
求高手帮助用msc7.0编译一个dos下plb
我下载了msc7.0,怎么也弄不好,因为以前没有用过。先谢谢了!以下是函数 。
******************************************************************************************************************
* Serial.C
* NMAKE PLBNAME=Serial MODEL=s /F Serial.mak
* MSC: _bios_serialcom Function
* The function returns a 16-bit integer whose high-order byte contains status bits.
* The meaning of the low-order byte varies, depending on the cmd value.
* The high-order bits [ Line Status Register (LSR) ]are as follows:
* Bit Meaning if Set
* 15 Timed out Error in Received FIFO
* 14 Transmission-shift register empty Empty Data Holding Registers (RxRDY)
* 13 Transmission-hold register empty Empty Transmitter Holding Register (TxRDY)
* 12 Break detected Break Interrupt
* 11 Framing error
* 10 Parity error
* 9 Overrun error
* 8 Data ready
* When service is _COM_INIT or _COM_STATUS, the low-order bits are defined as follows:
* Bit Meaning if Set
* 7 Receive-line signal detected
* 6 Ring indicator
* 5 Data-set-ready 0x20
* 4 Clear-to-send
* 3 Change in receive-line signal detected
* 2 Trailing-edge ring indicator
* 1 Change in data-set-ready status
* 0 Change in clear-to-send status
******************************************************************************************************************/
#include <bios.h>
#include <conio.h>
#include <pro_ext.h>
#define DTR 0x01 /* data terminal ready */
#define RTS 0x02 /* request to send */
#define DATA_READY 0x0100
#define SEND_READY 0x2000 /* UART ready for next char */
#define COMM_ERROR 0x9e00 /* Timed out | Break detected | Framing error | Parity error | Overrun error */
#define DATA_MASK 0xff
#define COM1 0 /* define Serial Port */
/******************************************************************************************************************
*
* Defines Serial Ports Base Address
*
* COM1 0x3F8
* COM2 0x2F8
* COM3 0x3E8
* COM4 0x2E8
*
******************************************************************************************************************/
#define UART_BASE 0x3F8
#define MCR_PORT ( UART_BASE+ 4 )
/******************************************************************************************************************
*
* Functions visible to FoxPro :
*
******************************************************************************************************************/
void FAR get_comm_device(ParamBlk FAR *param)
{
unsigned int com1_status ;
char init_device_string[ ] = "*01:2,04=00\'\r";
char device_info[] = " ";
char ch = ' ';
unsigned int i;
/* turn DTR and RTS off */
_outp( MCR_PORT,_inp( MCR_PORT ) & ~(DTR|RTS) );
/* initialize serial port at 9600 baud, 8 data bits,No parity, 1 stop bit */
com1_status = _bios_serialcom(_COM_INIT, COM1, _COM_9600|_COM_CHR8 | _COM_NOPARITY | _COM_STOP1);
/* capture current MCR and turn on DTR and RTS */
_outp( MCR_PORT,( _inp( MCR_PORT ) | (DTR|RTS) ) );
if (!( _bios_serialcom(_COM_STATUS, COM1, 0) & COMM_ERROR)){
/* Sending initialize string to device */
for(i=0;init_device_string[i];i++) {
/* loops until the char has been sent. {Polling} indicatd by Transmitter Holding Register was empty */
while(( _bios_serialcom(_COM_STATUS, COM1, 0) & SEND_READY)==0)
; /*do nothing */
com1_status = _bios_serialcom(_COM_SEND, COM1,init_device_string[i]);
}
for(i=0;device_info[i];i++) {
ch = ' ';
com1_status = _bios_serialcom(_COM_RECEIVE, COM1, 0);
if (!(com1_status & COMM_ERROR)) ch = com1_status & DATA_MASK;
device_info[i]= ch;
}
}
_RetChar(device_info);
}
FoxInfo myFoxInfo[] = {
{"GET_COMM_DEVICE", (FPFI) get_comm_device, 0, "" }
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
|
|