private bool ReadWritePort(byte[] message, byte[] response, ModbusStationRTU station)
        {
            try
            {
                station.Port.Write(message, 0, message.Length);

                for (int i = 0; i < response.Length; i++)
                {
                    response[i] = (byte)station.Port.ReadByte();
                }

                if (CheckResponse(response))
                {
                    return(true);
                }
                else
                {
                    Console.WriteLine("Error CRC");
                    return(false);
                }
            }
            catch
            {
                Console.WriteLine("Error Catch");
                return(false);
            }
        }
Exemplo n.º 2
0
 public ConnectorModbusRTU(string taskName, ModbusStationRTU station, int startAddress, ModbusTypeData.TypeData typeData)
 {
     this.taskName            = taskName;
     this.station             = station;
     this.startAddress        = startAddress;
     this.typeData            = typeData;
     this.typeData.Address    = startAddress;
     this.typeData.ID_Station = station.ID;
     this.typeData.BitEndiang = station.Bit_Endiang;
 }