Search code examples
delphigpsserial-portsniffer

Intercept serial port data in Delphi


I know how to comunicate over serial port using TComPort, but I'd like to view the data going in and out a virtual (USB<=>RSR232) COM port without interupting the transmition and (obviously) opening the port. To be precise I want to see the GPS data from the USB GPS receiver. The thing is that I need to apps using the same data at the same time. My Delphi app and the navigation software. The alternative would be to have the decent PC navigation software with Europe maps (open street map would also be fine, but can't find any decent car navigation software) that has good API whci can return the GPS position.

Any ideas are welcome! :)

Thanks! G.


Solution

  • Use the com0com device driver in conjunction with hub4com.

    From documentation:

    In conjunction with the com0com driver the hub4com allows to

    • handle data and signals from a single real serial device by a number of different applications. For example, several applications can share data from one GPS device;

    Example:

    GPS hub


    You have a GPS device that connected to your computer via a physical COM1 port and you'd like to handle its data by two GPS applications. You can do it this way:

    1. With the com0com's Setup Command Prompt create COM5<->CNCB0 and COM6<->CNCB1 virtual COM port pairs (see com0com's ReadMe.txt for more info). For example:

      command> install 0 PortName=COM5 -
      command> install 1 PortName=COM6 -
      
    2. Start the hub4com.exe on COM1, CNCB0 and CNCB1 ports:

      hub4com \\.\COM1 \\.\CNCB0 \\.\CNCB1
      

      It will send data received from COM1 port to CNCB0 and CNCB1 ports and it will send data received from CNCB0 port to COM1 port.

    3. Start the GPS applications on COM5 and COM6 ports.