Skip to content

Commit

Permalink
TQS: Funkce CmdGetTemperature nově vrací výčet ResponseACK - je tak m…
Browse files Browse the repository at this point in the history
…ožné lépe rozeznat chybu teplotního čidla od jiných chyb.
  • Loading branch information
Papouchcom committed Jun 15, 2018
1 parent c824e41 commit eb805e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Binary file modified Latest/Papouch.Quido.dll
Binary file not shown.
Binary file modified Latest/Papouch.Quido.pdb
Binary file not shown.
22 changes: 15 additions & 7 deletions Papouch.Spinel/Spinel97.Device.Tqs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,33 @@ public Tqs(ICommunicationInterface ci, byte spinelADR) : base(ci, spinelADR)
/// Čtení teploty z teplotního senzoru
/// </summary>
/// <param name="temp">Aktuálně naměřená teplota. Pokud z nějakého důvodu není dostupná, je zde konstanta float.NaN.</param>
/// <returns>Teplota ve stupních Celsia.</returns>
public Boolean CmdGetTemperature(out float temp)
/// <returns>Výčet <see cref="ResponseACK"/>.</returns>
public ResponseACK CmdGetTemperature(out float temp)
{
byte[] data = {};

PacketSpinel97 txPacket = new PacketSpinel97(S97_INST_TQS_GetTemperature, data);
txPacket.ADR = this.ADR;
PacketSpinel97 rxPacket;

if (SendAndReceive(ref txPacket, out rxPacket) && (rxPacket.INST == (byte)ResponseACK.AllIsOk))
if (SendAndReceive(ref txPacket, out rxPacket))
{
if ((rxPacket.SDATA != null) && (rxPacket.SDATA.Length == 2))
if (rxPacket.INST == (byte)ResponseACK.AllIsOk)
{
temp = (float)(rxPacket.SDATA[0] * 256 + rxPacket.SDATA[1]) / 32;
return true;
if ((rxPacket.SDATA != null) && (rxPacket.SDATA.Length == 2))
{
temp = (float)(rxPacket.SDATA[0] * 256 + rxPacket.SDATA[1]) / 32;
return ResponseACK.AllIsOk;
}
}
else
{
temp = float.NaN;
return (ResponseACK)rxPacket.INST;
}
}
temp = float.NaN;
return false;
return ResponseACK.OtherCommError;
}

}
Expand Down

0 comments on commit eb805e1

Please sign in to comment.