Hello.
I have a db which is 1000 INT, and this db is represented in WinCC as a raw data type set of 5x 400 Bytes.
This set is read with a script to form an INT inside, which is working ok.
What i have to do is to multiply the INTs * 1000 and write them back.
I have to do inside wincc because I can't touch db structure.
With the following code:
I can read my values, i see correct result, but I have trouble writing it back.
It doesnt really matter if i swap bytes or not - my data written back is totally something else.
Do You have any suggestion what I'm doing wrong?
Thank You for any help and suggestions.
EDIT: IF i write them back without changing (Write3 image), my DB remains the same... Now I'm really confused.
I have a db which is 1000 INT, and this db is represented in WinCC as a raw data type set of 5x 400 Bytes.
This set is read with a script to form an INT inside, which is working ok.
What i have to do is to multiply the INTs * 1000 and write them back.
I have to do inside wincc because I can't touch db structure.
With the following code:
Code:
GetTagRawWait(Kurve1, &Yb[0], 400);
GetTagRawWait(Kurve2, &Yb[400], 400);
GetTagRawWait(Kurve3, &Yb[800], 400);
GetTagRawWait(Kurve4, &Yb[1200], 400);
GetTagRawWait(Kurve5, &Yb[1600], 400);
for (i=0; i < 1000; i++)
{
Y = (Yb[2 * i] << 8) + Yb[2 * i +1]; // -- Read 2 bytes, form INT
Ymul =(unsigned int) Y*100; // -- Multiply
printf("Before: %d", Y);
printf("After: %d", Ymul);
printf("\n");
if (Ymul >= 32768) Ymul = Ymul - 65536;
Yb[2*i] = (Ymul <<8); // -- Write back INT to 2 bytes
Yb[2 * i +1] = Ymul &0xFF;
}
I can read my values, i see correct result, but I have trouble writing it back.
It doesnt really matter if i swap bytes or not - my data written back is totally something else.
Do You have any suggestion what I'm doing wrong?
Thank You for any help and suggestions.
EDIT: IF i write them back without changing (Write3 image), my DB remains the same... Now I'm really confused.
Attachments
Last edited: