Skip to content

Commit af442cd

Browse files
author
Pavel Petroshenko
authored
Merge pull request #3 from electricimp/develop
Develop
2 parents 25023f6 + 0265984 commit af442cd

22 files changed

+436
-67
lines changed

Diff for: LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
MIT License
2+
3+
Copyright 2017 Electric Imp
4+
5+
SPDX-License-Identifier: MIT
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
OTHER DEALINGS IN THE SOFTWARE.

Diff for: Modbus485Master/Modbus485Master.class.nut renamed to Modbus485Master/Modbus485Master.device.lib.nut

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
// Copyright (c) 2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
class Modbus485Master extends ModbusMaster {
26+
static VERSION = "1.0.1";
627
static MINIMUM_RESPONSE_LENGTH = 5;
728
_uart = null;
829
_rts = null;

Diff for: Modbus485Master/README.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This library allows an imp to communicate with other devices via the Modbus-RS48
66

77
```
88
#require "CRC16.class.nut:1.0.0"
9-
#require "ModbusRTU.class.nut:1.0.0"
10-
#require "ModbusMaster.class.nut:1.0.0"
11-
#require "Modbus485Master.class.nut:1.0.0"
9+
#require "ModbusRTU.device.lib.nut:1.0.1"
10+
#require "ModbusMaster.device.lib.nut:1.0.1"
11+
#require "Modbus485Master.device.lib.nut:1.0.1"
1212
```
1313

1414
## Hardware Setup
@@ -27,7 +27,7 @@ The following instructions are applicable to Electric Imp’s [impAccelerator&tr
2727

2828
This is the main library class. It implements most of the functions listed in the [Modbus specification](http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf).
2929

30-
### Constructor: Modbus485Master(*uart, rts, params*)
30+
### Constructor: Modbus485Master(*uart, rts[, params]*)
3131

3232
Instantiate a new Modbus485Master object and set the configuration of the UART bus over which it operates. The parameters *uart* and *rts* are, respectively, the imp UART in use and an imp GPIO pin which will be used to control flow. The *params* parameter is optional and takes a table containing the following keys:
3333

@@ -265,16 +265,12 @@ This method performs a combination of one read operation and one write operation
265265
| *writeValue* | Blob | Yes | N/A | The value written into the holding register |
266266
| *callback* | Function | No | Null | The function to be fired when it receives response regarding this request. It takes two parameters, *error* and *result* |
267267

268+
**Note** The actual order of operation is determined by the implementation of user's device.
269+
270+
268271
#### Example
269272

270273
```squirrel
271-
modbus.readWriteMultipleRegisters(0x01, 0x10, 0xFFFF, 0x0000, function(error, result) {
272-
if (error) {
273-
server.error(error);
274-
} else {
275-
server.log(result);
276-
}
277-
}.bindenv(this));
278274
```
279275

280276
### readDeviceIdentification(*deviceAddress, readDeviceIdCode, objectId[, callback]*)
@@ -347,4 +343,4 @@ The table below enumerates all the exception codes that can be possibly encounte
347343

348344
## License
349345

350-
The Modbus485Master library is licensed under the [MIT License](https://github.com/electricimp/Modbus/tree/master/LICENSE).
346+
The Modbus485Master library is licensed under the [MIT License](../LICENSE).

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

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
125
#require "CRC16.class.nut:1.0.0"
2-
#require "ModbusRTU.class.nut:1.0.0"
3-
#require "ModbusMaster.class.nut:1.0.0"
4-
#require "Modbus485Master.class.nut:1.0.0"
26+
#require "ModbusRTU.device.lib.nut:1.0.1"
27+
#require "ModbusMaster.device.lib.nut:1.0.1"
28+
#require "Modbus485Master.device.lib.nut:1.0.1"
529

630
// this example demonstrates how to write and read values into/from holding registers
731
const DEVICE_ADDRESS = 0x01;

Diff for: Modbus485Master/tests/device.test.nut

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
125
const DEVICE_ADDRESS = 1;
226

327
function errorMessage(error, resolve, reject) {

Diff for: Modbus485Slave/Modbus485Slave.class.nut renamed to Modbus485Slave/Modbus485Slave.device.lib.nut

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
// Copyright (c) 2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
class Modbus485Slave extends ModbusSlave {
26+
static VERSION = "1.0.1";
627
static MIN_REQUEST_LENGTH = 4;
728
_slaveID = null;
829
_uart = null;

Diff for: Modbus485Slave/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This library empowers an imp to communicate with the Modbus Master via the RS485
66

77
```squirrel
88
#require "CRC16.class.nut:1.0.0"
9-
#require "ModbusSlave.class.nut:1.0.0"
10-
#require "Modbus485Slave.class.nut:1.0.0"
9+
#require "ModbusSlave.device.lib.nut:1.0.1"
10+
#require "Modbus485Slave.device.lib.nut:1.0.1"
1111
```
1212

1313
## Hardware Setup
@@ -195,4 +195,4 @@ The table below enumerates all the exception codes that can be possibly encounte
195195

196196
# License
197197

198-
The Modbus485Slave library is licensed under the [MIT License](https://github.com/electricimp/Mdobus/tree/master/LICENSE).
198+
The Modbus485Slave library is licensed under the [MIT License](../LICENSE).

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

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
125
#require "CRC16.class.nut:1.0.0"
2-
#require "ModbusSlave.class.nut:1.0.0"
3-
#require "Modbus485Slave.class.nut:1.0.0"
26+
#require "ModbusSlave.device.lib.nut:1.0.1"
27+
#require "Modbus485Slave.device.lib.nut:1.0.1"
428

529
modbus <- Modbus485Slave(hardware.uart2, hardware.pinL, 1, { debug = true });
630

Diff for: Modbus485Slave/tests/device.test.nut

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
24+
25+
126
// it is a bit hard to write test cases if the hardware is involved,
227
// so the idea is to create a fake buffer and simulate the parsing requests and creating responses
328

Diff for: ModbusMaster/ModbusMaster.class.nut renamed to ModbusMaster/ModbusMaster.device.lib.nut

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
// Copyright (c) 2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
class ModbusMaster {
6-
static VERSION = "1.0.0";
26+
static VERSION = "1.0.1";
727
_debug = null;
828

929
//

Diff for: ModbusMaster/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ This library enables an imp to communicate with other devices via TCP/IP .
1515

1616
# License
1717

18-
The ModbusRTUMaster library is licensed under the [MIT License](https://github.com/electricimp/thethingsapi/tree/master/LICENSE).
18+
The ModbusRTUMaster library is licensed under the [MIT License](../LICENSE).

Diff for: ModbusRTU/ModbusRTU.class.nut renamed to ModbusRTU/ModbusRTU.device.lib.nut

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// Copyright (c) 2017 Electric Imp
2-
// This file is licensed under the MIT License
3-
// http://opensource.org/licenses/MIT
1+
// MIT License
2+
//
3+
// Copyright 2017 Electric Imp
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be
15+
// included in all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
20+
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
21+
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
// OTHER DEALINGS IN THE SOFTWARE.
424

525
enum MODBUSRTU_SUB_FUNCTION_CODE {
626
RETURN_QUERY_DATA = 0x0000,
@@ -64,7 +84,7 @@ enum MODBUSRTU_OBJECT_ID {
6484
}
6585

6686
class ModbusRTU {
67-
static VERSION = "1.0.0";
87+
static VERSION = "1.0.1";
6888
// resLen and reqLen are the length of the PDU
6989
static FUNCTION_CODES = {
7090
readCoils = {

Diff for: ModbusRTU/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This library creates and parses Modbus Protocol Data Units (PDU). It depends on
66

77
```
88
#require "CRC16.class.nut:1.0.0"
9-
#require "ModbusRTU.class.nut:1.0.0"
9+
#require "ModbusRTU.device.lib.nut:1.0.1"
1010
```
1111

1212
## ModbusRTU Class Usage
@@ -230,4 +230,4 @@ local result = parse({
230230

231231
## License
232232

233-
The ModbusRTU library is licensed under the [MIT License](https://github.com/electricimp/Modbus/tree/master/LICENSE).
233+
The ModbusRTU library is licensed under the [MIT License](../LICENSE).

0 commit comments

Comments
 (0)