-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell bindings to the C modbus library -- -- This library supports Modbus communication over both TCP and serial -- ports. -- -- It is a FFI to the C modbus library from https://libmodbus.org/ @package libmodbus @version 1.1.0 -- | Haskell bindings to the C modbus library https://libmodbus.org/ module System.Modbus -- | A modbus device context. -- -- The context will automatically be closed and freed when it is garbage -- collected. data Context -- | An address on a modbus device. newtype Addr Addr :: Int -> Addr newtype Baud Baud :: Int -> Baud data Parity ParityNone :: Parity ParityEven :: Parity ParityOdd :: Parity newtype DataBits DataBits :: Int -> DataBits newtype StopBits StopBits :: Int -> StopBits -- | Create a modbus Remote Terminal Unit context. -- -- The FilePath is the serial device to connect to. new_rtu :: FilePath -> Baud -> Parity -> DataBits -> StopBits -> IO Context data SerialMode RTU_RS232 :: SerialMode RTU_RS485 :: SerialMode rtu_get_serial_mode :: Context -> IO SerialMode rtu_set_serial_mode :: Context -> SerialMode -> IO () data RTS RTU_RTS_NONE :: RTS RTU_RTS_UP :: RTS RTU_RTS_DOWN :: RTS rtu_get_rts :: Context -> IO RTS rtu_set_rts :: Context -> RTS -> IO () rtu_get_rts_delay :: Context -> IO Int rtu_set_rts_delay :: Context -> Int -> IO () -- | IPv4 address to connect to. In server mode, use AnyAddress to listen -- to any addresses. data IPAddress IPAddress :: String -> IPAddress AnyAddress :: IPAddress newtype Port Port :: Int -> Port -- | Create a modbus TCP/IPv4 context. new_tcp :: IPAddress -> Port -> IO Context -- | Host name or IP address to connect to. In server mode, use AnyNode to -- listen to any addresses. data Node Node :: String -> Node AnyNode :: Node -- | Service name/port number to connect to. newtype Service Service :: String -> Service new_tcp_pi :: Node -> Service -> IO Context -- | The address of a modbus device. newtype DeviceAddress DeviceAddress :: Int -> DeviceAddress broadcastAddress :: DeviceAddress -- | Set the address of the modbus device that the Context should -- communicate with. set_slave :: Context -> DeviceAddress -> IO () connect :: Context -> IO () set_debug :: Context -> Bool -> IO () data Timeout Timeout :: Word32 -> Word32 -> Timeout [to_sec] :: Timeout -> Word32 [to_usec] :: Timeout -> Word32 get_byte_timeout :: Context -> IO Timeout set_byte_timeout :: Context -> Timeout -> IO () get_response_timeout :: Context -> IO Timeout set_response_timeout :: Context -> Timeout -> IO () -- | A mutable vector that is used as a buffer when reading or writing -- registers of a modbus device. type RegisterVector = IOVector Word16 -- | Allocates a vector holding the contents of a specified number of -- registers. -- -- The values are initialized to 0 to start. mkRegisterVector :: Int -> IO RegisterVector -- | Types that can hold modbus register data. -- -- Of these, RegisterVector is the most efficient as it avoids -- allocating new memory on each read or write. But it can be more useful -- to get a ByteString and use a library such as cereal or binary to -- parse the contents of the modbus registers. class RegisterData t fromRegisterVector :: RegisterData t => RegisterVector -> IO t toRegisterVector :: RegisterData t => t -> IO RegisterVector -- | Reads the holding registers from the modbus device, starting at the -- Addr, into the RegisterVector buffer. read_registers :: RegisterData t => Context -> Addr -> RegisterVector -> IO t -- | Reads the input registers from the modbus device, starting at the -- Addr, into the RegisterVector buffer. read_input_registers :: RegisterData t => Context -> Addr -> RegisterVector -> IO t -- | Writes the registers to the modbus device, starting at the Addr. write_registers :: Context -> Addr -> RegisterVector -> IO () write_register :: Context -> Addr -> Word16 -> IO () write_and_read_registers :: Context -> Addr -> RegisterVector -> Addr -> RegisterVector -> IO () -- | A mutable vector that is used as a buffer when reading or writing bits -- (coils) of a modbus device. type BitVector = IOVector Bit -- | Allocates a vector holding the specified number of bits. -- -- The bits are set to start. mkBitVector :: Int -> IO BitVector -- | Types that can hold modbus bit data. -- -- Of these, BitVector is the most efficient as it avoids -- allocating new memory on each read or write. But it can be easier to -- use a Vector of Bool. class BitData t fromBitVector :: BitData t => BitVector -> IO t toBitVector :: BitData t => t -> IO BitVector type Bit = Word8 boolBit :: Bit -> Bool bitBool :: Bool -> Bit -- | Reads the bits (coils) from the modbus device, starting at the Addr, -- into the BitVector. read_bits :: BitData t => Context -> Addr -> BitVector -> IO t -- | Reads the input bits from the modbus device, starting at the Addr, -- into the BitVector. read_input_bits :: BitData t => Context -> Addr -> BitVector -> IO t -- | Writes the bits (coils) of the modbus device, starting at the Addr. write_bits :: Context -> Addr -> BitVector -> IO () write_bit :: Context -> Addr -> Bit -> IO () instance GHC.Classes.Eq System.Modbus.Addr instance GHC.Show.Show System.Modbus.Addr instance GHC.Show.Show System.Modbus.Timeout instance GHC.Classes.Eq System.Modbus.Timeout instance GHC.Classes.Eq System.Modbus.DeviceAddress instance GHC.Show.Show System.Modbus.DeviceAddress instance GHC.Classes.Eq System.Modbus.RTS instance GHC.Show.Show System.Modbus.RTS instance GHC.Classes.Eq System.Modbus.SerialMode instance GHC.Show.Show System.Modbus.SerialMode instance GHC.Classes.Eq System.Modbus.Service instance GHC.Show.Show System.Modbus.Service instance GHC.Classes.Eq System.Modbus.Node instance GHC.Show.Show System.Modbus.Node instance GHC.Classes.Eq System.Modbus.Port instance GHC.Show.Show System.Modbus.Port instance GHC.Classes.Eq System.Modbus.IPAddress instance GHC.Show.Show System.Modbus.IPAddress instance GHC.Classes.Eq System.Modbus.StopBits instance GHC.Show.Show System.Modbus.StopBits instance GHC.Classes.Eq System.Modbus.DataBits instance GHC.Show.Show System.Modbus.DataBits instance GHC.Classes.Eq System.Modbus.Parity instance GHC.Show.Show System.Modbus.Parity instance GHC.Classes.Eq System.Modbus.Baud instance GHC.Show.Show System.Modbus.Baud instance System.Modbus.BitData System.Modbus.BitVector instance System.Modbus.BitData (Data.Vector.Storable.Vector GHC.Word.Word8) instance System.Modbus.BitData (Data.Vector.Storable.Vector GHC.Types.Bool) instance System.Modbus.RegisterData System.Modbus.RegisterVector instance System.Modbus.RegisterData (Data.Vector.Storable.Vector GHC.Word.Word16) instance System.Modbus.RegisterData Data.ByteString.Internal.ByteString instance System.Modbus.RegisterData Data.ByteString.Lazy.Internal.ByteString instance Data.Default.Class.Default System.Modbus.Service instance Data.Default.Class.Default System.Modbus.Port