скрытое меню

Выводы

РАЗРАБАТЫВАТЬ СВОИ ДРАЙВЕРА под Windows МОЖНО!

В примере VirtualSerail смысл таков :

Пишем в Com порт например "1233456" через WriteFile
Драйвер сохраняет это в кольцевом буфере
потом читаем через ReadFile , в результате драйвер выдает , то что в кольцевом буфере накопилось ("1233456")

Синхронный/Асинхронный(OverLapped) режимы оба работают.

Настройки порта, типа скорости можно устанавливать, можно не устанавливать - по барабану (ведь Com порт "виртуальный").

Проверяем двумя программами на qt 4.8.1 - одна пишет в Com порт, другая читает из порта.

По коду добавлена трассировка, так что все становится очевидно.

EventTrace
[2]119C.153C::05/17/2018-19:14:22.314 [virtualserial]INFO: **************** DllGetClassObject ******************* (c8ecc087-6b79-4de5-8fb4-c03358a29617)
[2]119C.153C::05/17/2018-19:14:22.314 [virtualserial]INFO: **************** DllGetClassObject ******************* SUCCEEDED
[2]119C.153C::05/17/2018-19:14:22.314 [virtualserial]INFO ....CMyDriver::Initialize!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.314 [virtualserial]INFO ....CMyDriver::CreateInstance!....SUCCEEDED
[2]119C.153C::05/17/2018-19:14:22.314 [virtualserial]INFO ....CMyDriver::QueryInterface!....S_OK
[2]119C.153C::05/17/2018-19:14:22.315 [virtualserial]INFO ....CMyDriver::QueryInterface!....CUnknown
[2]119C.153C::05/17/2018-19:14:22.318 [virtualserial]INFO ....CMyDevice::CreateInstance!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.318 [virtualserial]INFO ....CMyDevice::Initialize!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.318 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.319 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.319 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.319 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.319 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.319 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.322 [virtualserial]INFO ....CMyDevice::QueryInterface!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.336 [virtualserial]INFO ....CMyDriver::OnDeviceAdd!.... SUCCEEDED
[2]119C.153C::05/17/2018-19:14:22.336 [virtualserial]INFO ....CMyDevice::Configure!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[2]119C.153C::05/17/2018-19:14:22.337 [virtualserial]INFO ....CMyDevice::GetPdoName!.... (2c7089aa-2e0e-11d1-b114-00c04fc2aae4)
[0]119C.153C::05/17/2018-19:14:22.338 [virtualserial]INFO        CMyQueue::CreateInstance
[1]119C.153C::05/17/2018-19:14:22.338 [virtualserial]INFO    CRingBuffer::CRingBuffer
[1]119C.153C::05/17/2018-19:14:22.338 [virtualserial]INFO        CMyQueue::Initialize
[1]119C.153C::05/17/2018-19:14:22.338 [virtualserial]INFO    CRingBuffer::Initialize SUCCEEDED
[0]119C.153C::05/17/2018-19:14:22.338 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface IQueueCallbackRead
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface IQueueCallbackWrite
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface IQueueCallbackDeviceIoControl
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.153C::05/17/2018-19:14:22.341 [virtualserial]INFO        CMyQueue::QueryInterface unknown
[0]119C.17A8::05/17/2018-19:26:16.062 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[3]119C.17C0::05/17/2018-19:26:16.967 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[3]119C.17A8::05/17/2018-19:26:16.998 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[1]119C.17C0::05/17/2018-19:26:17.032 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[0]119C.17A8::05/17/2018-19:26:17.067 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS
[0]119C.17A8::05/17/2018-19:26:17.069 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS ReadIntervalTimeout
[3]119C.17C0::05/17/2018-19:26:17.102 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_PURGE
[3]119C.17A8::05/17/2018-19:26:17.133 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_PURGE
[0]119C.17C0::05/17/2018-19:26:17.162 [virtualserial]INFO        CMyQueue::OnWrite
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO        CMyQueue::ProcessWriteBytes 123
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write '1' DataSize=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write GetAvailableSpace=1023
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write m_Base=00000000003487F0 m_Head=00000000003487F0 m_Tail=00000000003487F0 m_End=0000000000348BF0 bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write '2' DataSize=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write GetAvailableSpace=1022
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write m_Base=00000000003487F0 m_Head=00000000003487F0 m_Tail=00000000003487F1 m_End=0000000000348BF0 bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write '3' DataSize=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write GetAvailableSpace=1021
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.163 [virtualserial]INFO    CRingBuffer::Write m_Base=00000000003487F0 m_Head=00000000003487F0 m_Tail=00000000003487F2 m_End=0000000000348BF0 bytesToCopy=1
[0]119C.17C0::05/17/2018-19:26:17.176 [virtualserial]INFO        CMyQueue::OnWrite availableData = 3
[0]119C.17A8::05/17/2018-19:27:28.610 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[1]119C.17C0::05/17/2018-19:27:29.385 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[3]119C.17A8::05/17/2018-19:27:29.426 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[3]119C.17C0::05/17/2018-19:27:29.454 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[1]119C.17A8::05/17/2018-19:27:29.483 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[3]119C.17C0::05/17/2018-19:27:29.512 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[1]119C.17A8::05/17/2018-19:27:29.542 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[1]119C.17C0::05/17/2018-19:27:29.571 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[1]119C.17A8::05/17/2018-19:27:29.600 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_BAUD_RATE = 4800
[1]119C.17C0::05/17/2018-19:27:29.629 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769524 0x1b0034
[1]119C.17A8::05/17/2018-19:27:29.656 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769512 0x1b0028
[3]119C.17C0::05/17/2018-19:27:29.686 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL SERIAL_8_DATA
[3]119C.17C0::05/17/2018-19:27:29.686 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL STOP_BIT_1
[3]119C.17C0::05/17/2018-19:27:29.686 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL NO_PARITY
[3]119C.17A8::05/17/2018-19:27:29.714 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769564 0x1b005c
[3]119C.17C0::05/17/2018-19:27:29.742 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769572 0x1b0064
[3]119C.17A8::05/17/2018-19:27:29.771 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS
[3]119C.17A8::05/17/2018-19:27:29.772 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS ReadIntervalTimeout
[3]119C.17C0::05/17/2018-19:27:29.801 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=1  BytesCopied=0
[3]119C.17C0::05/17/2018-19:27:29.802 [virtualserial]INFO    CRingBuffer::Read DataSize=1
[3]119C.17C0::05/17/2018-19:27:29.802 [virtualserial]INFO    CRingBuffer::Read CopyMemory m_Base=00000000003487F0 m_Head=00000000003487F0 m_Tail=00000000003487F3 m_End=0000000000348BF0
[3]119C.17C0::05/17/2018-19:27:29.802 [virtualserial]INFO    CRingBuffer::Read return S_OK
[3]119C.17C0::05/17/2018-19:27:29.802 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=1  BytesCopied=1
[3]119C.17C0::05/17/2018-19:27:29.813 [virtualserial]INFO        CMyQueue::OnRead  Data was read from buffer succesfully
[3]119C.17A8::05/17/2018-19:27:37.327 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[1]119C.17C0::05/17/2018-19:27:37.358 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[3]119C.17A8::05/17/2018-19:27:38.230 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[0]119C.17C0::05/17/2018-19:27:38.292 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[3]119C.17A8::05/17/2018-19:27:38.325 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[3]119C.17C0::05/17/2018-19:27:38.354 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[0]119C.17A8::05/17/2018-19:27:38.384 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[3]119C.17C0::05/17/2018-19:27:38.412 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[0]119C.17A8::05/17/2018-19:27:38.440 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_BAUD_RATE = 4800
[3]119C.17C0::05/17/2018-19:27:38.469 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769524 0x1b0034
[0]119C.17A8::05/17/2018-19:27:38.496 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769512 0x1b0028
[0]119C.17C0::05/17/2018-19:27:38.525 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL SERIAL_8_DATA
[0]119C.17C0::05/17/2018-19:27:38.525 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL STOP_BIT_1
[0]119C.17C0::05/17/2018-19:27:38.525 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL NO_PARITY
[3]119C.17A8::05/17/2018-19:27:38.554 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769564 0x1b005c
[0]119C.17C0::05/17/2018-19:27:38.581 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769572 0x1b0064
[0]119C.17A8::05/17/2018-19:27:38.609 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS
[0]119C.17A8::05/17/2018-19:27:38.610 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS ReadIntervalTimeout
[3]119C.17C0::05/17/2018-19:27:38.639 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=2  BytesCopied=0
[3]119C.17C0::05/17/2018-19:27:38.640 [virtualserial]INFO    CRingBuffer::Read DataSize=2
[3]119C.17C0::05/17/2018-19:27:38.640 [virtualserial]INFO    CRingBuffer::Read CopyMemory m_Base=00000000003487F0 m_Head=00000000003487F1 m_Tail=00000000003487F3 m_End=0000000000348BF0
[3]119C.17C0::05/17/2018-19:27:38.640 [virtualserial]INFO    CRingBuffer::Read return S_OK
[3]119C.17C0::05/17/2018-19:27:38.640 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=2  BytesCopied=2
[0]119C.17C0::05/17/2018-19:27:38.651 [virtualserial]INFO        CMyQueue::OnRead  Data was read from buffer succesfully
[0]119C.17A8::05/17/2018-19:29:42.745 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[0]119C.17C0::05/17/2018-19:29:42.776 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[3]119C.17A8::05/17/2018-19:29:42.802 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[0]119C.17C0::05/17/2018-19:29:42.824 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[0]119C.17A8::05/17/2018-19:29:42.847 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_BAUD_RATE = 1769552 0x1b0050
[0]119C.17C0::05/17/2018-19:29:42.870 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_LINE_CONTROL
[3]119C.17A8::05/17/2018-19:29:42.894 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_CHARS
[0]119C.17C0::05/17/2018-19:29:42.915 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769568 0x1b0060
[3]119C.17A8::05/17/2018-19:29:42.939 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_BAUD_RATE = 4800
[0]119C.17C0::05/17/2018-19:29:42.962 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769524 0x1b0034
[0]119C.17A8::05/17/2018-19:29:42.982 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769512 0x1b0028
[0]119C.17C0::05/17/2018-19:29:43.006 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL SERIAL_8_DATA
[0]119C.17C0::05/17/2018-19:29:43.006 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL STOP_BIT_1
[0]119C.17C0::05/17/2018-19:29:43.006 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_SET_LINE_CONTROL NO_PARITY
[0]119C.17A8::05/17/2018-19:29:43.029 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769564 0x1b005c
[0]119C.17C0::05/17/2018-19:29:43.051 [virtualserial]INFO        CMyQueue::OnDeviceIoControl  unknown by default 1769572 0x1b0064
[3]119C.17A8::05/17/2018-19:29:43.073 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS
[3]119C.17A8::05/17/2018-19:29:43.074 [virtualserial]INFO        CMyQueue::OnDeviceIoControl IOCTL_SERIAL_GET_TIMEOUTS ReadIntervalTimeout
[0]119C.17C0::05/17/2018-19:29:43.097 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=2  BytesCopied=0
[0]119C.17C0::05/17/2018-19:29:43.097 [virtualserial]INFO    CRingBuffer::Read DataSize=2
[0]119C.17C0::05/17/2018-19:29:43.097 [virtualserial]INFO    CRingBuffer::Read GetAvailableData=0
[0]119C.17C0::05/17/2018-19:29:43.097 [virtualserial]INFO        CMyQueue::OnRead SizeInBytes=2  BytesCopied=0
[0]119C.17C0::05/17/2018-19:29:43.104 [virtualserial]INFO        CMyQueue::OnRead   No data to read. Queue the request for later processing.

Единственно , что смущает Terminal 1.9 зависает сразу при установке соединения

Яндекс.Метрика