⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recvmon.c

📁 This driver and utilities are published in form of source code under GNU General Public License in
💻 C
字号:
/*****************************************************************************//* recvmon.c								     *//* This is the linux Communication Test Program for Advantech PCL card * * This file is part of pclterm * copyright (c)2000 ,ADVANTECH Co,Ltd * * pclterm is free software;you can redistribute it and/or modify it * under the terms of version 2 of GNU General Public License as * published by the Free Software Foundation.*//*****************************************************************************/#include	"term.h"#define K_CR		0x0d#define K_LF		0x0a#define LEN		156/*****************************************************************************//* STATIC VARIABLES							     *//*****************************************************************************/static WINDOW	*wid;static int	y, x, rlen;static char	clearstr[81], rbuf[LEN];/*****************************************************************************//* global subroutine							     *//*****************************************************************************/void	recvmon_init(void);void	recvmon_end(void);void	recvmon_disp(int);/*****************************************************************************//*	MAIN FUNCTIONS							     *//*****************************************************************************/void	recvmon_init(){	int	i;	mw_cursor(0, 6);	printf("Received data monitor:\n");	wid = mw_wopen(0, 7, 79, 22);	mw_wcolor(wid, wid->norm_c);	mw_wcls(wid);	mw_wdrawbox(wid, L_SINGLE);	for ( i=0; i<80; i++ )	    clearstr[i] = ' ';	y = 8;	x = 1;	rlen = 0;}void	recvmon_disp(int flag){	char	ch, lflag=0, temp[81];	int	slen, i, j, k, sx;	if ( flag == 0 ) {	    if ( (i = read(SioFd, &rbuf[rlen], LEN - rlen)) <= 0 )		return;	    rlen += i;	    if ( rlen < LEN )		return;	}	sx = x;	slen = 0;	for ( i=0 ; i<rlen; i++ ) {	    ch = rbuf[i];	    if ( ch == K_CR ) {		lflag = 1;		if ( rbuf[i+1] == K_LF )		    i ++;	    } else if ( ch == K_LF ) {		lflag = 1;		if ( rbuf[i+1] == K_CR )		    i ++;	    } else if ( ch == K_TAB ) {		j = x;		x += 7;		x = (x / 8) * 8 + 1;		if ( x >= 79 )		    lflag = 1;		else {		    k = x - j;		    for ( j=0; j<k; j++ )			temp[slen++] =' ';		}	    } else {		temp[slen++] = ch;		x++;		if ( x >= 79 )		    lflag = 1;	    }	    if ( lflag == 1 ) {		mw_putstr_xy((uchar *)temp, slen, sx, y);		slen = 0;		sx = x = 1;		y++;		if ( y >= 22 )		    y = 8;		lflag = 0;		mw_putstr_xy((uchar *)clearstr, 78, 1, y);	    }	}	if ( slen != 0 && lflag == 0 )	    mw_putstr_xy((uchar *)temp, slen, sx, y);	rlen = 0;}void recvmon_end(){	recvmon_disp(1);	mw_wclose(wid);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -