Exemplo n.º 1
0
        /// <summary>
        /// Transmit CAN message via ES581.3
        /// </summary>
        public int nWriteMessage(sTCAN_MSG sMessage)
        {
            int nReturn = 0;

            icsSpyMessage SpyMsg = new icsSpyMessage();

            SpyMsg.ArbIDOrHeader   = (int)sMessage.m_unMsgID;
            SpyMsg.NumberBytesData = sMessage.m_ucDataLen;
            SpyMsg.StatusBitField  = 0;
            SpyMsg.StatusBitField2 = 0;
            if (sMessage.m_ucRTR == 1)
            {
                SpyMsg.StatusBitField |= (uint)SPY_STATUS_REMOTE_FRAME;
            }
            if (sMessage.m_ucEXTENDED == 1)
            {
                SpyMsg.StatusBitField |= (uint)SPY_STATUS_XTD_FRAME;
            }
            SpyMsg.Data = sMessage.m_ucData;  // what if data> 8Byte?
            if (icsneoTxMessages(m_anhObject, ref SpyMsg, 1, 1) != 0)
            {
                nReturn = 1;
            }
            return(nReturn);
        }
Exemplo n.º 2
0
 /// <summary>
 /// copy sTCANDATA to sTCAN_MSG
 /// </summary>
 /// <param name="sdata"></param>
 /// <param name="sMessage"></param>
 public void CopysTDataTosTMsg(sTCANDATA sdata, ref sTCAN_MSG sMessage)
 {
     sMessage.m_unMsgID    = sdata.m_uDataInfo.m_sCANMsg.m_unMsgID;
     sMessage.m_ucDataLen  = sdata.m_uDataInfo.m_sCANMsg.m_ucDataLen;
     sMessage.m_ucData     = sdata.m_uDataInfo.m_sCANMsg.m_ucData;
     sMessage.m_ucChannel  = sdata.m_uDataInfo.m_sCANMsg.m_ucChannel;
     sMessage.m_ucEXTENDED = sdata.m_uDataInfo.m_sCANMsg.m_ucEXTENDED;
     sMessage.m_ucRTR      = sdata.m_uDataInfo.m_sCANMsg.m_ucRTR;
     sMessage.m_bCANFD     = sdata.m_uDataInfo.m_sCANMsg.m_bCANFD;
 }
Exemplo n.º 3
0
        /// <summary>
        /// This will receive can message and trans into datagridview type array.
        /// </summary>
        public string[] CANTxMsgToString(sTCAN_MSG sMessage)
        {
            string type = "Tx";

            byte[] tmpCAN = new byte[sMessage.m_ucDataLen];
            for (int i = 0; i < sMessage.m_ucDataLen; i++)
            {
                tmpCAN[i] = sMessage.m_ucData[i];
            }
            string CANData = ArrayToString(tmpCAN);

            string[] values =
            {
                DateTime.Now.ToString("HH:mm:ss.ffff"),
                type,
                sMessage.m_ucChannel.ToString(),
                GetFrameType(sMessage.m_ucData[0]),
                sMessage.m_unMsgID.ToString("X2"),
                sMessage.m_ucDataLen.ToString(),
                CANData
            };
            return(values);
        }