Esempio n. 1
0
        /// <summary>
        /// sendMessage send a CANMessage.
        /// </summary>
        /// <param name="a_message">A CANMessage.</param>
        /// <returns>true on success, othewise false.</returns>
        override protected bool sendMessageDevice(CANMessage a_message)
        {
            if (m_endThread)
            {
                return(false);
            }
            byte[] msg = a_message.getHeaderAndData();

            PassThruMsg txMsg = new PassThruMsg();

            txMsg.ProtocolID = ProtocolID.CAN;
            txMsg.TxFlags    = TxFlag.NONE;
            txMsg.SetBytes(msg);

            int       numMsgs = 1;
            const int timeout = 0;

            m_status = passThru.PassThruWriteMsgs(m_channelId, txMsg.ToIntPtr(), ref numMsgs, timeout);

            if (J2534Err.STATUS_NOERROR != m_status)
            {
                logger.Debug(String.Format("tx failed with status {0} {1}", m_status, BitConverter.ToString(msg)));
                return(false);
            }
            return(true);
        }