Skip to content

Commit 25023f6

Browse files
author
Pavel Petroshenko
authored
Merge pull request #1 from electricimp/develop
Some docs updates
2 parents 84bafb2 + 4f2c53d commit 25023f6

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

Diff for: Modbus485Master/README.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
This library allows an imp to communicate with other devices via the Modbus-RS485 protocol.
44

5-
**To use this library, add the following statements**
5+
**To use this library, add the following statements to the top of your device code:**
66

7-
```#require "CRC16.class.nut:1.0.0"
7+
```
8+
#require "CRC16.class.nut:1.0.0"
89
#require "ModbusRTU.class.nut:1.0.0"
910
#require "ModbusMaster.class.nut:1.0.0"
1011
#require "Modbus485Master.class.nut:1.0.0"
1112
```
1213

13-
**to the top of your device code.**
14-
1514
## Hardware Setup
1615

1716
The following instructions are applicable to Electric Imp’s [impAccelerator™ Fieldbus Gateway](https://electricimp.com/docs/hardware/resources/reference-designs/fieldbusgateway/).
@@ -49,7 +48,7 @@ modbus <- Modbus485Master(hardware.uart2, hardware.pinL);
4948

5049
## Modbus485Master Class Methods
5150

52-
### read(*deviceAddress, targetType, startingAddress, quantity, values[, callback]*)
51+
### read(*deviceAddress, targetType, startingAddress, quantity[, callback]*)
5352

5453
Function Code : 01, 02, 03, 04
5554

@@ -209,7 +208,7 @@ modbus.diagnostics(0x01, MODBUSRTU_SUB_FUNCTION_CODE.RESTART_COMMUNICATION_OPTIO
209208

210209
Function Code : 17
211210

212-
This method reads the description of the type, the current status and other information specific to a remote device whose address is specified in the method’s first parameter. The second, optional parameter is a function that will be fired when a response regarding this request is received. It takes two parameters, *error* and *result*.
211+
This method reads the description of the type, the current status and other information specific to a remote device whose address is specified in the method’s first parameter. The second, optional parameter is a function that will be fired when a response regarding this request is received. It takes two parameters, *error* and *result*.
213212

214213
#### Example
215214

@@ -220,7 +219,7 @@ modbus.reportSlaveID(0x01, function(error, result) {
220219
} else {
221220
server.log("Run indicator : " + result.runIndicator);
222221
server.log(result.slaveId);
223-
}
222+
}
224223
}.bindenv(this));
225224
```
226225

@@ -232,7 +231,7 @@ This method modifies the contents of a specified holding register using a combin
232231

233232
| Parameter | Data Type | Required | Default Value | Description |
234233
| --- | --- | --- | --- | --- |
235-
| *deviceAddress* | Integer | Yes | N/A | The unique address that identifies a device |
234+
| *deviceAddress* | Integer | Yes | N/A | The unique address that identifies a device |
236235
| *referenceAddress* | Integer | Yes | N/A | The address of the holding register the value is written into |
237236
| *AND_mask* | Integer | Yes | N/A | The AND mask |
238237
| *OR_mask* | Integer | Yes | N/A | The OR mask |
@@ -246,7 +245,7 @@ modbus.maskWriteRegister(0x01, 0x10, 0xFFFF, 0x0000, function(error, result) {
246245
server.error(error);
247246
} else {
248247
server.log(result);
249-
}
248+
}
250249
}.bindenv(this));
251250
```
252251

@@ -274,7 +273,7 @@ modbus.readWriteMultipleRegisters(0x01, 0x10, 0xFFFF, 0x0000, function(error, re
274273
server.error(error);
275274
} else {
276275
server.log(result);
277-
}
276+
}
278277
}.bindenv(this));
279278
```
280279

Diff for: Modbus485Master/example/example.device.nut

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#require "CRC16.class.nut:1.0.0"
22
#require "ModbusRTU.class.nut:1.0.0"
3+
#require "ModbusMaster.class.nut:1.0.0"
34
#require "Modbus485Master.class.nut:1.0.0"
45

56
// this example demonstrates how to write and read values into/from holding registers

Diff for: Modbus485Slave/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
This library empowers an imp to communicate with the Modbus Master via the RS485 protocol.
44

5-
**To use this library, add**
5+
**To use this library, add the following statements to the top of your device code:**
66

77
```squirrel
88
#require "CRC16.class.nut:1.0.0"
99
#require "ModbusSlave.class.nut:1.0.0"
1010
#require "Modbus485Slave.class.nut:1.0.0"
1111
```
1212

13-
**to the top of your device code.**
14-
1513
## Hardware Setup
1614

1715
The following instructions are applicable to Electric Imp’s [impAccelerator&trade; Fieldbus Gateway](https://electricimp.com/docs/hardware/resources/reference-designs/fieldbusgateway/).

Diff for: ModbusRTU/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# ModbusRTU
22

3-
This library creates and parses Modbus Protocol Data Units (PDU).
3+
This library creates and parses Modbus Protocol Data Units (PDU). It depends on Electric Imp's [CRC16 library](https://github.com/electricimp/CRC16) to calculate the [CRC-16](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) value of a string or blob.
44

5-
**To use this library, add**
5+
**To use this library, add the following statements to the top of your device code:**
66

77
```
88
#require "CRC16.class.nut:1.0.0"
99
#require "ModbusRTU.class.nut:1.0.0"
1010
```
1111

12-
**to the top of your device code.**
13-
1412
## ModbusRTU Class Usage
1513

1614
This is the main library class. All methods and variables inside this class are static.

Diff for: ModbusTCPMaster/README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This library allows an imp to communicate with other devices via TCP/IP. It requires the use of [Wiznet](https://github.com/electricimp/Wiznet_5500) to transmit the packets between devices via Ethernet.
44

5-
**To use this library, add**
5+
**To use this library, add the following statements to the top of your device code:**
66

77
```
88
#require "ModbusRTU.class.nut:1.0.0"
@@ -11,8 +11,6 @@ This library allows an imp to communicate with other devices via TCP/IP. It requ
1111
#require "W5500.device.nut:1.0.0"
1212
```
1313

14-
**to the top of your device code.**
15-
1614
The following instructions are applicable to Electric Imp’s [impAccelerator&trade; Fieldbus Gateway](https://electricimp.com/docs/hardware/resources/reference-designs/fieldbusgateway/).
1715

1816
1. Connect the antenna to the Fieldbus Gateway
@@ -53,7 +51,7 @@ This method configures the network and opens a TCP connection with the device. I
5351

5452
| Parameter | Data Type | Required | Default Value | Description |
5553
| --- | --- | --- | --- | --- |
56-
| *connectionSettings* | Table | Yes | N/A | The connection settings. It entails the device IP and port |
54+
| *connectionSettings* | Table | Yes | N/A | The device IP address and port. The device IP address can either be a string or an array of four bytes, for example: `[192, 168, 1, 37]` or `"192.168.1.37"`. The port can either be an integer or array of two bytes (the high and low bytes of an unsigned two-byte integer value), for example: `[0x10, 0x92]` or `4242` |
5755
| *onConnectCallback* | Function | No | Null | The function to be fired when the connection is established |
5856
| *onReconnectCallback* | Function | No | Null| The function to be fired when the connection is re-established |
5957

@@ -64,8 +62,8 @@ This method configures the network and opens a TCP connection with the device. I
6462
```squirrel
6563
// The device address and port
6664
local connectionSettings = {
67-
"destIP" : [192, 168, 1, 90],
68-
"destPort" : [0x01, 0xF6]
65+
"destIP" : "192.168.1.90",
66+
"destPort" : 502
6967
};
7068
7169
// Open the connection
@@ -255,7 +253,7 @@ modbus.reportSlaveID(function(error, result) {
255253
} else {
256254
server.log("Run indicator : " + result.runIndicator);
257255
server.log(result.slaveId);
258-
}
256+
}
259257
}.bindenv(this));
260258
```
261259

@@ -280,7 +278,7 @@ modbus.maskWriteRegister(0x10, 0xFFFF, 0x0000, function(error, result) {
280278
server.error(error);
281279
} else {
282280
server.log(result);
283-
}
281+
}
284282
}.bindenv(this));
285283
```
286284

@@ -307,7 +305,7 @@ modbus.readWriteMultipleRegisters(0x10, 0xFFFF, 0x0000, function(error, result)
307305
server.error(error);
308306
} else {
309307
server.log(result);
310-
}
308+
}
311309
}.bindenv(this));
312310
```
313311

0 commit comments

Comments
 (0)