Using System;
class test {
static libnodave.daveOSserialType fds;
static libnodave.daveInterface di;
static libnodave.daveConnection dc;
static int localMPI=0;
static int plcMPI=2;
public static int Main (string[] args)
{
int i,a=0,j,res,b=0,c=0;
float d=0;
fds.rfd=libnodave.setPort(args[0],"38400",'O');
fds.wfd=fds.rfd;
if (fds.rfd>0) {
di =new libnodave.daveInterface(fds, "IF1", localMPI, libnodave.daveProtoMPI, libnodave.daveSpeed187k);
di.setTimeout(1000000);
res=di.initAdapter();
if(res==0) {
dc = new libnodave.daveConnection(di,plcMPI, 0, 0);
if (0==dc.connectPLC()) {
res=dc.readBytes(libnodave.daveFlags, 0, 0, 16, null);
if (res==0) {
a=dc.getS32();
b=dc.getS32();
c=dc.getS32();
d=dc.getFloat();
Console.WriteLine("FD0: " + a);
Console.WriteLine("FD4: " + b);
Console.WriteLine("FD8: " + c);
Console.WriteLine("FD12: " + d);
} else
Console.WriteLine("error "+res+" "+libnodave.daveStrerror(res));
}
dc.disconnectPLC();
}
di.disconnectAdapter();
libnodave.closePort(fds.rfd);
} else {
Console.WriteLine("Couldn't open serial port "+args[0]);
return -1;
}
return 0;
}
}