Properties set in the control serial port
Cache size. It is recommended that the data received per second be more than 10 times
Important: this setting is important when the data volume received in the cache triggers a notification event. It is best to set no more than 10 trigger events per second. That is, when the amount of data received per second is 1000, set 100 ~ 400 trigger.
This problem is time-consuming. For later reference, the following is the code and explanation:
SerialPort _ serialbluetooth;
_ Serialbluetooth = new SerialPort ();
_ Serialbluetooth. baudrate = 115200;
_ Serialbluetooth. Parity = system. Io. Ports. Parity. None; // parity
_ Serialbluetooth. stopbits = system. Io. Ports. stopbits. One; // stop bit
_ SerialBluetooth. ReadTimeout = 2000; // read timeout, which is also the timeout time for the connection to open the port
_ SerialBluetooth. WriteTimeout = 500; // write timeout
_ SerialBluetooth. Encoding = System. Text. Encoding. Unicode;
_ SerialBluetooth. ReceivedBytesThreshold = 1024; // This setting is critical when an event is triggered at 1KB. Previously set to 1, causing the program to run and nearly dead.
_ SerialBluetooth. ReadBufferSize = 20240; // 20KB
_ SerialBluetooth. DataReceived + = new SerialDataReceivedEventHandler (_ serial1_th_datareceived );
1. Open the serial port in windows C ++
Char * port = "\\\\\ \ COM11"; // This is correct. You can directly use COM11 without hitting the file. ERROR_FILE_NOT_FOUND
M_hCom = CreateFileA (port,
GENERIC_READ | GENERIC_WRITE,/** access mode, which can be read and written simultaneously */
0,/** shared mode, 0 indicates not shared */
NULL,/** security settings, usually NULL */
OPEN_EXISTING,/** this parameter indicates that the device must exist; otherwise, creation fails */
0,
0 );