lijasmine
December 25th, 2005, 09:40 PM
Please help me read this program that I have writeen with libnodave.so:
int main(int argc,char **argv)
{
unsigned char buf[1024+1];
daveInterface * di;
daveConnection * dc;
_daveOSserialType fds;
int speed=daveSpeed187k;
int re;
fds.rfd=setPort("/dev/ttyS1","38400",'N');
fds.wfd=fds.rfd;
if(fds.rfd>0)
{
printf("\nstarting ppidaemon\n");
/*daveNewInterface(_daveOSserialType nfd, char *
nname, int localMPI, int protocol, int speed);*/
di = daveNewInterface(fds,"IF1",0,daveProtoMPI,speed);
re=daveInitAdapter(di);
if(re==0)
printf("Adapter is succeed\n");
if(re>0)
printf("are results (also errors) reported by the PLC\n");
if(re<0)printf(" means error reported by library code.\n");
/*daveNewConnection(daveInterface * di, int MPI,int rack, int slot);*/
dc =daveNewConnection(di,2,0,2);
if(daveConnectPLC(dc)==0)
printf("Connect PLC is succeed");
/*daveReadBytes(dc,area,dbnum,start,len,data)*/
/*int daveWriteBytes(daveConnection * dc,int area, int DBnum, int start,int len, void * buffer);*/
//daveWriteBytes(dc,0x84,1,0,24,buf);
daveReadBytes(dc,0x84,1,0,24,buf);
printf("%s\n",buf);
daveDisconnectPLC(dc);
daveDisconnectAdapter(di);
}
return 0;
}
The output is:
starting ppidaemon
means error reported by library code.
IF1 *** no DLE before send.
IF1 *** _daveSendMessageMPI error in _daveSendDialog.
???
I don't know why?
int main(int argc,char **argv)
{
unsigned char buf[1024+1];
daveInterface * di;
daveConnection * dc;
_daveOSserialType fds;
int speed=daveSpeed187k;
int re;
fds.rfd=setPort("/dev/ttyS1","38400",'N');
fds.wfd=fds.rfd;
if(fds.rfd>0)
{
printf("\nstarting ppidaemon\n");
/*daveNewInterface(_daveOSserialType nfd, char *
nname, int localMPI, int protocol, int speed);*/
di = daveNewInterface(fds,"IF1",0,daveProtoMPI,speed);
re=daveInitAdapter(di);
if(re==0)
printf("Adapter is succeed\n");
if(re>0)
printf("are results (also errors) reported by the PLC\n");
if(re<0)printf(" means error reported by library code.\n");
/*daveNewConnection(daveInterface * di, int MPI,int rack, int slot);*/
dc =daveNewConnection(di,2,0,2);
if(daveConnectPLC(dc)==0)
printf("Connect PLC is succeed");
/*daveReadBytes(dc,area,dbnum,start,len,data)*/
/*int daveWriteBytes(daveConnection * dc,int area, int DBnum, int start,int len, void * buffer);*/
//daveWriteBytes(dc,0x84,1,0,24,buf);
daveReadBytes(dc,0x84,1,0,24,buf);
printf("%s\n",buf);
daveDisconnectPLC(dc);
daveDisconnectAdapter(di);
}
return 0;
}
The output is:
starting ppidaemon
means error reported by library code.
IF1 *** no DLE before send.
IF1 *** _daveSendMessageMPI error in _daveSendDialog.
???
I don't know why?