Table of Contents
The API specifications and function documentation for this driver are in the Cogent Driver Specifications Chapter of the Cogent C API manual.
This is a highly simplified example of using a few of the Cogent C API functions, with no error checking etc. It leaves the actual work of read/writing the values from/to the buffer as an exercise for the reader.
#include ("dr_api.h");
#include ("dvn_api.h");
int main (int argc, char ** argv)
{
char dvn_data[1024];
int scanning=1;
if (!DR_ApInitIPC (argv[0], "/dr/dvn"))
{
/* read the configuration of points */
/* ..... */
while (scanning)
{
DR_ApUpdateBuffers ();
DR_ApReadBlock (0, DVN_BUF_INPUT, 0, 64*8, dvn_data, NULL);
/*
* read/write the data as required.
* eg: if 'point' is an object in a linked list that
* models where the data is, then for each point:
* point.value = dvn_data[point.dvn_offset]&point.dvn_bit_mask;
* ...
* dvn_data[point.dvn_offset] = modbus_data[point.mbs_offset];
* etc.
*/
DR_ApWriteBlock (0, DVN_BUF_OUTPUT, 0, 64*8, dvn_data, NULL);
}
DR_ApCloseIPC();
}
}Copyright © 1995-2006 by Cogent Real-Time Systems, Inc. All rights reserved.