【发布时间】:2010-06-12 01:00:24
【问题描述】:
我有这个代码:
private SerialPort port = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
Console.WriteLine("Incoming Data:");
port.WriteTimeout = 5000;
port.ReadTimeout = 5000;
// Attach a method to be called when there is data waiting in the port's buffer
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
// Begin communications
port.Open();
#region PhoneSMSSetup
port.Write("AT+CMGF=1\r\n");
Thread.Sleep(500);
port.Write("AT+CNMI=2,2\r\n");
Thread.Sleep(500);
port.Write("AT+CSCA=\"+4790002100\"\r\n");
Thread.Sleep(500);
#endregion
// Enter an application loop which keeps this thread alive
Application.Run();
我是从这里得到的:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22832563.html
我有一个新的 winforms 空应用程序:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
你能告诉我吗:
- 我应该将代码粘贴到哪里?
- 如何让代码运行?
我正在向连接到计算机的手机发送 AT 命令
【问题讨论】: