From 70892601f9ac41dd6f8084a3dd420caed3886568 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 11 Apr 2012 11:57:49 +0000 Subject: [PATCH] fixed bug in trb_read_uid, wrong hash format --- libtrbnet_perl/lib/HADES/TrbNet.pm | 7 +++---- libtrbnet_perl/test/test.pl | 12 +++++++----- libtrbnet_perl/test/test_readtime.pl | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libtrbnet_perl/lib/HADES/TrbNet.pm b/libtrbnet_perl/lib/HADES/TrbNet.pm index 80592ba..ae85ab7 100644 --- a/libtrbnet_perl/lib/HADES/TrbNet.pm +++ b/libtrbnet_perl/lib/HADES/TrbNet.pm @@ -10,7 +10,7 @@ require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. +# names by default withX1out a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use HADES::TrbNet ':all'; @@ -133,10 +133,9 @@ sub trb_read_uid { for (my $k = 0; $k < scalar @res; $k += 4) { my $uid = ($res[$k] << 32) | $res[$k + 1]; my $endP = $res[$k + 2]; - my $sender = $res[$k + 3]; + my $trb_address = $res[$k + 3]; - $hash{$uid}->{'trb_address'} = $sender; - $hash{$uid}->{'trb_endpoint'} = $endP; + $hash{$uid}->{$endP} = $trb_address; } return \%hash; diff --git a/libtrbnet_perl/test/test.pl b/libtrbnet_perl/test/test.pl index 2c6df71..55671db 100755 --- a/libtrbnet_perl/test/test.pl +++ b/libtrbnet_perl/test/test.pl @@ -10,12 +10,14 @@ trb_init_ports() or die "Failed trb_init_ports: ", trb_strerror(); my $ref; my @array; # Read all UIDs as hash -$ref = trb_read_uid(0xfffb) or die "trb_read_uid: ", trb_strerror(); -foreach my $cur_key (sort {$a <=> $b } keys %$ref) { - printf "uid: 0x%016x ==> addr: 0x%04x: endpoint: 0x%02x\n", $cur_key, - $ref->{$cur_key}->{'trb_address'}, $ref->{$cur_key}->{'trb_endpoint'} ; -} +$ref = trb_read_uid(0xffff) or die "trb_read_uid: ", trb_strerror(); #print Dumper $ref; +foreach my $uid (sort {$a <=> $b } keys %$ref) { + foreach my $endp (sort {$a <=> $b } keys $ref->{$uid}) { + printf "uid: 0x%016x ==> addr: 0x%04x: endpoint: 0x%02x\n", + $uid, $ref->{$uid}->{$endp}, $endp ; + } +} # Read all UIDs as array @array = trb_read_uid_c(0xfffb) or die "trb_read_uid: ", trb_strerror(); diff --git a/libtrbnet_perl/test/test_readtime.pl b/libtrbnet_perl/test/test_readtime.pl index 6f70f02..68f21bf 100755 --- a/libtrbnet_perl/test/test_readtime.pl +++ b/libtrbnet_perl/test/test_readtime.pl @@ -2,18 +2,19 @@ use warnings; use strict; use Data::Dumper; - use HADES::TrbNet; trb_init_ports() or die "Failed trb_init_ports: ", trb_strerror(); my $ref; -$ref = trb_registertime_read(0x8001, 0x0) or die "trb_registertime_read: ", +$ref = trb_registertime_read(0xffff, 0x0) or die "trb_registertime_read: ", trb_strerror(); print Dumper $ref; +print "Hallo: ". $ref->{8790}->{'value'}[0]."\n"; +exit 1; $ref = trb_registertime_read_mem(0x8001, 0x4031, 0, 3) or die "trb_registertime_read_mem: ", trb_strerror(); -- 2.43.0