Skip to content

2.9 issue#3859#3975

Open
JTrantow wants to merge 8 commits into
LinuxCNC:2.9from
JTrantow:2.9_Issue#3859
Open

2.9 issue#3859#3975
JTrantow wants to merge 8 commits into
LinuxCNC:2.9from
JTrantow:2.9_Issue#3859

Conversation

@JTrantow
Copy link
Copy Markdown
Contributor

This PR extends the hm2_test component and provides unit tests for the BUG2 portion of #3859. To open a modbus component for simulation the hm2_test component emulates enough of a 7i96 with pktuart to load the modbus component.

A more general solution would be to implement a user component that could load an arbitrary fpga dump into the test pattern memory. But this is enough to test the modbus delays for various bauds and parity conditions.

Further development will be required before hw2_test can be used to test the BUG1 portion of $3859.

JTrantow added 8 commits March 16, 2026 13:58
Modifies hm2_test to load a mesa variable dump, so modbus can get spoofed.
test_pattern15.h will be removed when I finish shared memory initialization via _usr component.
…om test_pattern15.h dumped from my 7i96.

This is enough fool hm2_modbus into initializing it's parameters for testing.

When user level component is working the test_pattern memory will be shared and the _usr component will load file (for any mesa fpga).
Comment on lines +39 to +40
const uint32_t config_memory_dump[] = {
0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headers should not be used to embed data. Use a separate C-file you link in to define the data.

Secondly, can this data not be derived from the original bit-file(s) to program the card?

#
# Convert each mbcc source file to binary.
#
for MBCCS in $(ls *.mbccs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call ls?

#
for MBCCS in $(ls *.mbccs)
do
MBCCB=$(echo "$MBCCS" | sed 's/mbccs$/mbccb/')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is usually done with basename (and dirname if necessary) constructs.

# Run HAL with each test .mbccb
#
TEST_PATTERN=15
for MBCCB in $(ls *.mbccb)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again superfluous ls

Comment on lines +46 to +49
arr=($(grep "hm2_modbus.0.baudrate" halrun-stdout))
baudrate=$(echo "${arr[3]}" | sed 's/0x0\+/0/')
baudrate=$((16#$baudrate))
echo " baudrate = $baudrate"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be easier done using awk? Then you can do all in a simple script.

Comment thread .gitignore
configs/**/halshow.preferences
/tests/hm2-modbus/modbus-Params/*.mbccb
/tests/hm2-modbus/modbus-Params/halrun-stderr
/tests/hm2-modbus/modbus-Params/halrun-stdout
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do not belong in the top-level .gitignore file. These need to go into a local file at tests/hm2-modus/.gitignore Also, they are absolute paths that should be relative.

@@ -0,0 +1,131 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all these files located in a subdirectory modbus-Params? There is only one test and those are generally not put into subdirectories. Are you planning on adding more? which?

(and directory/file names should generally be lower case).

Comment on lines +4 to +7
# This script will dump the current configuration memory to the command line.
# Use ./dump_config.sh >> test_pattern15.h to capture your configuration to a file. Replace 7i96 with your firmware name.

# Want to use --rpo from 0x0000 - 0x6100.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the other dump script will only work if you have the specific card and it is on the network.

The more versatile way is to create the config from the bit-file and make that loadable by the hm2_test component. Then you don't have any static config in the test component either.

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