IO::Modbus Namespace Reference

Namespaces

 NT18B07
 
 R421A
 
 RID35
 
 STM8Relay
 
 STS
 

Classes

struct  ADU
 
class  Device
 A virtual device, represents a modbus slave device. More...
 
class  GenericRequest
 
struct  PDU
 Protocol Data Unit. More...
 
class  Request
 

Enumerations

enum class  Exception {
  Success = 0x00 , IllegalFunction = 0x01 , IllegalDataAddress = 0x02 , IllegalDataValue = 0x03 ,
  SlaveDeviceFailure = 0x04
}
 Modbus exception codes returned in response packets. More...
 
enum class  Function { XX }
 

Functions

bool operator! (Exception exception)
 
ErrorCode readRequest (RS485::Controller &controller, ADU &adu)
 
void sendResponse (RS485::Controller &controller, ADU &adu)
 
Debug print support, outputs contents of packet
size_t printRequest (Print &p, const PDU &pdu)
 
size_t printRequest (Print &p, const ADU &adu)
 
size_t printResponse (Print &p, const PDU &pdu)
 
size_t printResponse (Print &p, const ADU &adu)
 

Detailed Description

Modbus/ADU.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Debug.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Device.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Exception.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Function.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/GenericRequest.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/PDU.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Request.h

Created on: 1 May 2018

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Modbus/Slave.h

Copyright 2022 mikee47 mike@.nosp@m.sill.nosp@m.yhous.nosp@m.e.ne.nosp@m.t

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Enumeration Type Documentation

◆ Exception

enum IO::Modbus::Exception
strong

Modbus exception codes returned in response packets.

Enumerator
Success 

No exception, transaction completed normally.

IllegalFunction 

Function not allowed/supported/implemented, or device in wrong state to process request.

For example, an unconfigured device may be unable to return register values.

IllegalDataAddress 

Data address not allowed.

More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, the ADU addresses the first register as 0, and the last one as 99.

If a request is submitted with a starting register address of 96 and a quantity of registers of 4, then this request will successfully operate (address-wise at least) on registers 96, 97, 98, 99.

If a request is submitted with a starting register address of 96 and a quantity of registers of 5, then this request will fail with Exception Code 0x02 "Illegal Data Address" since it attempts to operate on registers 96, 97, 98, 99 and 100, and there is no register with address 100.

IllegalDataValue 

Data value not allowed.

This indicates a fault in the structure of the remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.

SlaveDeviceFailure 

Protocol slave device failure exception.

An unrecoverable error occurred while the server (or slave) was attempting to perform the requested action.

◆ Function

enum IO::Modbus::Function
strong
Enumerator
XX 

Function Documentation

◆ operator!()

bool IO::Modbus::operator! ( Exception  exception)
inline

◆ printRequest() [1/2]

size_t IO::Modbus::printRequest ( Print p,
const ADU adu 
)

◆ printRequest() [2/2]

size_t IO::Modbus::printRequest ( Print p,
const PDU pdu 
)

◆ printResponse() [1/2]

size_t IO::Modbus::printResponse ( Print p,
const ADU adu 
)

◆ printResponse() [2/2]

size_t IO::Modbus::printResponse ( Print p,
const PDU pdu 
)

◆ readRequest()

ErrorCode IO::Modbus::readRequest ( RS485::Controller controller,
ADU adu 
)

◆ sendResponse()

void IO::Modbus::sendResponse ( RS485::Controller controller,
ADU adu 
)