Closed sparvu closed 8 years ago
The slow part comes when getting data from device:
DB<2>
main::(./rs485rec_2:17): my $req = $client->read_input_registers(
main::(./rs485rec_2:18): unit => 1,
main::(./rs485rec_2:19): address => 0,
main::(./rs485rec_2:20): quantity => 12
main::(./rs485rec_2:21): );
DB<2> n
main::(./rs485rec_2:23): $client->send_request($req);
DB<2> n
main::(./rs485rec_2:24): my $resp = $client->receive_response;
DB<2>
which sometimes ends with this error:
Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/RTU.pm line 105.
at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/ADU.pm line 44.
Device::Modbus::ADU::unit(Device::Modbus::RTU::ADU=HASH(0x8158d8), 0) called at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/RTU.pm line 105
Device::Modbus::RTU::parse_header(Device::Modbus::RTU::Client=HASH(0x47acc0), Device::Modbus::RTU::ADU=HASH(0x8158d8)) called at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/Client.pm line 82
Device::Modbus::Client::receive_response(Device::Modbus::RTU::Client=HASH(0x47acc0)) called at ./rs485rec_2 line 24
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<2> Use 'q' to quit or 'R' to restart. 'h q' for details.
It takes 2minutes+ to read data from this device. Not sure why.
krmx@raspberrypi:~ $ time /opt/kronometrix/bin/rs485rec
$VAR1 = bless( {
'message' => bless( {
'values' => [
17355,
0,
16595,
13107,
16852,
0,
16888,
0,
406,
66,
265,
310
],
'bytes' => 24,
'code' => 4,
'function' => 'Read Input Registers'
}, 'Device::Modbus::Response' ),
'unit' => 1,
'crc' => 19068
}, 'Device::Modbus::RTU::ADU' );
real 2m25.348s
user 0m1.500s
sys 0m0.710s
Trying to read using function 4, I get these values:
krmx@raspberrypi:/opt/kronometrix/bin $ time /opt/kronometrix/bin/rs485rec
timeout=865.4375
timeout=730.875
timeout=596.3125
timeout=461.75
timeout=327.1875
timeout=192.625
timeout=58.0625
timeout=-76.5
$VAR1 = bless( {
#!/opt/kronometrix/perl/bin/perl
'unit' => 1,
'crc' => 31385,
'message' => bless( {
'values' => [
405,
66,
268,
312
],
'code' => 4,
'function' => 'Read Input Registers',
'bytes' => 8
}, 'Device::Modbus::Response' )
}, 'Device::Modbus::RTU::ADU' );
real 0m23.482s
user 0m0.660s
sys 0m0.080s
krmx@raspberrypi:/opt/kronometrix/bin $ time /opt/kronometrix/bin/rs485rec
timeout=865.4375
timeout=730.875
timeout=596.3125
#!/opt/kronometrix/perl/bin/perl
timeout=461.75
timeout=327.1875
timeout=192.625
timeout=58.0625
timeout=-76.5
Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.24.0/Device/Modbus/RTU.pm line 106.
real 0m11.587s
user 0m0.540s
sys 0m0.110s
krmx@raspberrypi:/opt/kronometrix/bin $ time /opt/kronometrix/bin/rs485rec
timeout=865.4375
timeout=730.875
timeout=596.3125
timeout=461.75
timeout=327.1875
timeout=192.625
timeout=58.0625
timeout=-76.5
Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.24.0/Device/Modbus/RTU.pm line 106.
real 0m23.480s
user 0m0.670s
sys 0m0.060s
krmx@raspberrypi:/opt/kronometrix/bin $ vi rs485rec
krmx@raspberrypi:/opt/kronometrix/bin $ time /opt/kronometrix/bin/rs485rec
timeout=1865.4375
timeout=1730.875
timeout=1596.3125
timeout=1461.75
timeout=1327.1875
timeout=1192.625
timeout=1058.0625
timeout=923.5
timeout=788.9375
timeout=654.375
timeout=519.8125
timeout=385.25
timeout=250.6875
timeout=116.125
timeout=-18.4375
Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.24.0/Device/Modbus/RTU.pm line 106.
real 0m44.478s
user 0m0.810s
sys 0m0.110s
krmx@raspberrypi:/opt/kronometrix/bin $ vi rs485rec
krmx@raspberrypi:/opt/kronometrix/bin $ time /opt/kronometrix/bin/rs485rec
timeout=1365.4375
timeout=1230.875
timeout=1096.3125
timeout=961.75
timeout=827.1875
timeout=692.625
timeout=558.0625
timeout=423.5
timeout=288.9375
timeout=154.375
timeout=19.8125
timeout=-114.75
Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.24.0/Device/Modbus/RTU.pm line 106.
real 0m15.272s
user 0m0.590s
sys 0m0.060s
krmx@raspberrypi:/opt/kronometrix/bin $
not an issue anymore. https://github.com/jfraire/Device-Modbus/issues/2
We are experimenting with a MODBUS device, for Indoor Air Quality. The device works nice and supports MODBUS RTU.
For some reason it takes forever until I see some values back from this device on screen. Not sure why. Can I somehow put a debug on the RTU line and see more about whats happening within ?