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

📄 main.c

📁 unix/linux下串口调试工具
💻 C
字号:
/******************************************************************************  SCT, Serial Communication Tracer  **  CopyRight (C)  Bruce (ZhaoFei), zhaofei@zflogic.com*  			        http://www.zflogic.com				**  All sources in the package are copyrighted under the the terms of GNU GPL******************************************************************************                                                                         *  This program is free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  This program is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  You should have received a copy of the GNU General Public License*  along with this program; if not, write to the Free Software*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA**  If you intend to use this pragram commercially on a regular basis you*  must contact the author for an appropriate donation.*                                                                       ***************************************************************************/#include "stdhdr.h"#include "util.h"#include "sct.h"#include "cmd.h"#include "ver.h"static	struct cmd_t sct_cmd[] = {	//stat	{"stat",	NULL, 	cmd_stat,	"stat - display current port status 				\	\n    usage: stat\n"	},		//sel	{"port",	"sel",	cmd_port,	"port - select a serial device as current port  		\	\n    usage: port device 					\	\n       eg: port /dev/ttyS0 \n"	},		//frame	{"frame",	"frameset", 	cmd_frame,	"frame - set frameset 						\	\n    usage: frame rate,parity,databits,stopbits 		\	\n       eg: frame 9600,n,8,1\n"	},		//handshake	{"handshake", 	"hs",	cmd_handshake,	"handshake - set handshake for port communication 		\	\n    usage: handshake [+/-] prototol				\	\n       eg: handshake +rts					\	\n       eg: handshake -xonxoff	        			\	\n       eg: handshake none\n"	},		//open	      			{"open",	NULL, 	cmd_open,	"open - open current port and active it 			\	\n    usage: open \n"	},		//close		{"close", 	NULL,	cmd_close,	"close - close current port and stop action 			\	\n    usage: close \n"	},		//term	{"term", 	"terminal",	cmd_term,	"term - enter terminal mode					\	\n    usage: term \n"	},		//echo	{"echo",	NULL, 	cmd_echo,	"echo - enter echo mode, reply all byte when received 		\	\n    usage: echo\n"	},		//setbuf	{"setbuf", 	NULL,	cmd_setbuf,	"setbuf - set buffer data,10 buffers can use inall		\	\n    usage: setbuf buffer_no input_form 			\	\n       eg: setbuf 1 asc 					\	\n             set data of buf1 as ascii char			\	\n       eg: setbuf 2 hex 					\	\n             set data of buf2 hex code \n"	},		//dispbuf		{"dispbuf",	NULL, 	cmd_dispbuf,	"dispbuf - display buffers' info or buffer's data 		\	\n    usage: dispbuf [buffer_no]				\	\n       eg: dispbuf 						\	\n             get infomation ablout all buffers		\	\n       eg: dispbuf 3			 			\	\n             display data of buffer 3 by both ascii and hex form\n"	},		//clrbuf		{"clrbuf",	NULL, 	cmd_clrbuf,	"clrbuf - clear the buffer					\	\n    usage: clrbuf buffer_no|all 				\	\n       eg: clrbuf 3						\	\n             clear buffer 3					\	\n       eg: clrbuf all                 			\	\n             clear all buffers\n"	},		//loadbuf		{"loadbuf",	NULL, 	cmd_loadbuf,	"loadbuf - load data to buffer from file 			\	\n    usage: loadbuf buffer_no filepath 			\	\n       eg: loadbuf 3 commu.dat				\	\n             load data to buffer 3 from file commu.dat\n"	},		//savebuf		{"savebuf",	NULL,	cmd_savebuf,	"savebuf - save data to file from buffer 			\	\n    usage: savebuf filepath buffer_no				\	\n       eg: savebuf commu.dat 3				\	\n             save data to file commu.dat from buffer 3 \n"	},		//copybuf		{"copybuf",	NULL,	cmd_copybuf,	"copybuf - copy buffer from one to another 			\	\n    usage: copybuf dest_buffer_no src_buffer_no 		\	\n       eg: copybuf 3 4 					\	\n             copy buffer 3 to buffer 4"	},		//recv		{"recv",	"recvbuf", 	cmd_recv,	"recv - recv data to buffer,10 buffers can use inall		\	\n    usage: recv bufffer_no 					\	\n       eg: recv 4 						\	\n             recv data to buffer 4\n"	},		//send		{"send", 	"sendbuf",	cmd_send,	"send - send buffer data,10 buffers can use inall 		\	\n    usage: send buffer_no 					\	\n       eg: send 1 						\	\n             send data from buffer 1\n"	},		//sendrecv	{"sendrecv",	NULL,	cmd_sendrecv,	"sendrecv - send and recv buffer data concurrently 		\	\n    usage: sendrecv send_buffer_no recv_buffer_no 		\	\n       eg: sendrecv 1 2					\	\n             send data from buffer 1 and recv data to buffer 2\n"	},#if 0		//sendfile	{"sendfile",	NULL,	cmd_sendfile,	"sendfile - send a file                                         \	\n   usage: sendfile filepath [protocol]                        \	\n      eg: sendfile abc.txt                                    \	\n  remark: default protocol is XMODEM\n" 					},		//recvfile	{"recvfile",	NULL,	cmd_recvfile,	"recvfile - receive a file					\	\n   usage: recvfile filepath [protocol]			\	\n      eg: recvfile abc.txt					\	\n  remark: default protocol is XMODEM\n"			},	//cd	{"cd",	NULL,	cmd_cd,	"cd - change current directory					\	\n   usage: cd dest_directory					\	\n	eg: cd /home/me/data\n"	},		//ls	{"ls",	"dir",	cmd_ls,	"ls - list contents or current directory			\	\n   usage: ls\n"	},#endif	{NULL, NULL, NULL, NULL}};int main(int argc , char **argv){						printf("--------------------------------------------------------\	      \n    Serial Communicatioin Tracer v%s  (GPL)		\	      \n                    <C> Bruce Zhao  zhaofei@zflogic.com	\	      \n            Welcom to visit http://www.zflogic.com  \	      \n                          LastBuild: %s,%s\	      \n--------------------------------------------------------\n", VERSION, __TIME__, __DATE__);	printf("\nLoad default set...   ");	load_deflcfg();	init_buf();	docmd("=>",sct_cmd);	update_deflcfg();	}

⌨️ 快捷键说明

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