VC uses the MSCOM control to read serial port data

xiaoxiao2021-03-06  63

Void cinsdlg :: OnCommmscomm1 () {// Todo: Add Your Control Notification Handler Code Here Variant Variant_inp; ColesafeArray SafeArray_inp; Long Len, K; Char Ch; Byte RxData [2048]; cstring straTemp;

IF (m_com.getcommEvent () == 2) {variant_inp = m_com.getinput (); // Read buffer SafeArray_inp = variant_inp; // variant type variable converted to COLESAFEARRAY Variables LEN = SafeArray_inp.getonedIMSize (); // Get Effective data length for (k = 0; k

IF ((CH == 'E') && (Flag_First == 1)) // Continuously receive 0x7f, 'e'; {FLAG = 1; count = 0; // Strcpy (data, m_strrrxdata); // The zero is ended as a string m_strrxdata.empty ();} else {flag_first = 0;} = f (cH == 0x7f) {FLAG_FIRST = 1; // Whether to receive head character 0x7f} else {flag_first = 0;}}} }

Updatedata (false);

转载请注明原文地址:https://www.9cbs.com/read-112614.html

New Post(0)