// This function should be called in a loop, it monitors the SSP_COMMAND_INFO parameter // and writes the info to a text box in a readable format. If the failedCommand bool // is set true then it will not write a response. public void UpdateLog(SSP_COMMAND_INFO info, bool failedCommand = false) { if (m_bLogging) { string byteStr; byte len; // NON-ENCRPYTED // transmission m_LogText = "\r\nNo Encryption\r\nSent Packet #" + m_PacketCounter; len = info.PreEncryptedTransmit.PacketData[2]; m_LogText += "\r\nLength: " + len.ToString(); m_LogText += "\r\nSync: " + (info.PreEncryptedTransmit.PacketData[1] >> 7); m_LogText += "\r\nData: "; byteStr = BitConverter.ToString(info.PreEncryptedTransmit.PacketData, 3, len); m_LogText += FormatByteString(byteStr); m_LogText += "\r\n"; // received if (!failedCommand) { m_LogText += "\r\nReceived Packet #" + m_PacketCounter; len = info.PreEncryptedRecieve.PacketData[2]; m_LogText += "\r\nLength: " + len.ToString(); m_LogText += "\r\nSync: " + (info.PreEncryptedRecieve.PacketData[1] >> 7); m_LogText += "\r\nData: "; byteStr = BitConverter.ToString(info.PreEncryptedRecieve.PacketData, 3, len); m_LogText += FormatByteString(byteStr); m_LogText += "\r\n"; } else { m_LogText += "\r\nNo response..."; } if (checkBox1.Checked == true) { // ENCRYPTED // transmission m_LogText += "\r\nEncryption\r\nSent Packet #" + m_PacketCounter; len = info.Transmit.PacketData[2]; m_LogText += "\r\nLength: " + len.ToString(); m_LogText += "\r\nSync: " + (info.Transmit.PacketData[1] >> 7); m_LogText += "\r\nData: "; byteStr = BitConverter.ToString(info.Transmit.PacketData, 3, len); m_LogText += FormatByteString(byteStr); m_LogText += "\r\n"; // received if (!failedCommand) { m_LogText += "\r\nReceived Packet #" + m_PacketCounter; len = info.Receive.PacketData[2]; m_LogText += "\r\nLength: " + len.ToString(); m_LogText += "\r\nSync: " + (info.Receive.PacketData[1] >> 7); m_LogText += "\r\nData: "; byteStr = BitConverter.ToString(info.Receive.PacketData, 3, len); m_LogText += FormatByteString(byteStr); m_LogText += "\r\n"; } else { m_LogText += "\r\nNo response..."; } } if (logWindowText.InvokeRequired) { WriteToLog l = new WriteToLog(AppendToWindow); logWindowText.BeginInvoke(l, new object[] { m_LogText }); } else { logWindowText.AppendText(m_LogText); logWindowText.SelectionStart = logWindowText.TextLength; } AppendToLog(m_LogText); m_PacketCounter++; } }