-
while (m_isreceiving)
The interface is stuck with DoEvents
You're in an endless loop!! It's going to get stuck!!
-
Is the interface stuck? Was there still data being received at the time?
It is recommended to use multi-threading for data processing.
-
Hello! If you don't close the serial port and unplug the serial port, there will definitely be an error, so you can judge whether the serial port is open when sending data.
-
There is no such detection technology, because although different peripherals use serial port protocols, but for different inputs, even if the peripherals are linked, there will not necessarily be return data, and the serial port itself does not have the function of self-testing, so the serial port can only be opened, and it is impossible to know exactly whether there are peripherals connected, even if the upstairs says that it will not work with timeout.
-
serialport= new serialport(com, baudrate, parity, databits, stopbits);
Then you can do it.
Be sure to close the serial port when the program exits.
-
You should start a new thread, or use the backgroundworker to perform the interface update and send and receive.
You are currently putting all the processing in one main thread, and the interface update is in this main thread, which will inevitably cause the interface to freeze.
The execution of a thread is equivalent to procedural execution, which is sequential execution, which will inevitably have an impact on interface updates or data sending and receiving when an operation takes time.
You can email me the source** to see.
-
In your from1, declare the serial port as a static variable, e.g. public static serialport sp=new serialport();
After that, you can directly use it in form2 to control the serial port, as for saving the settings, there are many ways, you can use the registry or ini (you can check the read and write of ini in c and find it yourself), when you open the serial port at form2, first save the above settings to ini, and then open it, also in the load of form2, read these settings first, and then assign these drop-down lists above according to the settings.
Note: Generally speaking, your form2 does not start the serial port, but sets the serial port (that is, writes the settings to the ini), and starts and stops the serial port in form1 (also reads the ini loading settings when starting).
-
Upstairs, that's not okay, if you want to do that, it's to start the form, and if it's over, all the forms are closed, so you hide the form when you start the first window, and then you start the second form, and in the second form, write: form1 f1; Add the argument form1 f1 to the constructor in the second form, and then give the argument to f1 in the function; f1 = f1;Then you can write the login if the login is successful ; Close form2; So it can be very simple.
-
Write the settings to a txt file and read them the next time you start them.
It can also be written in INI, XML, etc.
-
Very strange question.
For serial ports, the speed of data reception depends entirely on the sending speed of the other party.
If there is a blockage in the receiving section, then the data may be lost and incomplete, but it will not be slow.
Because the sender won't "cooperate" with you to slow down the send.
Unless it's a question-and-answer protocol, then the speed depends on the frequency of the inquiry, and you should check that part of the **.
Out of the circle problem, this question is more classic, but at the same time slow and difficult, I have seen an algorithm, but the efficiency is not very high, and I haven't come up with it myself. >>>More
I haven't studied how to select this problem after finding it.,I don't know if richTextBox can be implemented.,If it's just a search, it shouldn't be difficult.。
Cite month[12][10]; Wrong. Without the element month[12][10], up to month[11][9], and the pointer p is useless. There's also the deletion of all your +10-level corresponding *. >>>More
You use a P1 port to control the dynamic scanning of 8 digital tubes, and the dynamic scanning display of digital tubes needs to be blanked. >>>More
bool f=0;
for(int i=1000;i>=1;i--) Start with the largest number of 1000 and try to the smaller number. >>>More