Has anyone per chance worked at all with OPC & perl? Specifically the package Win32::OLE::OPC. I'm having a mare of a time with it. My latest problem is writing data, here's the relavent code:
And the subsmy $itemdata = OPCItemRead ($rightdata[0], $i+1); $rightdata[0]->{lastvalues}->[$i] = $itemdata->{Value}; OPCItemWrite($rightdata[0], $i+1, $rightdata[0]->{lastvalues}->[$i +] + 1);
The read function works absolutely fine, the write always gives:sub OPCItemRead { my $groupdata = shift; my $itemno = shift; my $items; my $data; # reference to the ha +sh of data returned by Read() $items = $groupdata->{grouphandle}->OPCItems(); $data = $items->Item($itemno)->Read($OPCDevice); } sub OPCItemWrite { my $groupdata = shift; my $itemno = shift; my $newvalue = shift; my $items; $items = $groupdata->{grouphandle}->OPCItems(); $items->Item($itemno)->Write($newvalue); }
If I stop the debugger in the write function just before the write $groupdata, $itemno and $newvalue all look fine. If I do thisOPC::Item::Write Matrikon.OPC.DDE: Win32::OLE(0.1707) error 0x80070057: "The parameter is incorrect" in METHOD/PROPERTYGET "Write" at C:/Program Files/Perl/lib/Win32/OLE/OPC.pm line 1666
I get the expected data hash so I'm sure everything is set up correctly. As soon as I execute the write up pops this more verbose version of the same error:x $items->Item($itemno)->Read($OPCDevice)
All the man for this method says isOPC::Item::Write Matrikon.OPC.DDE: Win32::OLE(0.1707) error 0x80070057: "The parameter is incorrect" in METHOD/PROPERTYGET "Write" at C:/Program Files/Perl/lib/Win32/OLE/OPC.pm line 1666 at C:/Program Files/Perl/lib/Win32/OLE/OPC.pm line 123 Win32::OLE::OPC::_check_error('OPC::Item::Write Matrikon.OPC.D +DE') called at C:/Program Files/Perl/lib/Win32/OLE/OPC.pm line 1666 Win32::OLE::OPC::Item::Write('Win32::OLE::OPC::Item=HASH(0x22c +2360)', 11) called at opccompare.pl line 542 main::OPCItemWrite('HASH(0x2291d14)', 5, 11) called at opccomp +are.pl line 151 main::(opccompare.pl:154): if (not($debug + =~ m/quiet/)) {
So taking the error message at face value perhaps I'm expressing VALUE incorrectly. I've tried passing a ref to the data instead of the data value and it makes no difference. I've tried a bare value, a quoted value and a double quoted value. I've tried using a hash like the Read() returns or a ref to that hash. Apart from Swahili, Sanskrit or Welsh I've expressed VALUE in every way I can think of. Here's an online version of the help http://www.opcconnect.com/perl/OPC.html#opcitem<b>Write(VALUE)</b> Write VALUE to this item.
The example supplied with the package, groups.pl, gives exactly the same error for writes. Any monks in the monestary familiar with OPC?
Cheers
nonk
In reply to Win32::OLE error by nonnonymousnonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |