logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[C/C++] Nasłuchiwanie otwartego portu COM w C++ Builderze bez emulacji, WinAPI

24 Lis 2011 23:07 2911 3
REKLAMA
  • #1 10179337
    Konto nie istnieje
    Konto nie istnieje  
  • REKLAMA
  • #2 10179733
    Dżyszla
    Poziom 42  
    Posty: 7065
    Pomógł: 1095
    Ocena: 211
    Raczej wątpię. Najczęściej czytanie = wymazanie informacji z bufora. Więc nawet gdybyś czytał bez wymazania, to inna aplikacja i tak może Cię "ubiec".

    Ale głowy nie daję, czy nie ma rozwiązania jakiegoś... (pomijając DOS i tryb real-time - wtedy powinno się dać nadpisać procedurę obsługi przerwania).
  • REKLAMA
  • Pomocny post
    #3 10180172
    Luklukowaty
    Poziom 19  
    Posty: 394
    Pomógł: 29
    Ocena: 42
    A tam się nie da - na kompie jak potrafisz to wszystko zaprogramujesz - kwestia tylko umiejętności.

    Nie potrzeba do tego żadnego DOSu, trybu real-time, wirtualnych COMów czy fizycznego łączenia dwóch COMów ze sobą. Programy takie nazywają się snifferami (serial port sniffer) i tego możesz szukać na necie.

    Taka mała podpowiedź: http://technet.microsoft.com/en-us/sysinternals/bb896644
    program PortMon, który jest snifferem. Na stronie jest opis w jaki sposób działa i do jakiego API się odwołuje. W skrócie dodaje "device filter" dla portu szeregowego lub równoległego, dzięki czemu ma dostęp do całej transmisji.

    To tak w skrócie - szczegóły pewnie trzeba szukać głębiej i dłużej (czego mi się nie chce), ale z powyższymi informacjami powinieneś sobie poradzić :)

    Cytat:
    How it Works: WinNT

    The Portmon GUI is responsible for identifying serial and parallel ports. It does so by enumerating the serial ports that are configured under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm and the parallel ports defined under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\Parallel Ports. These keys contain the mappings between serial and parallel port device names and the Win32-accessible names.

    When you select a port to monitor, Portmon sends a request to its device driver that includes the NT name (e.g. \device\serial0) that you are interested in. The driver uses standard filtering APIs to attach its own filter device object to the target device object. First, it uses ZwCreateFile to open the target device. Then it translates the handle it receives back from ZwCreateFile to a device object pointer. After creating its own filter device object that matches the characteristics of the target, the driver calls IoAttachDeviceByPointer to establish the filter. From that point on the Portmon driver will see all requests aimed at the target device.

    Portmon has built-in knowledge of all standard serial and parallel port IOCTLs, which are the primary way that applications and drivers configure and read status information from ports. The IOCTLs are defined in the DDK file \ddk\src\comm\inc\ntddser.h and \ddk\src\comm\inc\ntddpar.h, and some are documented in the DDK.

    How it Works: Win9x

    On Windows 95 and 98, the Portmon GUI relies on a dynamically loaded VxD to capture serial and parallel activity. The Windows VCOMM (Virtual Communications) device driver serves as the interface to parallel and serial devices, so applications that access ports indirectly use its services. The Portmon VxD uses standard VxD service hooking to intercept all accesses to VCOMM's functions. Like its NT device driver, Portmon's VxD interprets requests to display them in a friendly format. On Win9x Portmon monitors all ports so there is no port selection like on NT.
  • #4 10181438
    Konto nie istnieje
    Konto nie istnieje  
REKLAMA