Question

There is device connected to PC via 1Gbit Ethernet. WinXP/7 I want to capture data in the following way:

  1. PC sends command to devices (initiate data acquisition)
  2. Device is sending data to PC
  3. User application waits for acquisition
  4. Driver saves data in the memory
  5. Device sends command to notify that it finished acquisition
  6. Driver generates interrupt and user application starts reading data from driver

I have no idea how to implement that. There is NIC driver. There is NDIS. Can user application communicate with NDIS? Do i need to write additional driver to communicate with NDIS?

Was it helpful?

Solution

Your problem really has two parts:

  1. How to send commands to the device
  2. How to capture data sent from the device

The first problem has two possible solutions, depending on whether your device accepts commands encapsulated in IPv4/IPv6, or whether it requires some other low-level protocol. If the device accepts commands encapsulated in IPv4/IPv6, then just use the sockets API in your favorite programming language.

If the device requires its own non-IP protocol, then you need to add an NDIS protocol driver. There is a sample protocol driver that is included with the Windows Driver Kit; this driver essentially opens a channel that allows a usermode application to send any kind of packet. (This would be a security issue if it were deployed widely, which is why it's not a built-in feature of the operating system.) You may need to modify the protocol driver to selectively listen only for control messages from your device.

The second problem — packet capture — is already solved. You should be able to pull existing software off the shelf and integrate it in your solution. Microsoft Network Monitor has an API that you can use to easily start/stop packet capture, and iterate through the captured results. Alternatively, some people use WinPcap.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top