Skip to content
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

I`m getting a wrong packet on fc16 #19

Closed
bordm opened this issue Jan 23, 2019 · 1 comment
Closed

I`m getting a wrong packet on fc16 #19

bordm opened this issue Jan 23, 2019 · 1 comment

Comments

@bordm
Copy link

bordm commented Jan 23, 2019

With this code:

    $startAddress = 0x0000;
    $registers = array("b0", "x-", "00", "00", "25", " 3");

    /** @var WriteMultipleRegistersRequest $packet */
    $packet = new WriteMultipleRegistersRequest($startAddress, $registers, 0);

    var_dump($packet->toHex()); die();

I am getting string

    d7f0000000110010000000060c6230782d3030303032352033

which is wrong, there must be length 0x0013, not 0x0011.
https://github.com/MightyPork/phpmodbus library did it right

@aldas
Copy link
Owner

aldas commented Jan 26, 2019

Fixed that one. Thanks for pointing that out.

by the ways. are trying to send ascii characters? as you see " 3" will be converted to 0x2003

There is example in tests to convert integers etc to bytes:

$registers = [Types::toByte(200), Types::toInt16(130), Types::toUint16(34561)];

@aldas aldas closed this as completed Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants