资源简介
串口采集数据发送到服务器串口采集数据发送到服务器串口采集数据发送到服务器
![](http://www.nz998.com/pic/61185.jpg)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.IO.Ports;
using System.Configuration;//添加System.Configuration.dll的引用,可读取本地配置文件
using System.Net.Sockets;
using System.Net;
using System.IO;
namespace SerialCom
{
public partial class Form1 : Form
{
public static SerialPort sp = new SerialPort();
//急停监控线程
private static Thread _collection_com = null;
Socket socketSend;
IPEndPoint Point;
public Form1()
{
InitializeComponent();
#region 获取APP.config里面的数据进行初始化
if (ConfigurationManager.AppSettings[“InvariantInfo“] != “false“)
{
Console.WriteLine(ConfigurationManager.AppSettings.Get(“InvariantInfo“));
}
string IP = ConfigurationManager.AppSettings.Get(“IP Address“);
string Port = ConfigurationManager.AppSettings.Get(“port“);
string COM= ConfigurationManager.AppSettings.Get(“COM“);
string BaudRate = ConfigurationManager.AppSettings.Get(“BaudRate“);
ShowMsg(“当前远程服务器IP:“+IP);
ShowMsg(“当前远程服务器端口:“ + Port);
#endregion
Init_Com(COMConvert.ToInt32(BaudRate));
try
{
socketSend = new Socket(AddressFamily.InterNetwork SocketType.Stream ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse(IP);
Point = new IPEndPoint(ip Convert.ToInt32(Port));
socketSend.Connect(Point);
ShowMsg(“连接服务器成功“);
}
catch
{
ShowMsg(“连接服务器失败“);
}
//启动串口监控线程
_collection_com = new Thread(new ThreadStart(Recive_Com));
// _mThreadStop.Priority = ThreadPriority.Normal;
_collection_com.IsBackground = true;
_collection_com.Start();
}
private void Form1_Load(object sender EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
///
/// //串口初始化程序
///
void Init_Com(string COMint BaudRate)
{
#region 打印当前所有串口
//string[] str = SerialPort.GetPortNames(); //获取当前有几个串口
//if (str.Length == 0)
//{
// Console.WriteLine(“本机没有串口!“ “Error“);
// Console.ReadLine();
// return;
//}
///*
// int len = str.Length; //获取当前数组的最大长度
// for(int i=0;i // {
// Console.WriteLine(str[i]);
// }
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 54272 2018-04-22 14:43 SerialCom\.vs\SerialCom\v15\.suo
文件 0 2018-03-30 11:00 SerialCom\.vs\SerialCom\v15\Server\sqlite3\db.lock
文件 1142784 2018-03-30 21:26 SerialCom\.vs\SerialCom\v15\Server\sqlite3\storage.ide
文件 434 2018-03-30 21:26 SerialCom\SerialCom\App.config
文件 2118 2018-03-30 19:50 SerialCom\SerialCom\bin\Debug\log\2018-03-30.log
文件 11264 2018-04-09 09:19 SerialCom\SerialCom\bin\Debug\SerialCom.exe
文件 434 2018-03-30 21:26 SerialCom\SerialCom\bin\Debug\SerialCom.exe.config
文件 19968 2018-04-09 09:19 SerialCom\SerialCom\bin\Debug\SerialCom.pdb
文件 10089 2018-03-30 19:50 SerialCom\SerialCom\Form1.cs
文件 2784 2018-03-30 11:45 SerialCom\SerialCom\Form1.Designer.cs
文件 5817 2018-03-30 11:45 SerialCom\SerialCom\Form1.resx
文件 1760 2018-03-30 21:26 SerialCom\SerialCom\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6878 2018-04-22 14:42 SerialCom\SerialCom\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 42 2018-03-30 21:26 SerialCom\SerialCom\obj\Debug\SerialCom.csproj.CoreCompileInputs.cache
文件 816 2018-03-30 14:01 SerialCom\SerialCom\obj\Debug\SerialCom.csproj.FileListAbsolute.txt
文件 939 2018-03-30 14:01 SerialCom\SerialCom\obj\Debug\SerialCom.csproj.GenerateResource.cache
文件 43694 2018-03-30 21:26 SerialCom\SerialCom\obj\Debug\SerialCom.csprojResolveAssemblyReference.cache
文件 11264 2018-04-09 09:19 SerialCom\SerialCom\obj\Debug\SerialCom.exe
文件 180 2018-03-30 21:26 SerialCom\SerialCom\obj\Debug\SerialCom.Form1.resources
文件 19968 2018-04-09 09:19 SerialCom\SerialCom\obj\Debug\SerialCom.pdb
文件 0 2018-03-30 11:00 SerialCom\SerialCom\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2018-03-30 11:00 SerialCom\SerialCom\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2018-03-30 11:00 SerialCom\SerialCom\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 354 2018-03-30 11:34 SerialCom\SerialCom\Program.cs
文件 1330 2018-03-30 11:00 SerialCom\SerialCom\Properties\AssemblyInfo.cs
文件 2901 2018-03-30 21:26 SerialCom\SerialCom\SerialCom.csproj
文件 1126 2018-03-30 11:00 SerialCom\SerialCom.sln
目录 0 2018-04-22 14:43 SerialCom\.vs\SerialCom\v15\Server\sqlite3
目录 0 2018-03-30 11:00 SerialCom\.vs\SerialCom\v15\Server
目录 0 2018-03-30 15:39 SerialCom\SerialCom\bin\Debug\log
............此处省略14个文件信息
相关资源
- 易语言OTG串口通信
- delphi 串口通讯
- STM32蓝牙和串口程序
- LCD显示温度+串口接收温度.rar
- WPF USB 网络 串口 通信软件
- DELPHI与西门子200PLC的串口通信实例
- Verilog FPGA UART串口控制器
- USB转串口驱动,FT232R驱动程序,最新
- 编写简单的RMI程序 多线程web 服务器
- PC -- 单片机的串口数据传输系统设计
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- PC 串口调试软件
- 51单片机读取温度数据存储到SD卡中并
- 单片机与PC机串口通讯仿真
- IOCP 类 简单的IOCP(IO完成端口)服务
- 串口调试助手V5.0
- 双串口调试助手 V4.0 _ 可同时调试两个
- 读取串口数据并画实时曲线的VC 程序
- CVI下的TCP服务器和客户端
- 网络(UDP)转串口程序
- SOCKET 网络编程 计算机网络 作业 客户
- 串口绘制曲线 将收到的数据进行曲线
- 基于ARM蓝牙传输源程序
- JS操作本地网页串口源码
- 用Socket写的简易FTP服务器和客户端
- AT89S ISP下载编程软件(串口)
- 串口操作类(justinio)
- vc 编写的基于TCP协议的客户/服务器
- 《Visual Basic 串口通信与测控应用技术
评论
共有 条评论