// This helper allows one port to be open at once public static bool OpenPort(ref SSP_COMMAND cmd) { try { // Lock critical section lock (m_Lock) { // If this exact port is already open, return true if (cmd.ComPort == m_PortName && m_PortOpen) { return(true); } // Open port if (m_LibHandle.OpenSSPComPort(cmd)) { // Remember details m_PortName = cmd.ComPort; m_PortOpen = true; return(true); } return(false); } } catch (Exception ex) { m_LastEx = ex; return(false); } }
// This function calls the open com port function of the SSP library. public bool OpenComPort() { if (!m_eSSP.OpenSSPComPort(m_cmd)) { return(false); } return(true); }
bool OpenComPort() { SSP_COMMAND cmd = new SSP_COMMAND(); cmd.ComPort = Global.ComPort; cmd.BaudRate = 9600; cmd.Timeout = 500; return(sspLib.OpenSSPComPort(cmd)); }
/* Non-Command functions */ // This function calls the open com port function of the SSP library. public bool OpenComPort(TextBox log = null) { if (log != null) { log.AppendText("Opening com port\r\n"); } if (!eSSP.OpenSSPComPort(cmd)) { return(false); } return(true); }
// This function opens the com port identified in the command structure, using the SSP library. public bool OpenComPort(TextBox log = null) { // open com port if (log != null) { log.AppendText("Opening com port\r\n"); } if (m_eSSP.OpenSSPComPort(m_cmd) == false) { return(false); } return(true); }
public bool OpenComPort(ref string log) { if (log != null) { log += "Opening com port\r\n"; } if (eSSP == null) { eSSP = new SSPComms(); } if (!eSSP.OpenSSPComPort(cmd)) { return(false); } return(true); }
/// <summary> /// Opens a new port connection. /// </summary> /// <param name="command">The command that contains the port name to open.</param> public static void OpenPort(ref SSP_COMMAND command) { lock (thisLock) { if (command.ComPort == portName && isPortOpen) { return; } if (libHandle.OpenSSPComPort(command)) { portName = command.ComPort; isPortOpen = true; } else { throw new LibraryException($"Could not open the port {command.ComPort}."); } } }
// This function performs a number of commands in order to setup the encryption between the host and the validator. public bool NegotiateKeys(TextBox log = null) { byte i; string s = ""; // make sure encryption is off cmd.EncryptionStatus = false; // open com port s += "Opening com port... "; if (eSSP.OpenSSPComPort(cmd) == false) { return(false); } s += "Success\r\n"; // send sync s += "Syncing... "; cmd.CommandData[0] = CCommands.SSP_CMD_SYNC; cmd.CommandDataLength = 1; if (!SendCommand(log)) { return(false); } s += "Success\r\n"; eSSP.InitiateSSPHostKeys(keys, cmd); // send generator cmd.CommandData[0] = CCommands.SSP_CMD_SET_GENERATOR; cmd.CommandDataLength = 9; s += "Setting generator... "; for (i = 0; i < 8; i++) { cmd.CommandData[i + 1] = (byte)(keys.Generator >> (8 * i)); } if (!SendCommand(log)) { return(false); } s += "Success\r\n"; // send modulus cmd.CommandData[0] = CCommands.SSP_CMD_SET_MODULUS; cmd.CommandDataLength = 9; s += "Sending modulus... "; for (i = 0; i < 8; i++) { cmd.CommandData[i + 1] = (byte)(keys.Modulus >> (8 * i)); } if (!SendCommand(log)) { return(false); } s += "Success\r\n"; // send key exchange cmd.CommandData[0] = CCommands.SSP_CMD_KEY_EXCHANGE; cmd.CommandDataLength = 9; s += "Exchanging keys... "; for (i = 0; i < 8; i++) { cmd.CommandData[i + 1] = (byte)(keys.HostInter >> (8 * i)); } if (!SendCommand(log)) { return(false); } s += "Success\r\n"; keys.SlaveInterKey = 0; for (i = 0; i < 8; i++) { keys.SlaveInterKey += (UInt64)cmd.ResponseData[1 + i] << (8 * i); } eSSP.CreateSSPHostEncryptionKey(keys); // get full encryption key cmd.Key.FixedKey = 0x0123456701234567; cmd.Key.VariableKey = keys.KeyHost; s += "Keys successfully negotiated\r\n"; if (log != null) { log.AppendText(s); } return(true); }