[bcn-pm] Problemilla con arrays
Xavier Noria
fxn at hashref.com
Mon Feb 14 10:59:23 PST 2005
On Feb 14, 2005, at 19:00, Josep M. Mendoza wrote:
> sub writeMultipleRegisters(){
> my ($self, $Address, $Length, @data) = @_;
> my $wordCount = $Length;
> my $byteCount = ($Length * 2);
> carp ("Length of data array error") unless (@data == $byteCount);
[...]
> my ($result) = $serverConnection->writeMultipleRegisters(120, 3,
> $hour, $min,
> $sec);
[...]
> jmendoza at odin:~/Desenvolupament/Net-ModbusRTU$ ./write-time
> Length of data array error at ./write-time line 12
En esa llamada al metodo writeMultipleRegisters tenemos
$Address = 120
$Length = 3
@data = ($hour, $min, $sec)
De acuerdo al codigo $byteCount es 6, que es distinto de 3. Es un bug?
Para darle vueltas al tema, por que pasas $Length? No seria calculable
a partir de @data? $Length = @data/2?
-- fxn
More information about the Barcelona-pm
mailing list