水下机器人设计毕业论文内容摘要:

private int receiveheadbyteindex = 0。 private DataReceiveStatus datareceivestatus =。 private ArrayList malCmdQueue = new ArrayList()。 private Thread threadSending。 private Thread threadReceiving。 public delegate void UserRequest(object sender, ReceivedEventArgs e)。 22 public delegate void UserCommandRequest(object sender, ReceivedCommandEventArgs e)。 public event UserRequest OnDataReceived。 public event UserCommandRequest OnCommandDataReceived。 public SerialSendData() { serialPort1 = new ()。 if ( == false) { = 50。 = 1024。 = false。 = 512。 = 9600。 = 1024。 += new SerialDataReceivedEventHandler(serialPort1_DataReceived)。 } } public void StartSending() //检测发送队列并发送 { while (true) { try { if( 0) { byte[] tempbytes。 23 tempbytes = (byte[])malCmdQueue[0]。 (0)。 (tempbytes, 0, )。 } } catch { } (50)。 } } public void StartReceiving() //接收队列 { while (true) { try { (50)。 int tempbytestoread =。 if (tempbytestoread = 128) { byte[] tempbyte = new byte[tempbytestoread]。 (tempbyte, 0, tempbytestoread)。 OnDataReceived(this, new ReceivedEventArgs(tempbyte))。 } } catch { } } 24 } public void OpenPort(string port, int baud) //打开串口 { = port。 = baud。 ()。 if ( == true) { threadSending = new Thread(new ThreadStart(StartSending))。 ()。 threadReceiving = new Thread(new ThreadStart(StartReceiving))。 ()。 } } public void ClosePort() //关闭串口 { if (threadSending != null amp。 amp。 ) ()。 if (threadReceiving != null amp。 amp。 ) ()。 ()。 ()。 ()。 } public void SendMessage(byte[] cmd) //str 前引导符。 str1 数值 { try 25 { ()。 (cmd, 0, )。 } catch (TimeoutException) {} } public void SendMessage(DataType _dt, String _para, String _para1) { byte checksum = new byte()。 byte[] bytes = new byte[7]。 bytes[0] = 0xCC。 //0x95 bytes[1] = 0xDD。 bytes[2] = 0x04。 switch (_dt) { case : bytes[3] = 0x20。 break。 case : bytes[3] = 0x21。 break。 case : bytes[3] = 0x22。 break。 case : bytes[3] = 0x23。 break。 case : 26 bytes[3] = 0x24。 break。 case : bytes[3] = 0x25。 break。 case : bytes[3] = 0x27。 break。 case : bytes[3] = 0x28。 break。 } switch (_para) { case top: if (_para1 == down) { bytes[4] = 0x75。 bytes[5] = 0x64。 } else if (_para1 == up) { bytes[4] = 0x75。 bytes[5] = 0x75。 } break。 case AutoTop: bytes[4] = 0x90。 bytes[5] = (_para1)。 27 break。 case AutoDown: bytes[4] = 0x91。 bytes[5] = (_para1)。 break。 case AutoLeft: bytes[4] = 0x93。 bytes[5] = (_para1)。 break。 case AutoRight: bytes[4] = 0x92。 bytes[5] = (_para1)。 break。 case bottom: if (_para1 == down) { bytes[4] = 0x64。 bytes[5] = 0x64。 } else if (_para1 == up) { bytes[4] = 0x64。 bytes[5] = 0x75。 } break。 case left: if (_para1 == down) { bytes[4] = 0x72。 bytes[5] = 0x64。 28 } else if (_para1 == up) { bytes[4] = 0x72。 bytes[5] = 0x75。 }。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。