snap ethernet-based i/o units protocols and programming guide
snap ethernet-based i/o units protocols and programming guide
snap ethernet-based i/o units protocols and programming guide
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CHAPTER 3<br />
Chapter 3<br />
Using the SNAP Ethernet I/O<br />
Driver Toolkit<br />
Introduction<br />
This chapter includes instructions for using the SNAP Ethernet I/O Driver Toolkit for<br />
communication between a computer <strong>and</strong> an Opto 22 SNAP Ethernet-<strong>based</strong> brain. The Toolkit<br />
includes two ActiveX components <strong>and</strong> two C++ classes. The components <strong>and</strong> classes have nearly<br />
identical <strong>programming</strong> interfaces <strong>and</strong> are used in the same manner. They hide the details of<br />
Ethernet communications <strong>and</strong> the IEEE 1394-<strong>based</strong> memory map protocol, making it easy to<br />
communicate with the Ethernet-<strong>based</strong> brain.<br />
This chapter assumes that you already have an underst<strong>and</strong>ing of ActiveX <strong>and</strong> C++ <strong>programming</strong>.<br />
The toolkit’s two components <strong>and</strong> two classes communicate differently with SNAP<br />
Ethernet-<strong>based</strong> brains:<br />
OptoSnapIoMemMap component or class—Communicates with the Ethernet-<strong>based</strong><br />
brain’s memory map via TCP or UDP. You can use it to read <strong>and</strong> write to analog <strong>and</strong> digital<br />
points, configuration settings, <strong>and</strong> other sections of the memory map.<br />
OptoSnapIoStreaming component or class—Listens to <strong>and</strong> processes stream packets<br />
received from multiple Ethernet-<strong>based</strong> brains, hiding the details of receiving <strong>and</strong><br />
processing UDP streaming packets.<br />
The C++ classes h<strong>and</strong>le all the details of Ethernet sockets <strong>and</strong> the<br />
IEEE 1394-<strong>based</strong> protocol. They provide functions like OptoEnet(),<br />
GetDigPtState(), <strong>and</strong> SetAnaPtValue(), making <strong>programming</strong><br />
easier <strong>and</strong> more intuitive.The ActiveX components are essentially<br />
wrappers around the C++ classes, making the efficient C++ code<br />
available to many types of ActiveX clients (see “Important<br />
ActiveX Client Issues” on page 47). The diagram at right shows<br />
how layers are related.<br />
The toolkit includes all the code for the C++ classes, ActiveX<br />
components, <strong>and</strong> examples. You are free to use this code at no<br />
charge in your own application, with or without modification.<br />
However, Opto 22 cannot support modification of the code.<br />
Your Application<br />
Toolkit ActiveX<br />
Components<br />
Toolkit C++ Classes<br />
1394-<strong>based</strong> Protocol<br />
Sockets<br />
TCP <strong>and</strong> UDP<br />
IP<br />
Ethernet-<strong>based</strong> Brain<br />
NOTE: Because the SNAP Ethernet I/O Driver Toolkit was originally developed for SNAP Ethernet<br />
I/O, it contains some methods <strong>and</strong> structures that do not apply to SNAP Simple I/O or to some<br />
SNAP Ethernet-Based I/O Units Protocols <strong>and</strong> Programming Guide 45