mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add test for WriteRegister
This commit is contained in:
parent
608e2c7065
commit
729ce8a497
@ -4,10 +4,13 @@ mb_tcp = modbus.ModBusRTU(128, 128)
|
|||||||
mb_tcp.setSlave(1)
|
mb_tcp.setSlave(1)
|
||||||
|
|
||||||
send_buff = mb_tcp.serializeReadRegisters(0, 10)
|
send_buff = mb_tcp.serializeReadRegisters(0, 10)
|
||||||
|
print(send_buff)
|
||||||
|
|
||||||
host_regists = mb_tcp.deserializeReadRegisters(
|
host_regists = mb_tcp.deserializeReadRegisters(
|
||||||
b'\x01\x03\x14\x00\x00\x00\x00\x04\xD2\x00\x00\x00\x00\x00\x7B\x00\x00\x00\x00\x00\x00\x00\x00\xE5\x0B'
|
b'\x01\x03\x14\x00\x00\x00\x00\x04\xD2\x00\x00\x00\x00\x00\x7B\x00\x00\x00\x00\x00\x00\x00\x00\xE5\x0B'
|
||||||
)
|
)
|
||||||
|
|
||||||
print(send_buff)
|
|
||||||
print(host_regists)
|
print(host_regists)
|
||||||
|
|
||||||
|
|
||||||
|
send_buff = mb_tcp.serializeWriteRegister(0, 0x1234)
|
||||||
|
print(send_buff)
|
||||||
|
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
|||||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||||
"args": [
|
"args": [
|
||||||
"--gtest_filter=vm.super_val_"
|
// "--gtest_filter=vm.super_val_"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
|
@ -322,10 +322,12 @@ TEST(modbus, rtu_master) {
|
|||||||
pikaVM_runSingleFile(pikaMain, "test/python/modbus/rtu_master.py");
|
pikaVM_runSingleFile(pikaMain, "test/python/modbus/rtu_master.py");
|
||||||
/* collect */
|
/* collect */
|
||||||
/* assert */
|
/* assert */
|
||||||
EXPECT_STREQ(log_buff[2], "BEGIN\r\n");
|
EXPECT_STREQ(log_buff[3], "BEGIN\r\n");
|
||||||
EXPECT_STREQ(log_buff[1],
|
EXPECT_STREQ(log_buff[2],
|
||||||
"b'\\x01\\x03\\x00\\x00\\x00\\x0a\\xc5\\xcd'\r\n");
|
"b'\\x01\\x03\\x00\\x00\\x00\\x0a\\xc5\\xcd'\r\n");
|
||||||
EXPECT_STREQ(log_buff[0], "[0, 0, 1234, 0, 0, 123, 0, 0, 0, 0]\r\n");
|
EXPECT_STREQ(log_buff[1], "[0, 0, 1234, 0, 0, 123, 0, 0, 0, 0]\r\n");
|
||||||
|
EXPECT_STREQ(log_buff[0],
|
||||||
|
"b'\\x01\\x06\\x00\\x00\\x12\\x34\\x84\\xbd'\r\n");
|
||||||
/* deinit */
|
/* deinit */
|
||||||
obj_deinit(pikaMain);
|
obj_deinit(pikaMain);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
@ -4,10 +4,13 @@ mb_tcp = modbus.ModBusRTU(128, 128)
|
|||||||
mb_tcp.setSlave(1)
|
mb_tcp.setSlave(1)
|
||||||
|
|
||||||
send_buff = mb_tcp.serializeReadRegisters(0, 10)
|
send_buff = mb_tcp.serializeReadRegisters(0, 10)
|
||||||
|
print(send_buff)
|
||||||
|
|
||||||
host_regists = mb_tcp.deserializeReadRegisters(
|
host_regists = mb_tcp.deserializeReadRegisters(
|
||||||
b'\x01\x03\x14\x00\x00\x00\x00\x04\xD2\x00\x00\x00\x00\x00\x7B\x00\x00\x00\x00\x00\x00\x00\x00\xE5\x0B'
|
b'\x01\x03\x14\x00\x00\x00\x00\x04\xD2\x00\x00\x00\x00\x00\x7B\x00\x00\x00\x00\x00\x00\x00\x00\xE5\x0B'
|
||||||
)
|
)
|
||||||
|
|
||||||
print(send_buff)
|
|
||||||
print(host_regists)
|
print(host_regists)
|
||||||
|
|
||||||
|
|
||||||
|
send_buff = mb_tcp.serializeWriteRegister(0, 0x1234)
|
||||||
|
print(send_buff)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user