CommErrEvnt

エラー割り込み(evErr)を使用して、エラーを内容を表示確認する為の例です

var

msg: string;

ShowOff evErr で、通常のCommErrEvnt 例

procedure TForm1.Comm1CommEvent(Sender: TObject; ErrCode: Cardinal);

begin

ErrDisp(ErrCode);

end;

procedure TForm1.ErrDisp(ErrorCode: cardinal);

begin

msg := '';

if (ErrorCode and CE_RXOVER) <> 0 then msg := '受信バッファオーバーフロー, ';

if (ErrorCode and CE_OVERRUN) <> 0 then msg := msg + '受信オーバーラン, ';

if (ErrorCode and CE_RXPARITY) <> 0 then msg := msg + '受信パリティエラー, ';

if (ErrorCode and CE_FRAME) <> 0 then msg := msg + '受信フレーミングエラー, ';

if (ErrorCode and CE_BREAK) <> 0 then msg := msg + 'ブレーク検出, ';

if (ErrorCode and CE_TXFULL) <> 0 then msg := msg + '送信バッファフル, ';

if (ErrorCode and CE_IOE) <> 0 then msg := msg + 'I/Oデバイスエラー, ';

if (ErrorCode and CE_MODE) <> 0 then msg := msg + '指定モード無し, ';

if (FErrorCode and CE_SENDTIMOEUT) <> 0 then msg := msg + '送信タイムアウト, ';

if (FErrorCode and CE_READTIMOEUT) <> 0 then msg := msg + '受信タイムアウト, ';

{

******* Win95 only parallel device *********

if (ErrorCode and CE_PTO) <> 0 then msg := msg + 'LPTx TimeOut, ';

if (ErrorCode and CE_DNS) <> 0 then msg := msg + 'LPTx Device Not Selected, ';

if (ErrorCode and CE_OOP) <> 0 then msg := msg + 'LPTx Out-Of-Paper, ';

}

if msg = '' then msg := 'Unknown error'

else msg := Copy(msg, 1, Length(msg) - 2); // -2 は最後の ', '

Application.MessageBox(@msg'Look',MB_OK);

end;

ブレークを検出する場合は、CE_BREAKの検出ルーチンを別途設定してください。

if (FErrorCode and CE_BREAK) <> 0 then **********

evErrによるCommErrEvnt使用時はCommEventBreak受信よる割り込みは発生しません、注意してください。