We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is the code I'm trying to retrieve data from the register.
require 'PhpSerialModbus.php';
$modbus = new PhpSerialModbus;
$modbus->deviceInit('COM3',19200,'none',8,1,'none');
$modbus->deviceOpen();
$startaddress = 3371;
while($startaddress!=3380) { $modbus->debug = true; echo $hex_addr = strval(dechex($startaddress)); echo ""; echo $startaddress; echo ""; $result=$modbus->sendQuery(11,3,$hex_addr,2); if(print_r($result)){ echo ""; $startaddress++; }
}
Output : I receive null output.
The datasheet of the device I'm trying to connect.
I'm not sure what I'm missing. There are not a lot of community on internet to research about.
Kindly help me through. Thanks in advance.
The text was updated successfully, but these errors were encountered:
$hex_addr = "D2B" The way sendQuery() parses the data, it sends "D20B" (53771)
sendQuery()
will need to add str_pad($hex_addr,4,"0",STR_PAD_LEFT); in your code to make it a 4 character string
str_pad($hex_addr,4,"0",STR_PAD_LEFT);
or add $registerAddress = str_pad($registerAddress,4,"0",STR_PAD_LEFT); at line 111 of PhpSerialModbus.php
$registerAddress = str_pad($registerAddress,4,"0",STR_PAD_LEFT);
Sorry, something went wrong.
No branches or pull requests
This is the code I'm trying to retrieve data from the register.
require 'PhpSerialModbus.php';
$modbus = new PhpSerialModbus;
$modbus->deviceInit('COM3',19200,'none',8,1,'none');
$modbus->deviceOpen();
$startaddress = 3371;
while($startaddress!=3380)
{
$modbus->debug = true;
echo $hex_addr = strval(dechex($startaddress));
echo "
";
echo $startaddress;
echo "
";
$result=$modbus->sendQuery(11,3,$hex_addr,2);
if(print_r($result)){
echo "
";
$startaddress++;
}
}
Output : I receive null output.
The datasheet of the device I'm trying to connect.
I'm not sure what I'm missing. There are not a lot of community on internet to research about.
Kindly help me through. Thanks in advance.
The text was updated successfully, but these errors were encountered: