-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Modbus Input plugin #6154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Modbus Input plugin #6154
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
2ae7064
Add modbus path
garciaolais 716adff
First commit
garciaolais 531c86b
ac234ee
add modbus constraint
garciaolais bac4a1c
add readme
garciaolais 8d1621c
Allow for float32 registers
robinsheehy 9d073d5
fix typo in example telegraf config
gregorybrzeski cd32ef7
fix typo in example config in code
gregorybrzeski e1261cc
Merge pull request #2 from gregorybrzeski/modbus-fix-typo
garciaolais 5c175cb
Merge pull request #3 from gregorybrzeski/modbus-fix-typo
garciaolais 0f1849d
Merge branch 'input/modbus' into patch-1
garciaolais ad99edd
Merge pull request #1 from robinsheehy/patch-1
garciaolais 9268303
Fix datatype
garciaolais d99586e
282fdb5
Remove comments
garciaolais cdde42e
Clean code
garciaolais eb6a49b
Revert "add modbus constraint"
garciaolais 41e9a95
Merge branch 'master' into input/modbus
d98b45b
add modbus dependencies
24b253e
run dep ensure
6303eee
restore Gopkg.* and run dep ensure
1743098
update dep version, run dep ensure
ddbda66
run make fmt
a55f3fb
Use the internal.Duration type for timeout
608dc2a
update config, Use the internal.Duration type
cb72c56
change fields not settable for lowercase
60dc832
remove defer
8f6e271
remove comparing with == true, false
cf1315a
Remove createChunks function
f3fee58
fix Value , WIP
171d022
implement table driven test
acab252
change variable name
04f8679
revision changes
a501fd1
run make fmt
d95525b
remove constants
5338133
remove raw_values field
066a2ef
change multipe if condition for if else
5f9ac6a
move name variable
25865f3
add tag validation
8b16af2
run make fmt
3a62a54
implement ASCII Handler, add Protocol field
6a4a46f
run make fmt
d0a1a19
add comments
bf60d30
add sample config
c9b234f
Update README.md
garciaolais b8276a6
Update README.md
garciaolais d6579c4
Update modbus.go
garciaolais 66f8c34
Update modbus.go
garciaolais 8f01c12
Update README.md
garciaolais b8ba0ff
Update README.md
garciaolais 268f1a5
Update modbus.go
garciaolais e8ce38c
Update modbus.go
garciaolais 70d4471
Update README.md
garciaolais 8e26084
Fix set Digital an Analog values
3e814d1
Update README.md
garciaolais cfeec73
run make fmt
4f9aa18
Refactored 'time_out' to 'timeout'
SEA-NET bd3d26b
Refactored 'protocol' to 'transmission_mode'
SEA-NET 08a5e5f
Default config uses registered MODBUS/TCP port
SEA-NET d230b05
Config cleanup and commentary
SEA-NET fceaa69
Corrected typo
SEA-NET 048553d
Merge pull request #4 from h-schwanbeck/input/modbus
garciaolais 4280b61
Refactored struct name 'tag' to 'ModbusData'
SEA-NET b475c96
Struct names begin with capital letters
SEA-NET 454064d
Struct names in CamelCase
SEA-NET 900fe3e
Adopted golang (naming) conventions
SEA-NET 3a70008
Fields are not tags
SEA-NET 648ed89
Renamed 'serialHandler' to 'rtuHandler'
SEA-NET 1d869fe
Naming conventions in test code
SEA-NET 764e0a0
Corrected spacing
SEA-NET e729d55
Merge pull request #5 from h-schwanbeck/input/modbus_refactor
garciaolais 1736ea8
run make fmt
garciaolais c96d5b6
changed _err , removed capitalized error string
garciaolais 879841f
use the Init( ) error function
garciaolais cc4296e
change to float type
garciaolais e2be575
change to snake_case
garciaolais 63104c8
add new test case
garciaolais cce47be
change to float type
garciaolais f9c3f2a
add coil name
garciaolais f655cc0
add validations
garciaolais aa76e83
remove unecessary libs
garciaolais 13e4171
remove comment
garciaolais 7dc4438
clean code
garciaolais 3d67d41
remove reflection
garciaolais 8ac6820
add method InitRegister, fix error message
garciaolais 730d904
improve logic
garciaolais e1e3305
run make fmt
garciaolais 74b24cf
update data type
garciaolais c6f4b3e
fix data type in config
garciaolais 5b04015
add device name
garciaolais ed1928c
run make fmt
garciaolais cdaadce
Merge remote-tracking branch 'origin/master' into input/modbus
danielnelson d007490
Update go.mod/go.sum
danielnelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Telegraf Input Plugin: Modbus | ||
|
|
||
| The Modbus plugin collects Discrete Inputs, Coils, Input Registers and Holding Registers via Modbus TCP or Modbus RTU/ASCII | ||
|
|
||
| ### Configuration: | ||
|
|
||
| ```toml | ||
| ## Connection Configuration | ||
| ## | ||
| ## The module supports connections to PLCs via MODBUS/TCP or | ||
| ## via serial line communication in binary (RTU) or readable (ASCII) encoding | ||
| ## | ||
| ## Device name | ||
| name = "Device" | ||
|
|
||
| ## Slave ID - addresses a MODBUS device on the bus | ||
| ## Range: 0 - 255 [0 = broadcast; 248 - 255 = reserved] | ||
| slave_id = 1 | ||
|
|
||
| ## Timeout for each request | ||
| timeout = "1s" | ||
|
|
||
| # TCP - connect via Modbus/TCP | ||
| controller = "tcp://localhost:502" | ||
|
|
||
| # Serial (RS485; RS232) | ||
| #controller = "file:///dev/ttyUSB0" | ||
| #baud_rate = 9600 | ||
| #data_bits = 8 | ||
| #parity = "N" | ||
| #stop_bits = 1 | ||
| #transmission_mode = "RTU" | ||
|
|
||
|
|
||
| ## Measurements | ||
| ## | ||
|
|
||
| ## Digital Variables, Discrete Inputs and Coils | ||
| ## name - the variable name | ||
| ## address - variable address | ||
|
|
||
| discrete_inputs = [ | ||
| { name = "Start", address = [0]}, | ||
| { name = "Stop", address = [1]}, | ||
| { name = "Reset", address = [2]}, | ||
| { name = "EmergencyStop", address = [3]}, | ||
| ] | ||
| coils = [ | ||
| { name = "Motor1-Run", address = [0]}, | ||
| { name = "Motor1-Jog", address = [1]}, | ||
| { name = "Motor1-Stop", address = [2]}, | ||
| ] | ||
|
|
||
| ## Analog Variables, Input Registers and Holding Registers | ||
| ## name - the variable name | ||
| ## byte_order - the ordering of bytes | ||
| ## |---AB, ABCD - Big Endian | ||
| ## |---BA, DCBA - Little Endian | ||
| ## |---BADC - Mid-Big Endian | ||
| ## |---CDAB - Mid-Little Endian | ||
| ## data_type - UINT16, INT16, INT32, UINT32, FLOAT32, FLOAT32-IEEE (the IEEE 754 binary representation) | ||
| ## scale - the final numeric variable representation | ||
| ## address - variable address | ||
|
|
||
| holding_registers = [ | ||
| { name = "PowerFactor", byte_order = "AB", data_type = "FLOAT32", scale=0.01, address = [8]}, | ||
| { name = "Voltage", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [0]}, | ||
| { name = "Energy", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [5,6]}, | ||
| { name = "Current", byte_order = "ABCD", data_type = "FLOAT32", scale=0.001, address = [1,2]}, | ||
| { name = "Frequency", byte_order = "AB", data_type = "FLOAT32", scale=0.1, address = [7]}, | ||
| { name = "Power", byte_order = "ABCD", data_type = "FLOAT32", scale=0.1, address = [3,4]}, | ||
| ] | ||
| input_registers = [ | ||
| { name = "TankLevel", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]}, | ||
| { name = "TankPH", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]}, | ||
| { name = "Pump1-Speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]}, | ||
| ] | ||
| ``` | ||
| ### Example Output: | ||
|
|
||
| ``` | ||
| $ ./telegraf -config telegraf.conf -input-filter modbus -test | ||
| modbus.InputRegisters,host=orangepizero Current=0,Energy=0,Frecuency=60,Power=0,PowerFactor=0,Voltage=123.9000015258789 1554079521000000000 | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the sample configuration to use snake_case for the field/tag names? This will better match other Telegraf plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✔️