Home > Software engineering >  VS2017 Cserial class serial port operation, and some of the serial port can open but not sending dat
VS2017 Cserial class serial port operation, and some of the serial port can open but not sending dat

Time:09-24

Masters,

In test VS2017 these days, for the operation of the serial port using CSerial class. There are two types of serial port is hanged on computer, one kind is CH340, one kind is the CDC virtual serial port, similar ATMEL debugger, edbug virtual port.

Through a serial port assistant test, can normal send and receive data. Cross sent (CH340, edebug virtual port). There is no problem. A serial port is no problem.
Use VS2017 compiled software testing, the use of two CH340 serial port, two for the hair, there is no problem, it can be seen that the software is ok.

But using this software, open the above edbug Virtual port, step through, can be opened, can enter the send function, writefile, but there is no data.

And I can't again to send function.

In this case, if using the debug aides open the virtual port, you can see the data sent to and from the phenomenon, the data seems to be in the buffer of the serial port, but don't understand why the data in VS2017.

Online to find a lot of serial port access to relevant information, but did not encounter this kind of problem.

Trouble warrior.

thank you

CodePudding user response:

GetCommState see if there is a handshake protocol?
Good DCB SetCommState structure

CodePudding user response:

Check the writefile return values
VS2017 bring Cserial?
But many online Cserial this name,

CodePudding user response:

Some class has a serial port can not be opened more than 10 serial interface bug, check

CodePudding user response:

Thank you, this problem has not been solved, in c #, behind can be normal use.

Because of copyright issues, cannot use MFC, so turn to c #.

CodePudding user response:

refer to the second floor arpnet99 response:
view the writefile return values
VS2017 bring Cserial?
But many online Cserial this name,
for the first time, is online, so there may be. Now, in c #, has solved the problem. But c # like no c + + high portability. The original program can be directly applied in embedded directly in the host. But there is no way.

thank you

CodePudding user response:

Behind the test c #, and out of the question.

Eventually find the root cause, need to make to DTR.

SerialPort1. DtrEnable=true; After this is ok.

CodePudding user response:

refer to 6th floor wankai1985cn response:
behind test c #, and out of the question.

Eventually find the root cause, need to make to DTR.

SerialPort1. DtrEnable=true; After this.

spirit!

CodePudding user response:

[and I can't again to send function.] you run the function of error, jump to the superior function handler
  • Related