public SpektrometrStatus GetAllVariables()
        {
            byte[] command = Sptpp.ReadCommand(0, 10);
            serialPort.Write(command, 0, command.Length);
            byte[] response = Sptpp.GetReadResponse(serialPort, 10);

            if (response == null || response.Count() < 6)
            {
                serialPort.DiscardOutBuffer();
                serialPort.DiscardInBuffer();
                throw new FormatException();
            }

            byte status = response[0];
            byte port   = response[9];

            return(new SpektrometrStatus
            {
                MainStatus = status,
                IoStatus = port,
                Pozycjonowanie1 = IsPozycjonowanie1(status),
                Pozycjonowanie2 = IsPozycjonowanie2(status),
                JazdaLewo1 = IsJazdaLewo1(status),
                JazdaPrawo1 = IsJazdaPrawo1(status),
                JazdaLewo2 = IsJazdaLewo2(status),
                JazdaPrawo2 = IsJazdaPrawo2(status),
                Input1 = (port & (1 << 0)) != 0,
                Input2 = (port & (1 << 1)) != 0,
                Input3 = (port & (1 << 2)) != 0,
                Input4 = (port & (1 << 3)) != 0,
                AktualneImpulsy1 = BitConverter.ToInt32(response, 1),
                AktualneImpulsy2 = BitConverter.ToInt32(response, 5)
            });
        }
 private bool WriteBytes(byte addr, byte[] value)
 {
     byte[] command = Sptpp.WriteCommand(value, addr);
     serialPort.Write(command, 0, command.Length);
     return(Sptpp.GetWriteResponse(serialPort) == value.Length);
 }
 private bool WriteInt32(byte addr, Int32 value)
 {
     byte[] command = Sptpp.WriteCommand(BitConverter.GetBytes(value), addr);
     serialPort.Write(command, 0, command.Length);
     return(Sptpp.GetWriteResponse(serialPort) == 4);
 }
 private bool WriteByte(byte addr, byte value)
 {
     byte[] command = Sptpp.WriteCommand(new byte[] { value }, addr);
     serialPort.Write(command, 0, command.Length);
     return(Sptpp.GetWriteResponse(serialPort) == 1);
 }