PjComm:控制台版本的串口调试助手

PjComm是一款简单的C#控制台应用,用于串口调试。它支持自动打开和关闭串口,具备热键功能,并在发送数据时确保串口处于打开状态。程序默认配置为com1,波特率115200,数据位8,停止位1,无校验。串口信息会保存到文件中。文章提供了下载链接和源代码,适用于学习C#串口通信的开发者。
摘要由CSDN通过智能技术生成

为了学习C#,所以,自己动手,开发了一个小小的控制台版本的串口调试助手PjComm,截图如下:

上图中的蓝色背景的字符,为热键。在使用SendData时,若串口没有打开,则自动打开。若已经打开,会暂时关闭串口。

默认的串口设置参数是com1,115200,8,1,none。

整个窗口的第0-18行为串口信息显示行,每当显示完一屏幕之后,会自动将屏幕的内容保存至文件,并清屏继续显示。

下载地址:

【网通】点击下载PjComm,控制台版本的串口调试助手

【电信、网通】点击下载PjComm,控制台版本的串口调试助手

【下载说明】
1、单击上面这个地址,打开下载页面。
2、点普通下载--等待30秒--点“下载”按钮--保存

以上下载的为SharpDevelop 2.2的工程文件,若没有安装SHarpDevelop,请到这里下载。若没有安装.net framework 2.0,请到这里下载

全部源程序如下:

/*
 * Created by SharpDevelop.
 * User: PJ
 * Date: 2012-9-23
 * Time: 6:47
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

using System.IO;
using System.Threading;
using System.IO.Ports;

namespace PjComm
{
	class Program
	{
		private static int consoleHeight = 25;
		private static int consoleWidth = 80;
		
		// recv string(line0-line18),line19 is a split line
		private static string[] recvBuffer = new string[19];
		// prompt(line 20),input(line 21),exception(line 22)
		private static string[] inputBuffer = new string[3];
		// menu(line23,line24)
		private static string menuString = string.Empty;
		
		private static SerialPort comm = new SerialPort();
		private static Thread inputThread = null;
		private static Thread recvThread = null;
		private static bool isExit = false;
		private static StreamWriter sw = null;
		
		static void HighlightChar(string str,char ch,int num){
			int n = 0;
			for(int i=0;i<str.Length;i++){
				if(str[i] == ch)
					n++;
				
				if(str[i] == ch && num == n){
					Console.BackgroundColor = ConsoleColor.Blue;
				}else{
					Console.BackgroundColor = ConsoleColor.Black;
				}
	
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值