------------------------------------ char1 ------------------------------------
$$$$ $$$$ $$ $$ $$ $$$$
$$ $$ $$ $$ $$$ $$$ $$$ $$ $$
$$ $$ $$ $$$$$$$ $$ $$
$$ $$ $$ $$ $ $$ $$ $$
$$ $$ $$ $$ $$ $$ $$ $$
$$$$ $$$$ $$ $$ $$$$$$ $$$$$$
------------------------------------ char2 ------------------------------------
$$$$$$$ $$$$$$ $$$$$$$ $$ $$$$$$$
$$ $$ $$ $$ $ $ $ $$ $$ $$
$$ $$ $$ $ $ $ $$ $$
$$$ $$$ $$ $$ $ $ $$$ $$$$$$$
$$$ $$$ $$ $$ $ $ $$$ $$$
$$$ $$ $$$ $$ $$ $ $ $$$ $$$
$$$$$$$ $$$$$$$ $$ $ $ $$$ $$$$$$$
------------------------------------ char3 ------------------------------------
$$$$ $$$ $$ $$ $$ $$$$$
$$ $$ $$ $$ $$$ $$$ $$$ $$ $$
$$ $$ $$ $$$$$$$ $$ $$ $$
$$ $$ $$ $$ $ $$ $$ $$$
$$ $$ $$ $$ $$ $$ $$$
$$ $$ $$ $$ $$ $$ $$ $$ $$
$$$$ $$$ $$ $$ $$$$$$ $$$$$$$
------------------------------------ char4 ------------------------------------
$$$ $$$ $$ $ $$ $$$$
$$$$$$ $$$$$ $$ $$ $$$ $$ $$
$$ $$ $$ $$$$$$ $$$$ $$
$$ $$ $$ $$$ $$$ $$ $$$
$$ $$ $$ $$ $$ $$ $$ $$$
$$ $$$ $$ $$ $$ $$ $$ $$$
$$$$ $$$$ $$ $$ $$$$$$$ $$$$$$$
------------------------------------ charact1 ------------------------------------
$$ $$$$$$
$$$$$$ $$$$$$ $$ $$ $$$ $$ $$
$$ $$ $$ $$ $$$$$$ $$$$ $$
$$ $$ $$ $$$$$$ $$ $$$$
$$ $$ $$ $$ $$ $$$ $$ $$
$$$$$$ $$$$$$ $$ $$$ $$$$$$ $$$$$$
------------------------------------ charact2 ------------------------------------
$$ $$$$
$$$ $$ $$
$$$$$ $$$$ $$ $$ $$$$ $$
$$ $$ $$ $$$$$$ $$ $$$$
$$ $$ $$ $$ $$ $$ $$
$$$$$ $$$$ $$ $$ $$$$$$ $$$$$$
------------------------------------ charact3 ------------------------------------
$$$ $$$$
$$$ $$ $$
$$$$$ $$$$$ $$ $$ $$$ $$$
$$ $$ $$ $$$$$$$ $$ $$$$
$$ $$ $$ $$ $$ $$ $$
$$$$$$ $$$$$ $$ $$ $$$$$$ $$$$$$$
------------------------------------ charact4 ------------------------------------
$$ $$$$$$
$$$ $$$
$$$$$$ $$$$$$ $$ $$ $$ $$$
$$$ $$ $$ $$$$$$ $$ $$$$$$
$$$ $$ $$$ $$ $$$ $$$$$$ $$
$$$$$$ $$$$$$ $$ $$$ $$$$$$ $$$$$$
------------------------------------ charact5 ------------------------------------
$$ $$$$
$$$ $$ $$$
$$$$$ $$$$ $$ $$ $$$$ $$$
$$$ $$ $$ $$$$$$ $$ $$$$
$$$ $$ $$ $$ $$ $$$$$$ $$$
$$$$$ $$$$ $$ $$ $$$$$$ $$$$$$
------------------------------------ charact6 ------------------------------------
$$ $$$$
$$$$ $$$$ $$ $$ $$$ $$ $$
$$ $$ $$ $$$$$$ $$$$ $$
$$ $$ $$ $$$$$$ $$ $$$$
$$ $$ $$ $$ $$ $$ $$
$$$$ $$$$ $$ $$ $$$$$$ $$$$$$
------------------------------------ characte ------------------------------------
$$ $$$$$$
$$$ $$ $$
$$$$$$ $$$$$$ $$ $$ $$$$ $$
$$ $$ $$ $$$$$$ $$ $$$$
$$ $$ $$ $$ $$ $$ $$
$$$$$$ $$$$$$ $$ $$ $$$$$$ $$$$$$
------------------------------------ chartr ------------------------------------
$$ $ $$ $ $ $$
$ $ $ $ $$ $$ $ $ $
$ $ $ $$ $$ $ $
$ $ $ $ $$ $ $ $
$ $ $ $ $ $$ $ $ $ $
$$ $ $$$ $$ $ $$$$
------------------------------------ chartri ------------------------------------
$$$ $$$ $ $$ $ $$
$ $ $ $ $$ $ $$ $ $
$ $ $ $$ $$ $ $
$ $ $ $$ $$ $ $$
$ $ $ $ $ $$ $ $ $ $
$$$ $$$ $$$ $$ $$ $$$$
usb_event_callback_handler
def usb_event_callback_handler(eventPort, eventInfo, eventType):
if eventType == 0x2025:
context = ' ---%4s%s' % ('', devicePort)
XBanner.line('-')
XBanner.printText(context)
XBanner.line('-')
if eventType == 0x8000:
context = ' <<<%4s%s' % ('', devicePort)
XBanner.line('<')
XBanner.printText(context)
XBanner.line('<')
if eventType == 0x8004:
context = ' %s%4s>>>' % (devicePort, '')
XBanner.line('>')
XBanner.printText(context)
XBanner.line('>')
return 0
PyQT DLL Process
def process():
coreEvent = XCoreEvent.loadDll()
if True:
eventCallback = CallbackType(XCoreEvent.usb_event_callback_handler)
coreEvent.RegisterCallback(eventCallback)
if True:
result = coreEvent.StartMonitoring()
print('StartMonitoring DLL invoked', result)
try:
i, maximum = 0, (50 * 1000)
for i in range(maximum):
time.sleep(0.001)
except Exception as e:
print("Exiting...")
SerialList & SerialIsValid
CORE_EVENT_API BOOL WINAPI SerialList(LPSTR dataBuff, UINT buffSize) {
std::vector<std::string> myList = EnumerateComPorts();
std::string alpha;
for (auto& one : myList) {
alpha.append(one).append(";");
}
if (!alpha.empty() && alpha.back() == ';') {
alpha.pop_back();
}
memset(dataBuff, 0x00, buffSize);
memcpy(dataBuff, alpha.c_str(), alpha.size());
return TRUE;
}
CORE_EVENT_API BOOL WINAPI SerialIsValid(LPSTR portName) {
HANDLE hComm = CreateFileA(
portName,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
if (hComm != INVALID_HANDLE_VALUE) {
CloseHandle(hComm);
return TRUE;
}
return FALSE;
}
def todoE():
coreEvent = XCoreEvent.loadDll()
if True:
alpha = XCoreEvent.listSerial()
for one in alpha:
logLine()
portName = one
bytesData = portName.encode()
result = coreEvent.SerialIsValid(bytesData)
if result:
XBanner.printText('%s : connected' % (portName))
else:
XBanner.printText('%s : opened' % (portName))
logLine()