-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
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
Limitation of Unit ID #159
Labels
Comments
As a immediate workaround - you can change the unitID value after packet has been created. $packet = new ReadHoldingRegistersRequest($startAddress, $quantity, $unitID);
$packet[6] = 255; For example: unit ID is 7th byte for FC3 request. modbus-tcp-client/src/Packet/ModbusFunction/ReadHoldingRegistersRequest.php Lines 17 to 24 in 53657b3
|
Thanks for fast reply, but i fear it's not as easy as it seems for me:
1) I'm using this library for several modbus devices (wallbox, inverter, battery), therefore workaround with fixed ID will not work.
2) I tried to remove the limit here:
private function validate(int $length, int $unitId, int|null $transactionId): void
{
if (!$length || !($length > 0 && $length <= Types::MAX_VALUE_UINT16)) {
throw new InvalidArgumentException("length is not set or out of range (uint16): {$length}");
}
if (!($unitId >= 0 && $unitId <= 257)) {
throw new InvalidArgumentException("unitId is out of range (0-257): {$unitId}");
but it doesn't has impact. Unfortunately I don't know what composer does on my installation, perhaps there is something like compiling? I don't know how to handle this properly.
best regards
P.S.: there is also a message:
Cannot use aldas/modbus-tcp-client's latest version 3.5.0 as it requires php ^8.0 which is not satisfied by your platform.
I'm still on 7.2.34
Gesendet: Donnerstag, 22. Februar 2024 um 23:22 Uhr
Von: "Martti T." ***@***.***>
An: "aldas/modbus-tcp-client" ***@***.***>
Cc: "Winni66" ***@***.***>, "Author" ***@***.***>
Betreff: Re: [aldas/modbus-tcp-client] Limitation of Unit ID (Issue #159)
As a immediate workaround - you can change the unitID value after packet has been created.
$packet = new ReadHoldingRegistersRequest($startAddress, $quantity, $unitID);
$packet[6] = 255;
For example: unit ID is 7th byte for FC3 request.
https://github.com/aldas/modbus-tcp-client/blob/53657b3de8f90c9e6727c9aca841b3e355fbe554/src/Packet/ModbusFunction/ReadHoldingRegistersRequest.php#L21
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I think you could create custom patch for PHP 7 to remove that validation check and let composer to apply it. See |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I'm quite new to Modbus topic. This library is used within one Smarthome solution called Edomi. I'm using a Webasto Wallbox which uses Unit ID 255 and unfortunately this library allowes only ID up to 247. It's not possible to change.
Describe the solution you'd like
Would it be possible to disable ID limitation? I'm not able to build my own library for that, because I don't have the skills.
The text was updated successfully, but these errors were encountered: