WAGO 750 Series Manual page 189

Linux fieldbus coupler
Hide thumbs Also See for 750 Series:
Table of Contents

Advertisement

Example Program
WAGO-I/O-SYSTEM 750
Linux Fieldbus Coupler
Example of Reading and Writing from the NVRAM
#include <fcntl.h>
#include <stdio.h>
int main()
{
int i;
int file;
ssize_t sstmp;
char buf[2048];
/*Open Device*/
if((file = open("/dev/nvram")) < 0)
{
printf("ERROR: Can't open device
(\"/dev/nvram\")\n");
close(file);
exit(1);
}
/*Read Device*/
sstmp = read(file, buf, 8);
printf("read %d bytes\n", sstmp);
if(sstmp != 8)
{
printf("ERROR: Reading NVRAM failed\n");
}
else
{
printf("read(%x %x %x %x %x %x %x %x)\n", buf[0] ,
buf[1] , buf[2] , buf[3] , buf[4] , buf[5] , buf[6]
, buf[7]);
}
/*Trivial change of values*/
for(i=0;i<8;i++)
buf[i] += 1;
/*Write into Device*/
if(-1 == lseek(file, 0, SEEK_SET))
printf("ERROR: lseek failed\n");
sstmp = write(file, buf, 8);
printf("Write (%d) bytes\n", sstmp);
if(sstmp != 8)
printf("ERROR: Writing into Device failed\n");
/*close device*/
close(file);
}
Application Examples • 185

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

750-860

Table of Contents