/// <summary> /// Sends an OPN to the pinpad and do not close it. /// </summary> /// <returns>If the OPN was received, that is, if a pinpad was detected.</returns> public bool OpenPinpadConnection() { try { // Verifies if serial port is opened: if (this.Connection.IsOpen == false) { this.OpenConnectionSafely(); } // Closes pinpad connection: this.ClosePinpadConnection(string.Empty); // Open pinpad connection: OpnResponse response = this.SendRequestAndReceiveResponse <OpnResponse>(new OpnRequest()); if (response != null && response.RSP_STAT.Value == AbecsResponseStatus.ST_OK) { return(true); } } catch (IOException) { return(false); } catch (PropertyParseException) { this.ReceiveResponse <GenericResponse>(new AbecsContext()); return(this.OpenPinpadConnection()); } return(false); }
public void OPN_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadCommunication comm = new PinpadCommunication(conn); OpnRequest opn = new OpnRequest(); OpnResponse opnResp = comm.SendRequestAndReceiveResponse <OpnResponse>(opn); DspRequest dsp = new DspRequest(); dsp.DSP_MSG.Value = new SimpleMessageProperty("ola"); GenericResponse r = comm.SendRequestAndReceiveResponse <GenericResponse>(dsp); }