Skip to content
Merged
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
19 changes: 9 additions & 10 deletions Modbus485Master/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

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

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

```#require "CRC16.class.nut:1.0.0"
```
#require "CRC16.class.nut:1.0.0"
#require "ModbusRTU.class.nut:1.0.0"
#require "ModbusMaster.class.nut:1.0.0"
#require "Modbus485Master.class.nut:1.0.0"
```

**to the top of your device code.**

## Hardware Setup

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

## Modbus485Master Class Methods

### read(*deviceAddress, targetType, startingAddress, quantity, values[, callback]*)
### read(*deviceAddress, targetType, startingAddress, quantity[, callback]*)

Function Code : 01, 02, 03, 04

Expand Down Expand Up @@ -209,7 +208,7 @@ modbus.diagnostics(0x01, MODBUSRTU_SUB_FUNCTION_CODE.RESTART_COMMUNICATION_OPTIO

Function Code : 17

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*.
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*.

#### Example

Expand All @@ -220,7 +219,7 @@ modbus.reportSlaveID(0x01, function(error, result) {
} else {
server.log("Run indicator : " + result.runIndicator);
server.log(result.slaveId);
}
}
}.bindenv(this));
```

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

| Parameter | Data Type | Required | Default Value | Description |
| --- | --- | --- | --- | --- |
| *deviceAddress* | Integer | Yes | N/A | The unique address that identifies a device |
| *deviceAddress* | Integer | Yes | N/A | The unique address that identifies a device |
| *referenceAddress* | Integer | Yes | N/A | The address of the holding register the value is written into |
| *AND_mask* | Integer | Yes | N/A | The AND mask |
| *OR_mask* | Integer | Yes | N/A | The OR mask |
Expand All @@ -246,7 +245,7 @@ modbus.maskWriteRegister(0x01, 0x10, 0xFFFF, 0x0000, function(error, result) {
server.error(error);
} else {
server.log(result);
}
}
}.bindenv(this));
```

Expand Down Expand Up @@ -274,7 +273,7 @@ modbus.readWriteMultipleRegisters(0x01, 0x10, 0xFFFF, 0x0000, function(error, re
server.error(error);
} else {
server.log(result);
}
}
}.bindenv(this));
```

Expand Down
1 change: 1 addition & 0 deletions Modbus485Master/example/example.device.nut
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#require "CRC16.class.nut:1.0.0"
#require "ModbusRTU.class.nut:1.0.0"
#require "ModbusMaster.class.nut:1.0.0"
#require "Modbus485Master.class.nut:1.0.0"

// this example demonstrates how to write and read values into/from holding registers
Expand Down
4 changes: 1 addition & 3 deletions Modbus485Slave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

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

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

```squirrel
#require "CRC16.class.nut:1.0.0"
#require "ModbusSlave.class.nut:1.0.0"
#require "Modbus485Slave.class.nut:1.0.0"
```

**to the top of your device code.**

## Hardware Setup

The following instructions are applicable to Electric Imp’s [impAccelerator&trade; Fieldbus Gateway](https://electricimp.com/docs/hardware/resources/reference-designs/fieldbusgateway/).
Expand Down
6 changes: 2 additions & 4 deletions ModbusRTU/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# ModbusRTU

This library creates and parses Modbus Protocol Data Units (PDU).
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.

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

```
#require "CRC16.class.nut:1.0.0"
#require "ModbusRTU.class.nut:1.0.0"
```

**to the top of your device code.**

## ModbusRTU Class Usage

This is the main library class. All methods and variables inside this class are static.
Expand Down
16 changes: 7 additions & 9 deletions ModbusTCPMaster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.

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

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

**to the top of your device code.**

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

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

| Parameter | Data Type | Required | Default Value | Description |
| --- | --- | --- | --- | --- |
| *connectionSettings* | Table | Yes | N/A | The connection settings. It entails the device IP and port |
| *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` |
| *onConnectCallback* | Function | No | Null | The function to be fired when the connection is established |
| *onReconnectCallback* | Function | No | Null| The function to be fired when the connection is re-established |

Expand All @@ -64,8 +62,8 @@ This method configures the network and opens a TCP connection with the device. I
```squirrel
// The device address and port
local connectionSettings = {
"destIP" : [192, 168, 1, 90],
"destPort" : [0x01, 0xF6]
"destIP" : "192.168.1.90",
"destPort" : 502
};

// Open the connection
Expand Down Expand Up @@ -255,7 +253,7 @@ modbus.reportSlaveID(function(error, result) {
} else {
server.log("Run indicator : " + result.runIndicator);
server.log(result.slaveId);
}
}
}.bindenv(this));
```

Expand All @@ -280,7 +278,7 @@ modbus.maskWriteRegister(0x10, 0xFFFF, 0x0000, function(error, result) {
server.error(error);
} else {
server.log(result);
}
}
}.bindenv(this));
```

Expand All @@ -307,7 +305,7 @@ modbus.readWriteMultipleRegisters(0x10, 0xFFFF, 0x0000, function(error, result)
server.error(error);
} else {
server.log(result);
}
}
}.bindenv(this));
```

Expand Down