Purpose: retrieve current netmap
Parameter:
IN: ARCNET_NETMAP
OUT: ARCNET_NETMAP
Comment:
The driver compares the input netmap with the real netmap. The function
returns only if differences are detected or the herein specified
timeout
elapses.
If the member w_timeout of ARCNET_NETMAP
is set to 0, or no input netmap is specified, the function returns
immediately
with the current netmap.
If the member w_timeout is set to 0xFFFF the functions wait infinitely
for a netmap change.
If no differences are deteced the function returns with
E_FARC_NETMAP_NO_CHANGES
unless member w_timeout of ARCNET_NETMAP
is not set to 0xFFFF.
A pending request is cancelled if IOCTL_FARC_DEINIT
is performed.
Only one request of this call can be pending otherwise an error is
returned.
Hint: It is a good idea to store the retrieved netmap and hand it to
the call the next time.
Note, that this feature is not available with
SH ARC66.
Note also, that this feature allows only simple
and rudimentary netmap detection. The driver may NOT detect glitches in
the netmap. Furthermore this funtion may return "ghost nodes". You
should
only look at that nodes that are set in the previous call to IOCTL_FARC_NETMAP_SETTINGS.
If you need a safe and reliable node/netmap
detection,
use SHARCALYZER.
Possible errors (see also Error codes):
E_FARC_NOT_INITED,
E_FARC_EXCESSIVE_RECON,
E_FARC_BUFFER_TOO_SMALL,
E_FARC_NETMAP_PENDING,
E_FARC_NETMAP_NO_CHANGE
Example:
Note, that the following example is only a fragment. It is recommended,
that the driver is opened in asynchronous mode and a handle to the
driver
is available.
OVERLAPPED overlapped;
DWORD read, err;
BOOL ret;
ARCNET_NETMAP sNetmap;
ARCNET_NETMAP sNetmapNew;
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent =
CreateEvent(NULL,
TRUE, FALSE, NULL);
...
memset(&sNetmap,0,sizeof(sNetmap));
// only nodes 1..3 and 7 are
expected to be active
sNetmap.ba_netmap[0] = 0x8E;
// wait 100ms for a netmap
schange
// function should return, if
detected netmap is different or at least after 100ms
sNetmap.w_timeout = 10;
ret =
DeviceIoControl(drvhandle,
IOCTL_FARC_GET_NETMAP,
&sNetmap,
sizeof(sNetmap),
&sNetmapNew,
sizeof(sNetmapNew),
&read,
&overlapped);
if (!ret)
{
err = GetLastError();
if (err == E_FARC_PENDING)
{
ret
= GetOverlappedResult(drvhandle, &overlapped, &read, TRUE);
if
(!ret)
{
err = GetLastError();
// do errorhandling here
}
else
{
// netmap retrieved after timeout or change detected
}
}
else
{
//
other error occured, perhaps wrong handle
}
}
else
{
// netmap immediately
retrieved
}
...