Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ docs/help/vi/*
docs/help/zh_CN/*
configs/**/*.tbl.bak
configs/**/halshow.preferences
/tests/hm2-modbus/modbus-Params/*.mbccb
/tests/hm2-modbus/modbus-Params/halrun-stderr
/tests/hm2-modbus/modbus-Params/halrun-stdout
94 changes: 92 additions & 2 deletions src/hal/drivers/mesa-hostmot2/hm2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,97 @@ int rtapi_app_main(void) {
break;
}

/*
7i96 configuration, enough to load pktUart driver.
Use script based on
mesaflash --addr 10.10.10.10 --device 7i96 --rpo 0x0100
to find the memory values.
*/
case 15: {
LL_PRINT("test pattern %d, llio and pattern copy\n", test_pattern);
static const char *hm2_7i96_pin_names[] = {
"TB3-01",
"TB3-02",
"TB3-03",
"TB3-04",
"TB3-05",
"TB3-06",
"TB3-07",
"TB3-08",
"TB3-09",
"TB3-10",
"TB3-11",
"TB3-13/TB3-14",
"TB3-15/TB3-16",
"TB3-17/TB3-18",
"TB3-19/TB3-20",
"TB3-21/TB3-22",
"TB3-23/TB3-24",

"TB1-02/TB1-03",
"TB1-04/TB1-05",
"TB1-08/TB1-09",
"TB1-10/TB1-11",
"TB1-14/TB1-15",
"TB1-16/TB1-17",
"TB1-20/TB1-21",
"TB1-22-TB1-23",

"TB2-02/TB2-03",
"TB2-04/TB2-05",
"TB2-07/TB2-08",
"TB2-10/TB2-11",
"TB2-13/TB2-14",
"TB2-16/TB2-17",
"TB2-18/TB2-19",

"internal", /* SSerial TXEN */
"internal", /* SSR AC Reference pin */

"P1-01/DB25-01", /* P1 parallel expansion */
"P1-02/DB25-14",
"P1-03/DB25-02",
"P1-04/DB25-15",
"P1-05/DB25-03",
"P1-06/DB25-16",
"P1-07/DB25-04",
"P1-08/DB25-17",
"P1-09/DB25-05",
"P1-11/DB25-06",
"P1-13/DB25-07",
"P1-15/DB25-08",
"P1-17/DB25-09",
"P1-19/DB25-10",
"P1-21/DB25-11",
"P1-23/DB25-12",
"P1-25/DB25-13",
};

/*
low level needs setup per board.
Copy this block from hm2_eth.c for your configuration.
*/
//memcpy(llio_name, "7i96", 4);
me->llio.num_ioport_connectors = 3;
me->llio.pins_per_connector = 17;
me->llio.io_connector_pin_names = (char**)hm2_7i96_pin_names;

me->llio.ioport_connector_name[0] = "P1"; // DB25, 17 pins used, IO 34 to IO 50
me->llio.ioport_connector_name[1] = "TB1"; // terminal block, 8 pins used, Step & Dir 0-3
me->llio.ioport_connector_name[2] = "TB2"; // terminal block, 7 pins used, Step & Dir 4, Enc A, B, Z, serial Rx/Tx
me->llio.ioport_connector_name[3] = "TB3"; // terminal block, 11 inputs, 6 SSR outputs

me->llio.fpga_part_number = "6slx9tqg144";
me->llio.num_leds = 4;

/*
Fill memory based on 7i96.
*/
size_t pattern_size = (sizeof(me->test_pattern) > sizeof(config_memory_dump)) ? sizeof(config_memory_dump) : sizeof(me->test_pattern);
(void)memcpy(me->test_pattern.tp8, config_memory_dump, pattern_size);
break;
}

default: {
LL_ERR("unknown test pattern %d", test_pattern);
return -ENODEV;
Expand Down Expand Up @@ -592,5 +683,4 @@ void rtapi_app_exit(void) {

LL_PRINT("driver unloaded\n");
hal_exit(comp_id);
}

}
783 changes: 783 additions & 0 deletions src/hal/drivers/mesa-hostmot2/hm2_test.h

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions tests/hm2-modbus/modbus-Params/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

This is a test of the hm2_modbus driver parameter settings.

Create a fake device using dump_config.sh.
40 changes: 40 additions & 0 deletions tests/hm2-modbus/modbus-Params/dump_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

#
# 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.
#
ADDR=0
#END=0x6100 or decimal 24832

# format output in columns.
COLUMN=0

echo "/*"
echo " Header file containing configuration memory dump."
echo " You may use tests/hm-test/dump_config.sh to create this file."
echo "*/"
echo ""
echo "#pragma once"
echo ""
echo "const uint32_t config_memory_dump[] = {"

while [ $ADDR -lt 24832 ]
do
echo -n "0x"

mesaflash --addr 10.10.10.10 --device 7i96 --rpo $ADDR | tr "\n" ", "

if [ $COLUMN -lt 7 ]; then
COLUMN=$(( $COLUMN + 1 ))
else
COLUMN=0
echo ""
fi

ADDR=$(( $ADDR + 4 ))
done

echo "};"
40 changes: 40 additions & 0 deletions tests/hm2-modbus/modbus-Params/dump_config2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

#
# 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.
# Use ./dump_config.sh >> test_pattern15.b to capture your configuration to a binary file.

# Want to use --rpo from 0x0000 - 0x6100.
#
ADDR=0
#END=0x6100 or decimal 24832

# format output in columns.
COLUMN=0

echo "/*"
echo " Header file containing configuration memory dump."
echo " You may use tests/hm-test/dump_config.sh to create this file."
echo "*/"
echo ""
echo "#pragma once"
echo ""
echo "const uint32_t config_memory_dump[] = {"


while [ $ADDR -lt 24832 ]
do
echo -n "0x"

v=$(mesaflash --addr 10.10.10.10 --device 7i96 --rpo $ADDR)

echo "mesaflash returns $v for $ADDR"
#var_value=$(echo "${arr[3]}" | sed 's/0x0\+//')

print "%u" $ADDR

ADDR=$(( $ADDR + 4 ))
done

echo "};"
50 changes: 50 additions & 0 deletions tests/hm2-modbus/modbus-Params/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

baudrate = 1200
drivedelay = 2
icdelay = 16
parity = 2
rxdelay = 38
stopbits = 1
txdelay = 40

baudrate = 19200
drivedelay = 1
icdelay = 16
parity = 3
rxdelay = 38
stopbits = 1
txdelay = 40

baudrate = 19200
drivedelay = 3
icdelay = 16
parity = 2
rxdelay = 38
stopbits = 1
txdelay = 40

baudrate = 38400
drivedelay = 1
icdelay = 29
parity = 0
rxdelay = 67
stopbits = 2
txdelay = 69

baudrate = 115200
drivedelay = 1
icdelay = 87
parity = 2
rxdelay = 201
stopbits = 1
txdelay = 203

baudrate = 1000000
drivedelay = 1
icdelay = 255
parity = 2
rxdelay = 1019
stopbits = 1
txdelay = 1021
Number of errors 0
All tests passed.
17 changes: 17 additions & 0 deletions tests/hm2-modbus/modbus-Params/modbus_test.hal
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# HAL for modbus testing.
#
#loadrt hostmot2 debug_idrom=1 debug_pin_descriptors=1 debug_module_descriptors=1
loadrt hostmot2

#
# Load hm2_test that allows us to run test without physical mesa board or ethernet or RS485.
# TEST_PATTERN goes to the realtime hm2_test component.
#
loadrt hm2_test test_pattern=$(TEST_PATTERN)

#
# Now load the component with the configuration we want to test.
#
loadrt hm2_modbus ports=hm2_test.0.pktuart.0 mbccbs=$(TEST_MBCCB)
show param hm2_modbus.0
Loading
Loading