Reading Coil #111
Unanswered
Elmatbaisaad
asked this question in
Q&A
Replies: 3 comments 12 replies
-
What does it say? Is there an error? This is how I test:
<?php
require __DIR__ . '/../vendor/autoload.php';
use ModbusTcpClient\Composer\Read\ReadCoilsBuilder;
use ModbusTcpClient\Network\NonBlockingClient;
$fc3 = ReadCoilsBuilder::newReadCoils('tcp://127.0.0.1:5022')
->coil(0, "my_coil")
->build();
$responseContainer = (new NonBlockingClient(['readTimeoutSec' => 0.2]))->sendRequests($fc3);
var_dump($responseContainer->getData()); // array of assoc. arrays (keyed by address name)
var_dump($responseContainer->getErrors());
x@x:~/code/modbus-tcp-client/examples$ php -v
PHP 8.1.2 (cli) (built: Jan 24 2022 10:42:51) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
x@x:~/code/modbus-tcp-client/examples$ php coils_builder.php
/home/x/code/modbus-tcp-client/examples/coils_builder.php:13:
array(1) {
'my_coil' =>
bool(false)
}
/home/x/code/modbus-tcp-client/examples/coils_builder.php:14:
array(0) {
}
x@x:~/code$ ./diagslave -m tcp -p 5022
diagslave 3.1 - FieldTalk(tm) Modbus(R) Diagnostic Slave Simulator
Copyright (c) 2002-2018 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: MODBUS/TCP
Slave configuration: address = -1, master activity t/o = 3.00
IP configuration: port = 5022, connection t/o = 60.00
Server started up successfully.
Listening to network (Ctrl-C to stop)
............
validateMasterIpAddr: accepting connection from 127.0.0.1
Slave 0: readCoils from 1, 1 references
.................................................... |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
5 replies
-
Here is my code, I really don't know where this come from |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone i m working on a project where i must read coils and registers i succed in reading registers but not in coils .
I m trying this code but its not working to exlain what i want :
Beta Was this translation helpful? Give feedback.
All reactions