1:PLC程序
2:C# 程序
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.IO.Ports;
using System.IO;
using System.Threading;
namespace 串口通讯
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void coms(object sender, SerialDataReceivedEventArgs e)
{
Thread.Sleep(100);
if (Class1.com.BytesToRead == 0)
{
return;
}
else
{
byte[] bt = new byte[1024];
int a = Class1.com.BytesToRead;