捣鼓了天了2 .net 2.0 的SerialPort 控件测试Modem AT 拨号指令,终于拨通了....

代码如下,一个窗口有来输入AT 指令,先要安置好Modem我用的是KN-JT560(金浪的外置猫)配置好驱动
另外来电显示要电信那边开通,Modem也分为支持来电显示与不支持来电显示2中.
开始输入ATDxxxxx (xxx为电话号码)怎么也不行,找了很多资料,KN-JT560的生产厂家电话也打过,要了分资料,发现上面写的拨好指令也是ATDxxxxx ,多要崩溃了....
后来(恩恩)设置了下 serialPort 的DtrEnable 属性为true (这个表示DTR,此针脚由计算机控制,用以通知Modem可以进行传输.高位表示计算机已经准备就绪)就可以拨通了...!
None.gif    delegate   void  del_ShowMsg( string  msg);
None.gif    
public  partial  class  Form1 : Form
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
public Form1()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            InitializeComponent();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void Form1_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
InBlock.gif            Invoke(
new del_ShowMsg(ShowMsg), serialPort1.ReadLine());
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void ShowMsg(string msg)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            textBox1.Text 
= msg + Environment.NewLine+ textBox1.Text ;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            serialPort1.Close();
InBlock.gif            label1.Text 
= serialPort1.IsOpen.ToString();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button2_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            serialPort1.NewLine 
=Environment.NewLine;
InBlock.gif            serialPort1.Open();
InBlock.gif            serialPort1.WriteLine(textBox2.Text.Trim());
InBlock.gif            
//serialPort1.WriteLine("at+vcid=1");
InBlock.gif
            label1.Text = serialPort1.IsOpen.ToString();
InBlock.gif            button2.Enabled 
= false;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void serialPort1_PinChanged(object sender, System.IO.Ports.SerialPinChangedEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//Invoke(new del_ShowMsg(ShowMsg), e.EventType.ToString());
InBlock.gif

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void serialPort1_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//Invoke(new del_ShowMsg(ShowMsg), e.ToString());
InBlock.gif
            
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void button3_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            serialPort1.WriteLine(textBox2.Text.Trim());
ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif    }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值