Skip to content

mb2hal tests: accept any comp id#2456

Merged
SebKuzminsky merged 1 commit into2.8from
fix-mb2hal-tests-on-rtai
Apr 29, 2023
Merged

mb2hal tests: accept any comp id#2456
SebKuzminsky merged 1 commit into2.8from
fix-mb2hal-tests-on-rtai

Conversation

@SebKuzminsky
Copy link
Copy Markdown
Collaborator

uspace and RTAI assign different component ids at component load-time.

This test used to verify that the mb2hal component got a specific component id, which means it only worked on uspace, and always failed on RTAI.

This commit makes the tests ignore the component ids, but still verify everything they actually care about.

uspace and RTAI assign different component ids at component load-time.

This test used to verify that the mb2hal component got a specific
component id, which means it only worked on uspace, and always failed
on RTAI.

This commit makes the tests ignore the component ids, but still verify
everything they actually care about.
@SebKuzminsky SebKuzminsky requested a review from hansu April 29, 2023 15:32
@SebKuzminsky
Copy link
Copy Markdown
Collaborator Author

This fixes the comp id issue with #2274 on RTAI.

@SebKuzminsky SebKuzminsky changed the base branch from master to 2.8 April 29, 2023 15:37
@hansu
Copy link
Copy Markdown
Member

hansu commented Apr 29, 2023

Yeah this looks good. Thank you for fixing my tests! 😇
(I only would have chosen something without spaces like IGNORED_COMP_ID)
Only need to be done again for the additional tests added for 2.9.

@SebKuzminsky SebKuzminsky merged commit 9df9b64 into 2.8 Apr 29, 2023
@SebKuzminsky SebKuzminsky deleted the fix-mb2hal-tests-on-rtai branch April 29, 2023 21:30
@SebKuzminsky
Copy link
Copy Markdown
Collaborator Author

@hansu well it looks like my fix is incomplete. These two builds are the current tip of 2.8 (9df9b64), which includes the comp_id/sed fix:

In both cases the test runs, but the output from mb2hal is truncated:

mb2hal main OK: init_gbl.mb_tx done OK
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.Modbus_fnct_02.num_errors]
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.Modbus_fnct_02.00]
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.Modbus_fnct_02.01]
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.Modbus_fnct_02.02]
mb2hal create_each_mb_tx_hal_pins DEBUG: mb_tx_num [0] pin_name [mb2hal.ModbERROR Can't open the device /dev/ttyUSB0 (No such file or directory)
ERROR Can't open the device /dev/ttyUSB0 (No such file or directory)
ERROR Can't open the device /dev/ttyUSB0 (No such file or directory)
ERROR Can't open the device /dev/ttyUSB0 (No such file or directory)
ERROR Can't open the device /dev/ttyUSB0 (No such file or directory)
ERROR Can't open the device /dev/ttyUSB0 (No such file or directory)

The truncated output doesn't match the expected output (of course) so the test fails. Any input on this one?

@SebKuzminsky
Copy link
Copy Markdown
Collaborator Author

Aha! It leaves behind a core file from mb2hal...

@SebKuzminsky
Copy link
Copy Markdown
Collaborator Author

Here's the backtrace, in case that helps you identify the problem:

$ gdb ../../../bin/mb2hal core
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/seb/linuxcnc-dev/bin/mb2hal...done.
[New LWP 9242]
[New LWP 9241]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
Core was generated by `mb2hal config=mb2hal.ini'.
Program terminated with signal 11, Segmentation fault.
#0  0xb762aa48 in modbus_set_socket () from /usr/lib/libmodbus.so.5
(gdb) bt
#0  0xb762aa48 in modbus_set_socket () from /usr/lib/libmodbus.so.5
#1  0x08049783 in get_tx_connection (this_mb_tx_num=4, ret_connected=0xb72f036c)
    at hal/user_comps/mb2hal/mb2hal.c:342
#2  0x08049c69 in link_loop_and_logic (thrd_link_num=0x9240204) at hal/user_comps/mb2hal/mb2hal.c:172
#3  0xb7735c39 in start_thread () from /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
#4  0xb75998be in clone () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
(gdb)

It looks like get_tx_connection() calls modbus_set_socket() with invalid arguments and it crashes there.

@hansu
Copy link
Copy Markdown
Member

hansu commented Apr 30, 2023

Probably just because the host doest not have a /dev/ttyUSB0.

I changed the test to use TCP, so let's see if that helps: #2455

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

Successfully merging this pull request may close these issues.

2 participants