Example:Write a sequence of bytes from a buffer to PLC memory. int daveWriteBytes(daveConnection * dc, int area, int DB, int start, int len, void * buffer);
Parameters:
dc: A pointer to a daveConnection structure representing an established connection.
area: A constant that specifies a memory area in the PLC.
DB: The number of a data block. Only meaningful if area is daveDB. Use 0 oterwise.
start: The address of the first byte in the block.
len: The number of bytes to write.
buffer: A pointer to some memory space with the writedata.
if(doWriteDB) {
printf("Writing to DataBlock memory.\n");
wait();
daveWriteBytes(dc, daveDB, 1, 0, 2, NULL); --> you must transfer your Data to the Function (not "NULL")
a=daveGetU16(dc) --> befor you can show the actual Data from the PLC you must read ("readbytes") them from the PLC after the write function.
printf("DB1: DW0: %d\n",a);
wait();
}//doWriteDB
so..... can I say:
daveWriteBytes(dc, daveDB, 1, 0, 2, &a); ??
//daveWriteBytes(dc,daveDB,42,17,4,&a); would write it to data block 42, starting with DBB 17.
// note the a is an int (32bit) and len (4) happens to be the byte size of a!
but my output does not change the values, it returns this:
a=daveSwapIed_16(a+1);
daveWriteBytes(dc,daveDB,1,0,2,&a);
b=daveSwapIed_16(b+2);
daveWriteBytes(dc,daveDB,1,2,2,&b);
davereadBytes(dc,daveDB,1,0,4,NULL);
a=daveGetU16(dc);
b=daveGetU16(dc);
printf("DB1: DW0: %d\n",a);
printf("DB1: DW1: %d\n\n",b);
You CAN write to DW0 and DW1, but when you write to DW1, you'll overwrite the 2nd half of DW0 and the 1st of DW2.You can not write to DW0 and DW 1, you must write to DW0 and DW 2.
this code should work:
a=daveGetU16(dc); // This uses two bytes from the bufffer and hence advances the buffer pointer by 2 bytes;a=daveGetU16(dc);
b=daveGetU16(dc);
printf("DB1: DW0: %d\n",a);
printf("DB1: DW1: %d\n\n",b);
I am getting an error that has never happened before. When I try running a test program in DOS I get the following error: "testISO_TCP" is not recognized as a n internal or external command, operable program or batch file"
I am very sure that my path is correct and in C++ the program compiles and builds fine.
Thanks for any help.
Van
I am not sure what you mean by "in DOS". The test programs are made to be run on the windows command line. They are WINDOWS executables, NOT DOS executables. This means that the CANNOT run under real DOS operating systems, like MSDOS, IBMDOS, FreeDOS etc.When I try running a test program in DOS I get the following error: "testISO_TCP" is not recognized as a n internal or external command, operable program or batch file"
I am very sure that my path is correct and in C++ the program compiles and builds fine.
Thanks for any help.
Van
I am not sure what you mean by "in DOS". The test programs are made to be run on the windows command line. They are WINDOWS executables, NOT DOS executables. This means that the CANNOT run under real DOS operating systems, like MSDOS, IBMDOS, FreeDOS etc.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?