Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -e
TESTDIR=$(dirname "$1")
cd "${TESTDIR}"
# HAL assigns each component a unique component ID at load-time.
# The RTAI and uspace HAL implementations assign different component IDs,
# so remove all mentions of specific component IDs from the result file,
# so that a single `expected` file works for both.
sed --in-place --regexp-extended --expression='s/^( *)[0-9]+(.*mb2hal.Modbus_fnct_.*)$/\1(ignored comp id)\2/' result
diff -u expected result

View File

@@ -0,0 +1,69 @@
Component Pins:
Owner Type Dir Value Name
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.00.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_02.00.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.01.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_02.01.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.02.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_02.02.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_02.03.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_02.03.bit-inv
Component Pins:
Owner Type Dir Value Name
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.00.float
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.00.int
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.01.float
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.01.int
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.02.float
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.02.int
(ignored comp id) float OUT 0 mb2hal.Modbus_fnct_03.03.float
(ignored comp id) s32 OUT 0 mb2hal.Modbus_fnct_03.03.int
Component Pins:
Owner Type Dir Value Name
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.00.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_06.00.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.01.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_06.01.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.02.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_06.02.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_06.03.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_06.03.int
Component Pins:
Owner Type Dir Value Name
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.00.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.01.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.02.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_15.03.bit
Component Pins:
Owner Type Dir Value Name
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.00.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_16.00.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.01.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_16.01.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.02.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_16.02.int
(ignored comp id) float IN 0 mb2hal.Modbus_fnct_16.03.float
(ignored comp id) s32 IN 0 mb2hal.Modbus_fnct_16.03.int
Component Pins:
Owner Type Dir Value Name
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_01.00.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_01.00.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_01.01.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_01.01.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_01.02.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_01.02.bit-inv
(ignored comp id) bit OUT FALSE mb2hal.Modbus_fnct_01.03.bit
(ignored comp id) bit OUT TRUE mb2hal.Modbus_fnct_01.03.bit-inv
Component Pins:
Owner Type Dir Value Name
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_05.00.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_05.01.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_05.02.bit
(ignored comp id) bit IN FALSE mb2hal.Modbus_fnct_05.03.bit

View File

@@ -0,0 +1,110 @@
#This .INI file is also the HELP, MANUAL and HOW-TO file for mb2hal.
#Load the modbus HAL userspace module as the examples below,
#change to match your own HAL_MODULE_NAME and .ini file name
#Using HAL_MODULE_NAME=mb2hal or nothing (default): loadusr -W mb2hal config=config_file.ini
#Using HAL_MODULE_NAME=mymodule: loadusr -Wn mymodule mb2hal config=config_file.ini
#Common section
[MB2HAL_INIT]
#OPTIONAL: Debug level of init and INI file parsing.
# 0 = silent.
# 1 = error messages (default).
# 2 = OK confirmation messages.
# 3 = debugging messages.
INIT_DEBUG=0
#OPTIONAL: Set to 1.1 to enable the new functions:
# - fnct_01_read_coils
# - fnct_05_write_single_coil
# - changed pin names (see https://linuxcnc.org/docs/2.9/html/drivers/mb2hal.html#_pins).
VERSION=1.1
#OPTIONAL: HAL module (component) name. Defaults to "mb2hal".
HAL_MODULE_NAME=mb2hal
#OPTIONAL: Insert a delay of "FLOAT seconds" between transactions in order
#to not to have a lot of logging and facilitate the debugging.
#Useful when using DEBUG=3 (NOT INIT_DEBUG=3)
#It affects ALL transactions.
#Use "0.0" for normal activity.
SLOWDOWN=0.0
#REQUIRED: The number of total Modbus transactions. There is no maximum.
TOTAL_TRANSACTIONS=7
#One transaction section is required per transaction, starting at 00 and counting up sequentially.
#If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time.
#Warning: Any OPTIONAL parameter not specified are copied from the previous transaction.
[TRANSACTION_00]
LINK_TYPE=serial
SERIAL_PORT=/dev/ttyUSB0
SERIAL_BAUD=19200
SERIAL_BITS=8
SERIAL_PARITY=none
SERIAL_STOP=1
SERIAL_DELAY_MS=2
MB_SLAVE_ID=240
MB_TX_CODE=fnct_02_read_discrete_inputs
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_02
#Update rate in Hz
MAX_UPDATE_RATE=20
DEBUG=0
[TRANSACTION_01]
MB_TX_CODE=fnct_03_read_holding_registers
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_03
MAX_UPDATE_RATE=100
DEBUG=0
[TRANSACTION_02]
MB_TX_CODE=fnct_06_write_single_register
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_06
MAX_UPDATE_RATE=100
DEBUG=0
[TRANSACTION_03]
MB_TX_CODE=fnct_15_write_multiple_coils
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_15
MAX_UPDATE_RATE=100
DEBUG=0
[TRANSACTION_04]
MB_TX_CODE=fnct_16_write_multiple_registers
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_16
MAX_UPDATE_RATE=100
DEBUG=0
[TRANSACTION_05]
MB_TX_CODE=fnct_01_read_coils
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_01
MAX_UPDATE_RATE=100
DEBUG=0
[TRANSACTION_06]
MB_TX_CODE=fnct_05_write_single_coil
FIRST_ELEMENT=0
NELEMENTS=4
HAL_TX_NAME=Modbus_fnct_05
MAX_UPDATE_RATE=100
DEBUG=0

View File

@@ -0,0 +1 @@
LIBMODBUS3

View File

@@ -0,0 +1 @@
This test runs mb2hal with VERSION=1.1 and compares the created pins (including types).

View File

@@ -0,0 +1,12 @@
# Load MB2HAL
loadusr -W mb2hal config=mb2hal.ini
# specifying these pins so detailed to avoid varying values of
# mb2hal.<MB_TX_CODE>.num_errors
show pin mb2hal.Modbus_fnct_02.0
show pin mb2hal.Modbus_fnct_03.0
show pin mb2hal.Modbus_fnct_06.0
show pin mb2hal.Modbus_fnct_15.0
show pin mb2hal.Modbus_fnct_16.0
show pin mb2hal.Modbus_fnct_01.0
show pin mb2hal.Modbus_fnct_05.0