BytesToWrite=0
来源:互联网 发布:unity3d文件解包 编辑:程序博客网 时间:2024/05/19 04:27
我手头有一些通过485通讯的设备,接线完毕后用设备自带的Demo发送、接受数据均正常。前段时间我写的代码往设备上发送信息也都是正常的,但是今天不行了,发现BytesToWrite=0。代码如下:
//打开端口
private void btn_open_Click(object sender, EventArgs e)
{
if (com.IsOpen == true)
{
label_state.Text = "状态:端口已打开";
}
else
{
com.PortName = "COM1";
com.BaudRate = 57600;
com.Parity = Parity.None;
com.StopBits = StopBits.One;
com.DataBits = 8;
com.Open();
label_state.Text = "状态:端口已打开";
}
}
//往设备上发送数据
private void btn_sent_Click(object sender, EventArgs e)
{
if (com.IsOpen == true)
{
try
{
com.DiscardOutBuffer();
byte[] bytesend = new byte[13];
bytesend[0] = 255;
bytesend[1] = 1;
bytesend[2] = 1;
bytesend[3] = 1;
bytesend[4] = 1;
bytesend[5] = 1;
bytesend[6] = 1;
bytesend[7] = 1;
bytesend[8] = 1;
bytesend[9] = 1;
bytesend[10] = 1;
bytesend[11] = 1;
bytesend[12] = 254;
com.Write(bytesend, 0, bytesend.Length);
if (com.BytesToWrite > 0)
{
MessageBox.Show("ok");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
搞了好大时间不知道问题出在哪里,请各位高手指点,谢谢。
- BytesToWrite=0
- ~0 == -1
- ==$0
- 0 == "###"
- ======ps cs6.0破解======
- "0" != 0
- GetLastError() == 0xEA
- child->m_pParent == 0
- View.getLeft()==0?
- null==0问题
- req.status==0
- cellpadding="0" cellspacing="0"
- sex==0?0:1; 出错
- TCP Win=0,Len=0
- ===========积分怎么突然变0了
- 1 / 0 = ?
- response.expires = 0
- sizeof(a=0)
- c#中treeview的用法
- 使用ibatis操作数据库的封装
- 加密asp.net
- /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
- (构思)网站运营分析之用户行为分析
- BytesToWrite=0
- resizing applet in browser
- 一个自动化风格编码的文档自动生成!支持C++,Java
- C++ 基础类型
- 动态创建类
- ClassLoader
- 走出误区 本本电池科学保养指南
- 浮动窗口的创建。
- javascript:window.location 详细用法