sio_Close(Port);//关闭串口 port 是 1,2,3……
sio_open(Port);//打开串口
sio_ioctl(Port,B19200,P_NONE+BIT_8+STOP_1);//设置波特率,数据位,停止位
sio_flush(Port,2);
while not Terminated do
begin
if FPause then
begin
Application.ProcessMessages;
Sleep(10);
Continue;
end;
try begin
DataLen := sio_iqueue(Port);//读串口中队列数据长度
if DataLen>0 then
begin
CurByte := sio_getch(port);//从串口读一个字符
implementation
function sio_open; external 'PComm.dll';
function sio_close; external 'PComm.dll';
function sio_ioctl; external 'PComm.dll';
function sio_flowctrl; external 'PComm.dll';
function sio_flush; external 'PComm.dll';
function sio_DTR; external 'PComm.dll';
function sio_RTS; external 'PComm.dll';
function sio_lctrl; external 'PComm.dll';
function sio_baud; external 'PComm.dll';
function sio_getch; external 'PComm.dll';
function sio_read; external 'PComm.dll';
function sio_linput; external 'PComm.dll';
function sio_putch; external 'PComm.dll';
function sio_putb; external 'PComm.dll';
function sio_write; external 'PComm.dll';
function sio_putb_x; external 'PComm.dll';
function sio_putb_x_ex; external 'PComm.dll';
function sio_lstatus; external 'PComm.dll';
function sio_iqueue; external 'PComm.dll';
function sio_oqueue; external 'PComm.dll';
function sio_Tx_hold; external 'PComm.dll';
function sio_getbaud; external 'PComm.dll';
function sio_getmode; external 'PComm.dll';
function sio_getflow; external 'PComm.dll';
function sio_data_status; external 'PComm.dll';
function sio_term_irq; external 'PComm.dll';
function sio_cnt_irq; external 'PComm.dll';
function sio_modem_irq; external 'PComm.dll';
function sio_break_irq; external 'PComm.dll';
function sio_Tx_empty_irq; external 'PComm.dll';
function sio_break; external 'PComm.dll';
function sio_view; external 'PComm.dll';
function sio_TxLowWater; external 'PComm.dll';
function sio_AbortWrite; external 'PComm.dll';
function sio_AbortRead; external 'PComm.dll';
function sio_SetWriteTimeouts; external 'PComm.dll';
function sio_GetWriteTimeouts; external 'PComm.dll';
function sio_SetReadTimeouts; external 'PComm.dll';
function sio_GetReadTimeouts; external 'PComm.dll';
function sio_FtASCIITx; external 'PComm.dll';
function sio_FtASCIIRx; external 'PComm.dll';
function sio_FtXmodemCheckSumTx; external 'PComm.dll';
function sio_FtXmodemCheckSumRx; external 'PComm.dll';
function sio_FtXmodemCRCTx; external 'PComm.dll';
function sio_FtXmodemCRCRx; external 'PComm.dll';
function sio_FtXmodem1KCRCTx; external 'PComm.dll';
function sio_FtXmodem1KCRCRx; external 'PComm.dll';
function sio_FtYmodemTx; external 'PComm.dll';
function sio_FtYmodemRx; external 'PComm.dll';
function sio_FtZmodemTx; external 'PComm.dll';
function sio_FtZmodemRx; external 'PComm.dll';
function sio_FtKermitTx; external 'PComm.dll';
function sio_FtKermitRx; external 'PComm.dll';