public bool WriteRegister(ushort reg, short value)
            {
                modbus link = new modbus();
                bool   ret  = link.Open(port, 9600, 8, Parity.None, StopBits.Two);

                if (!ret)
                {
                    throw EngineMessageException.offline(
                              "Opening port " + port + " failed: " + link.modbusStatus);
                }
                short[] val = { value };
                Logger.log(
                    "Writing 0x" + value.ToString("x") +
                    " to register 0x" + reg.ToString("x") +
                    " to address 0x" + address.ToString("x"));
                ret = link.SendFc16(address, reg, 1, val);
                if (!ret)
                {
                    throw new EngineMessageException(
                              "Writing 0x" + value.ToString("x") +
                              " to register 0x" + reg.ToString("x") + " failed: " + link.modbusStatus);
                }
                link.Close();
                return(ret);
            }
            public short ReadRegister(ushort reg)
            {
                modbus link = new modbus();
                bool   ret  = link.Open(port, 9600, 8, Parity.None, StopBits.Two);

                if (!ret)
                {
                    throw EngineMessageException.offline(
                              "Opening port " + port + " failed: " + link.modbusStatus);
                }
                short[] val = new short[1];
                ret = link.SendFc3(address, reg, 1, ref val);
                if (!ret)
                {
                    throw new EngineMessageException(
                              "Read from register 0x" + reg.ToString("x") + " failed: " + link.modbusStatus);
                }
                link.Close();
                return(val[0]);
            }