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

Address mismatch between READ and WRITE #2

Open
locodust6 opened this issue Aug 5, 2022 · 1 comment
Open

Address mismatch between READ and WRITE #2

locodust6 opened this issue Aug 5, 2022 · 1 comment

Comments

@locodust6
Copy link

Now, READ and WRITE have to change the address specification.

For example, to control W20, you need to do the following:

//READ
PLCData<short> devices = new(PlcDeviceType.W, 0x20, 1);

//WRITE
PLCData<short> devices2 = new(PlcDeviceType.W, 20, 1);

This seems to be because READ uses the specified address itself, and WRITE regards the specified address as a hexadecimal number and converts it to a decimal number.

@ping9719
Copy link
Owner

ping9719 commented Aug 8, 2022

在C#中,’0x20‘中的'0x'表示20是16进制,也就是说:0x20=32,20=0x14,0x20!=20;
代码中更推荐你使用10进制

10 16(0x) type
32 20 /
20 14 /
255 FF byte
65535 FFFF UInt16

我在测试中没有发现你说的问题。如果仍然有问题,你可以:

1.尝试使用方式1来试试(https://github.com/ping9719/McProtocol/blob/master/README.md#方式1-method-1)
2.提供详细的控制台测试代码

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