Step-by-step programming and wiring Methods

Source: Internet
Author: User

First, we will talk about wiring. To trigger events on CTS and other pins, a high level must be applied to the CTS and other pins. The source of the high level can come from the fourth foot, and the fourth foot must be set to a high level in the software.

 

C # Some code is as follows:

 

MSP. portName = "COM1"; mSP. baudRate = 9600; mSP. dtrEnable = true; // This is the advanced mSP for DTR. rtsEnable = true; // This is the high-level mSP for RTS. open (); mSP. pinChanged + = mSP_PinChanged; int mSPPinCount = 0; StringBuilder mSB = new StringBuilder (); System. dateTime mDTPinLast = System. dateTime. now; void mSP_PinChanged (object sender, System. IO. ports. serialPinChangedEventArgs e) {if (System. timeSpan) (System. dateTime. now-mDTPinLast )). totalMilliseconds <HealthyExamination. common. baseC. globeValues. localParas. captureSerialPortPinDelayMS) {return;} mDTPinLast = System. dateTime. now; mSPPinCount ++; // /// 1 CD Carrier Detection Carrier Detect) // 2 RXD receives data Receive) // 3 TXD sends data Transmit) // 4 prepare Data Terminal Ready for DTR Data Terminal) // 5 GND Ground) // 6 DSR Data prepare Data Set Ready) // 7 Send a Request To Send a RTS Request) // 8 CTS Clear Send Clear To Send) // 9 RI Ring Indicator) if (e. eventType = System. IO. ports. serialPinChange. ctsChanged) // pin 8 {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "CtsChanged mSPPinCount =" + mSPPinCount. toString () + "\ r \ n");} else if (e. eventType = System. IO. ports. serialPinChange. CDChanged) // Pin 1 {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "CDChanged mSPPinCount =" + mSPPinCount. toString () + "\ r \ n");} else if (e. eventType = System. IO. ports. serialPinChange. dsrChanged) // Pin 6 {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "DsrChanged mSPPinCount =" + mSPPinCount. toString () + "\ r \ n");} else if (e. eventType = System. IO. ports. serialPinChange. ring) // pin 9 {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "Ring mSPPinCount =" + mSPPinCount. toString () + "\ r \ n");} else if (e. eventType = System. IO. ports. serialPinChange. break) // pin {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "Break mSPPinCount =" + mSPPinCount. toString () + "\ r \ n");} else {mSB. insert (0, System. dateTime. now. toString ("mm: ss: ffff") + "\ t" + "Others mSPPinCount =" + mSPPinCount. toString () + "\ r \ n ");}}

 

 

This article is from the "cnming" blog, please be sure to keep this source http://cnming.blog.51cto.com/324450/1267091

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.