AdvancedHMI Software

General Category => Support Questions => Topic started by: mpfs on February 09, 2018, 03:41:21 AM

Title: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: mpfs on February 09, 2018, 03:41:21 AM
Hello,

I am using the WriteRaw method to write to a UDT in one go. The UDT consists of a single element of type REAL.
The WriteRaw method does not throw an error, but to check to see if the value was actually written, I call ReadRaw immediately afterwards; however, ReadRaw always returns the former value - as if WriteRaw was completely ignored.

I have tried the following, but to no avail:
- Switch the controller to PROG mode (it's in MEM mode by default).
- Wait 10ms to 10s before calling ReadRaw

Here is the partial code I am using to write to the UDT:

Code: [Select]
byte[] newValue = BitConverter.GetBytes(100.0f);
clxClient.WriteRaw(tag.TagName, 0, newValue);

I have also noticed that passing anything other than 0 in the second parameter ("numberOfElements") in WriteRaw throws an exception. Is it safe to assume that this is the offset of the byte array (the third parameter)?

Many thanks!
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: Archie on February 09, 2018, 07:33:43 AM
Try using WriteUDT as described here:

http://advancedhmi.com/documentation/index.php?title=WriteUDT(TagName_as_string,_Value_as_Object)
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: mpfs on February 09, 2018, 07:41:54 AM
Hello Archie,

thank you for the prompt reply. I came across this method earlier in the week, but it is not exposed by the EthernetIPforCLX class in the ClxDriver namespace.
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: Archie on February 09, 2018, 08:11:10 AM
I was thinking that feature was already rolled out into the ClxDriver. It is currently only available in AdvancedHMI. I will see about getting an update for the ClxDriver.

But the WriteRaw should still work because the WriteUDT uses it also. Try declaring a variable before using Bitconverter to make sure it is a single, then make sure it is sending 4 bytes.

Dim MyValue as Single = 100
Dim b() as byte=Bitconverter.GetBytes(MyValue)
clxClient.WriteRaw(tag.TagName, 0, b)
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: mpfs on February 09, 2018, 08:21:16 AM
Thank you again for the prompt reply. It still did not work using your suggestion (and to be quite frank, it would have really surprised me if it did).
EDIT: I can confirm it is sending 4 bytes, as did my code in my original post did.
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: bachphi on February 09, 2018, 10:32:21 AM
lol, I purchased the driver but not using it yet. If there is an update, please send me one too.
Title: Re: WriteRaw has no effect (ClxDriver 1.2.1.0)
Post by: mpfs on February 19, 2018, 04:22:07 AM
Hello Archie,

I can confirm that this functionality has been restored in ClxDriver 1.2.3.0.
Thank you for your rapid response!