当前位置: 首页>>代码示例>>C#>>正文


C# CANMessage.setID方法代码示例

本文整理汇总了C#中TrionicCANLib.CAN.CANMessage.setID方法的典型用法代码示例。如果您正苦于以下问题:C# CANMessage.setID方法的具体用法?C# CANMessage.setID怎么用?C# CANMessage.setID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrionicCANLib.CAN.CANMessage的用法示例。


在下文中一共展示了CANMessage.setID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: waitForMessage

 /// <summary>
 /// waitForMessage waits for a specific CAN message give by a CAN id.
 /// </summary>
 /// <param name="a_canID">The CAN id to listen for</param>
 /// <param name="timeout">Listen timeout</param>
 /// <param name="r_canMsg">The CAN message with a_canID that we where listening for.</param>
 /// <returns>The CAN id for the message we where listening for, otherwise 0.</returns>
 public override uint waitForMessage(uint a_canID, uint timeout, out CANMessage canMsg)
 {
     Lawicel.CANUSB.CANMsg r_canMsg;
     canMsg = new CANMessage();
     int readResult = 0;
     int nrOfWait = 0;
     while (nrOfWait < timeout)
     {
         r_canMsg = new Lawicel.CANUSB.CANMsg();
         readResult = Lawicel.CANUSB.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == Lawicel.CANUSB.ERROR_CANUSB_OK)
         {
             Thread.Sleep(1);
             AddToCanTrace("rx: 0x" + r_canMsg.id.ToString("X4") + r_canMsg.data.ToString("X16"));
             if (r_canMsg.id == 0x00)
             {
                 nrOfWait++;
             }
             else if (r_canMsg.id != a_canID)
                 continue;
             canMsg.setData(r_canMsg.data);
             canMsg.setID(r_canMsg.id);
             canMsg.setLength(r_canMsg.len);
             return (uint)r_canMsg.id;
         }
         else if (readResult == Lawicel.CANUSB.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
             nrOfWait++;
         }
     }
     r_canMsg = new Lawicel.CANUSB.CANMsg();
     return 0;
 }
开发者ID:josla972,项目名称:Trionic,代码行数:41,代码来源:CANUSBDevice.cs

示例2: readMessages

        public void readMessages()
        {
            CANMessage canMessage = new CANMessage();

            Console.WriteLine("readMessages started");
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        Console.WriteLine("readMessages ended");
                        return;
                    }
                }
                if (rawString != null)
                {
                    logger.Trace(String.Format("Raw Data: {0}", rawString));
                    //AddToSerialTrace("RAW RX: " + rawString.Replace("\r",m_cr_sequence));
                    string rxString = rawString.Replace("\r", m_cr_sequence); //replace , because stringbuilder cannot handle \r
                    bool isStopped = false;

                    if (rxString.Length > 0)
                    {
                        //AddToSerialTrace("RECEIVE TEXT: " + rxString);
                        //System.Diagnostics.Debug.WriteLine("SERMSG: " + rxString);
                        var lines = ExtractLines(rxString);
                        foreach (var rxMessage in lines)
                        {
                            if (rxMessage.StartsWith("STOPPED")) { isStopped = true; }
                            else if (rxMessage.StartsWith("NO (MORE?) DATA")) { } //skip it
                            else if (rxMessage.StartsWith("CAN ERROR")) { } //handle error?
                            else if (rxMessage.StartsWith("ELM")) { isStopped = false; } //skip it, this is a trick to stop ELM from listening to more messages and send ready char
                            else if (rxMessage.StartsWith("?")) { isStopped = false; }
                            else if (rxMessage.Length == 19) // is it a valid line
                            {
                                try
                                {
                                    rxMessage.Replace(" ", "");//remove all whitespaces
                                    uint id = Convert.ToUInt32(rxMessage.Substring(0, 3), 16);
                                    if (acceptMessageId(id))
                                    {
                                        canMessage.setID(id);
                                        canMessage.setLength(8); // TODO: alter to match data
                                        //canMessage.setData(0x0000000000000000); // reset message content
                                        canMessage.setData(ExtractDataFromString(rxMessage));

                                        receivedMessage(canMessage);
                                    }
                                }
                                catch (Exception)
                                {
                                    //Console.WriteLine("MSG: " + rxMessage);
                                }
                            }
                            //disable whitespace logging
                            if (rxMessage.Length > 0)
                            {
                                logger.Debug("TELNET: " + rxMessage);
                            }
                        }
                    }
                    if (!isStopped)
                    {
                        logger.Debug("TELNET READY");
                        interfaceBusy = false;
                    }
                    rawString = null;
                }
            }
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:71,代码来源:CANMXWiFiDevice.cs

示例3: waitForMessage

        //---------------------------------------------------------------------------------------------
        /**
        Waits for arrival of a specific CAN message or any message if ID = 0.

        @param      a_canID     message ID
        @param      timeout     timeout, ms
        @param      canMsg      message

        @return                 message ID
        */
        public override uint waitForMessage(uint a_canID, uint timeout,
        out CANMessage canMsg)
        {
            canMsg = new CANMessage();
            Debug.Assert(canMsg != null);
            canMsg.setID(0);

            caCombiAdapter.caCANFrame frame = new caCombiAdapter.caCANFrame();
            if (this.combi.CAN_GetMessage(ref frame, timeout) &&
            (frame.id == a_canID || a_canID == 0))
            {
            // message received
            canMsg.setID(frame.id);
            canMsg.setLength(frame.length);
            canMsg.setData(frame.data);

            return frame.id;
            }

            // timed out
            return 0;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:32,代码来源:LPCCANDevice.cs

示例4: readMessages

 /// <summary>
 /// readMessages is the "run" method of this class. It reads all incomming messages
 /// and publishes them to registered ICANListeners.
 /// </summary>
 public void readMessages()
 {
     int readResult = 0;
     Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
     CANMessage canMessage = new CANMessage();
     Console.WriteLine("readMessages started");
     while (true)
     {
         lock (m_synchObject)
         {
             if (m_endThread)
             {
                 Console.WriteLine("readMessages ended");
                 return;
             }
         }
         readResult = Lawicel.CANUSB.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == Lawicel.CANUSB.ERROR_CANUSB_OK)
         {
             if (acceptMessageId(r_canMsg.id))
             {
                 canMessage.setID(r_canMsg.id);
                 canMessage.setLength(r_canMsg.len);
                 canMessage.setTimeStamp(r_canMsg.timestamp);
                 canMessage.setFlags(r_canMsg.flags);
                 canMessage.setData(r_canMsg.data);
                 lock (m_listeners)
                 {
                     AddToCanTrace(string.Format("RX: {0} {1}", canMessage.getID().ToString("X3"), canMessage.getData().ToString("X16")));
                     foreach (ICANListener listener in m_listeners)
                     {
                         listener.handleMessage(canMessage);
                     }
                 }
             }
         }
         else if (readResult == Lawicel.CANUSB.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
         }
     }
 }
开发者ID:josla972,项目名称:Trionic,代码行数:46,代码来源:CANUSBDevice.cs

示例5: waitAnyMessage

        /// <summary>
        /// waitAnyMessage waits for any message to be received.
        /// </summary>
        /// <param name="timeout">Listen timeout</param>
        /// <param name="r_canMsg">The CAN message that was first received</param>
        /// <returns>The CAN id for the message received, otherwise 0.</returns>
        private uint waitAnyMessage(uint timeout, out Lawicel.CANUSB.CANMsg r_canMsg)
        {
            CANMessage canMessage = new CANMessage();

            string line = string.Empty;

            int readResult = 0;
            int nrOfWait = 0;
            while (nrOfWait < timeout)
            {
                m_serialPort.Write("\r");
                m_serialPort.Write("P\r");
                bool endofFrames = false;
                while (!endofFrames)
                {
                    Console.WriteLine("reading line");
                    line = m_serialPort.ReadLine();
                    Console.WriteLine("line: " + line + " len: " + line.Length.ToString());
                    if (line[0] == '\x07' || line[0] == '\r' || line[0] == 'A')
                    {
                        endofFrames = true;
                    }
                    else
                    {

                        if (line.Length == 14)
                        {
                            // three bytes identifier
                            r_canMsg = new Lawicel.CANUSB.CANMsg();
                            r_canMsg.id = (uint)Convert.ToInt32(line.Substring(1, 3), 16);
                            r_canMsg.len = (byte)Convert.ToInt32(line.Substring(4, 1), 16);
                            ulong data = 0;
                            // add all the bytes
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(5, 2), 16) << 7 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(7, 2), 16) << 6 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(9, 2), 16) << 5 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(11, 2), 16) << 4 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(13, 2), 16) << 3 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(15, 2), 16) << 2 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(17, 2), 16) << 1 * 8;
                            data |= (ulong)(byte)Convert.ToInt32(line.Substring(19, 2), 16);
                            r_canMsg.data = data;
                            canMessage.setID(r_canMsg.id);
                            canMessage.setLength(r_canMsg.len);
                            canMessage.setFlags(0);
                            canMessage.setData(r_canMsg.data);

                            return (uint)r_canMsg.id;

                        }
                    }

                }
                //Thread.Sleep(0);
                nrOfWait++;
            }
            r_canMsg = new Lawicel.CANUSB.CANMsg();
            return 0;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:65,代码来源:CANUSBDirectDevice.cs

示例6: readMessages

        /// <summary>
        /// readMessages is the "run" method of this class. It reads all incomming messages
        /// and publishes them to registered ICANListeners.
        /// </summary>
        public void readMessages()
        {
            int readResult = 0;
            Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
            CANMessage canMessage = new CANMessage();
            logger.Debug("readMessages started");
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        logger.Debug("readMessages thread ended");
                        return;
                    }
                }
                readResult = Lawicel.CANUSB.canusb_Read(m_deviceHandle, out r_canMsg);
                if (readResult == Lawicel.CANUSB.ERROR_CANUSB_OK)
                {
                    if (acceptMessageId(r_canMsg.id))
                    {
                        canMessage.setID(r_canMsg.id);
                        canMessage.setLength(r_canMsg.len);
                        canMessage.setTimeStamp(r_canMsg.timestamp);
                        canMessage.setFlags(r_canMsg.flags);
                        canMessage.setData(r_canMsg.data);

                        receivedMessage(canMessage);
                    }
                }
                else if (readResult == Lawicel.CANUSB.ERROR_CANUSB_NO_MESSAGE)
                {
                    Thread.Sleep(1);
                }
            }
        }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:40,代码来源:CANUSBDevice.cs

示例7: waitAnyMessage

        /// <summary>
        /// waitAnyMessage waits for any message to be received.
        /// </summary>
        /// <param name="timeout">Listen timeout</param>
        /// <param name="r_canMsg">The CAN message that was first received</param>
        /// <returns>The CAN id for the message received, otherwise 0.</returns>
        private uint waitAnyMessage(uint timeout, out CANMessage canMessage)
        {
            canMessage = new CANMessage();
            Debug.Assert(canMessage != null);

            int wait_cnt = 0;
            uint id;
            byte length;
            ulong data;
            while (wait_cnt < timeout)
            {
            if (MctAdapter_ReceiveMessage(out id, out length, out data))
            {
                // message received
                canMessage.setID(id);
                canMessage.setLength(length);
                canMessage.setData(data);

                return id;
            }

            // wait a bit
            Thread.Sleep(1);
            ++wait_cnt;
            }

            // nothing was received
            return 0;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:35,代码来源:MictronicsCanDevice.cs

示例8: readMessages

        // int thrdcnt = 0;
        /// <summary>
        /// readMessages is the "run" method of this class. It reads all incomming messages
        /// and publishes them to registered ICANListeners.
        /// </summary>
        public void readMessages()
        {
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        m_endThread = false;
                        return;
                    }
                }
                if (m_serialPort.IsOpen)
                {
                    // read the status?

                    string line = string.Empty;

                    try
                    {
                        line = m_serialPort.ReadLine();
                        if (line.Length > 0)
                        {
                            if (line.Length == 25)
                            {
                                Lawicel.CANUSB.CANMsg r_canMsg = new Lawicel.CANUSB.CANMsg();
                                canMessage = new CANMessage();
                                // three bytes identifier
                                r_canMsg.id = (uint)Convert.ToInt32(line.Substring(1, 3), 16);
                                r_canMsg.len = (byte)Convert.ToInt32(line.Substring(4, 1), 16);
                                ulong data = 0;
                                // add all the bytes
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(5, 2), 16);
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(7, 2), 16) << 1 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(9, 2), 16) << 2 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(11, 2), 16) << 3 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(13, 2), 16) << 4 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(15, 2), 16) << 5 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(17, 2), 16) << 6 * 8;
                                data |= (ulong)(byte)Convert.ToInt32(line.Substring(19, 2), 16) << 7 * 8;
                                r_canMsg.data = data;
                                canMessage.setID(r_canMsg.id);
                                canMessage.setLength(r_canMsg.len);
                                canMessage.setFlags(r_canMsg.flags);
                                canMessage.setData(r_canMsg.data);

                                lock (m_listeners)
                                {
                                    AddToCanTrace(string.Format("RX: {0} {1} {2}", canMessage.getID().ToString("X3"), line.Substring(5, 16), line));
                                    foreach (ICANListener listener in m_listeners)
                                    {
                                        listener.handleMessage(canMessage);
                                    }
                                }
                            }
                            else if(line.Contains("z"))
                            {
                                interfaceBusy = false;
                                //Console.WriteLine("clear");
                            }
                            else if (line.Length == 2 && Convert.ToInt32(line.Substring(1, 2), 16) != 0x07)
                            {
                                //Console.WriteLine("Send error");
                            }
                            else
                            {
                                //Console.WriteLine("Unknown message: " + line);
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("Failed to read frames from CANbus: " + E.Message);
                    }
                }
                //Thread.Sleep(2);
                Thread.Sleep(delayTimespan); // give others some air
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:84,代码来源:CANUSBDirectDevice.cs

示例9: waitForMessage

        /// <summary>
        /// waitForMessage waits for a specific CAN message give by a CAN id.
        /// </summary>
        /// <param name="a_canID">The CAN id to listen for</param>
        /// <param name="timeout">Listen timeout</param>
        /// <param name="r_canMsg">The CAN message with a_canID that we where listening for.</param>
        /// <returns>The CAN id for the message we where listening for, otherwise 0.</returns>
        public override uint waitForMessage(uint a_canID, uint timeout, out CANMessage canMessage)
        {
            canMessage = new CANMessage();
            Debug.Assert(canMessage != null);

            int wait_cnt = 0;
            uint id;
            byte length;
            ulong data;
            while (wait_cnt < timeout)
            {
            if (MctAdapter_ReceiveMessage(out id, out length, out data))
            {
                // message received
                canMessage.setID(id);
                canMessage.setLength(length);
                canMessage.setData(data);

                if (canMessage.getID() != a_canID)
                    continue;
                return (uint)canMessage.getID();
            }

            // wait a bit
            Thread.Sleep(1);
            ++wait_cnt;
            }

            // nothing was received
            return 0;
        }
开发者ID:josla972,项目名称:Trionic,代码行数:38,代码来源:MictronicsCanDevice.cs

示例10: read_messages

        //-------------------------------------------------------------------------
        /**
        Handles incoming messages.
        */
        private void read_messages()
        {
            uint id;
            byte length;
            ulong data;

            CANMessage msg = new CANMessage();
            Debug.Assert(msg != null);

            // main loop
            while (true)
            {
            // check for thread termination request
            Debug.Assert(this.term_mutex != null);
            lock (this.term_mutex)
            {
                if (this.term_requested)
                {
                    return;
                }
            }

            // receive messages
            while (MctAdapter_ReceiveMessage(out id, out length, out data))
            {
                if (acceptMessageId(id))
                {
                    // convert message
                    msg.setID(id);
                    msg.setLength(length);
                    msg.setData(data);

                    // pass message to listeners
                    lock (this.m_listeners)
                    {
                        AddToCanTrace("RX: " + id.ToString("X4") + " " + data.ToString("X16"));
                        foreach (ICANListener listener in this.m_listeners)
                        {
                            listener.handleMessage(msg);
                        }
                    }
                }
            }

            // give up CPU for a moment
            Thread.Sleep(1);
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:52,代码来源:MictronicsCanDevice.cs

示例11: waitForMessage

 /// <summary>
 /// waitForMessage waits for a specific CAN message give by a CAN id.
 /// </summary>
 /// <param name="a_canID">The CAN id to listen for</param>
 /// <param name="timeout">Listen timeout</param>
 /// <param name="r_canMsg">The CAN message with a_canID that we where listening for.</param>
 /// <returns>The CAN id for the message we where listening for, otherwise 0.</returns>
 public override uint waitForMessage(uint a_canID, uint timeout, out CANMessage canMsg)
 {
     EASYSYNC.CANMsg r_canMsg;
     canMsg = new CANMessage();
     int readResult = 0;
     int nrOfWait = 0;
     while (nrOfWait < timeout)
     {
         r_canMsg = new EASYSYNC.CANMsg();
         readResult = EASYSYNC.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == EASYSYNC.ERROR_CANUSB_OK)
         {
             if (r_canMsg.id == 0x00)
             {
                 nrOfWait++;
             }
             else if (r_canMsg.id != a_canID)
                 continue;
             canMsg.setData(r_canMsg.data);
             canMsg.setID(r_canMsg.id);
             canMsg.setLength(r_canMsg.len);
             return (uint)r_canMsg.id;
         }
         else if (readResult == EASYSYNC.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
             nrOfWait++;
         }
     }
     r_canMsg = new EASYSYNC.CANMsg();
     return 0;
 }
开发者ID:josla972,项目名称:Trionic,代码行数:39,代码来源:EasySyncUSBDevice.cs

示例12: readMessages

 /// <summary>
 /// readMessages is the "run" method of this class. It reads all incomming messages
 /// and publishes them to registered ICANListeners.
 /// </summary>
 public void readMessages()
 {
     int readResult = 0;
     EASYSYNC.CANMsg r_canMsg = new EASYSYNC.CANMsg();
     CANMessage canMessage = new CANMessage();
     while (true)
     {
         lock (m_synchObject)
         {
             if (m_endThread)
                 return;
         }
         readResult = EASYSYNC.canusb_Read(m_deviceHandle, out r_canMsg);
         if (readResult == EASYSYNC.ERROR_CANUSB_OK)
         {
             canMessage.setID(r_canMsg.id);
             canMessage.setLength(r_canMsg.len);
             canMessage.setTimeStamp(r_canMsg.timestamp);
             canMessage.setFlags(r_canMsg.flags);
             canMessage.setData(r_canMsg.data);
             lock (m_listeners)
             {
                 foreach (ICANListener listener in m_listeners)
                 {
                     listener.handleMessage(canMessage);
                 }
             }
         }
         else if (readResult == EASYSYNC.ERROR_CANUSB_NO_MESSAGE)
         {
             Thread.Sleep(1);
         }
     }
 }
开发者ID:josla972,项目名称:Trionic,代码行数:38,代码来源:EasySyncUSBDevice.cs

示例13: readMessages

        public void readMessages()
        {
            CANMessage canMessage = new CANMessage();
            StringBuilder receiveText = new StringBuilder();

            Console.WriteLine("readMessages started");
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        Console.WriteLine("readMessages ended");
                        return;
                    }
                }

                receiveDataSemaphore.WaitOne();

                if (m_serialPort != null)
                {
                    if (m_serialPort.IsOpen)
                    {
                        if (m_serialPort.BytesToRead > 0)
                        {
                            string rawString = m_serialPort.ReadExisting();
                            //AddToSerialTrace("RAW RX: " + rawString.Replace("\r",m_cr_sequence));
                            string rxString = rawString.Replace("\n", "").Replace(">", "");// remove prompt characters... we don't need that stuff
                            bool isStopped = false;

                            if (rxString.Length > 0)
                            {
                                rxString = rxString.Replace("\r", m_cr_sequence); //replace , because stringbuilder cannot handle \r
                                receiveText.Append(rxString);
                                //AddToSerialTrace("RECEIVE TEXT: " + receiveText.ToString());
                                //System.Diagnostics.Debug.WriteLine("SERMSG: " + receiveText);
                                var lines = ExtractLines(ref receiveText);
                                foreach (var rxMessage in lines)
                                {
                                    if (rxMessage.StartsWith("STOPPED")) { isStopped = true; }
                                    else if (rxMessage.StartsWith("NO DATA")) { } //skip it
                                    else if (rxMessage.StartsWith("CAN ERROR"))
                                    {
                                        //handle error?
                                    }
                                    else if (rxMessage.StartsWith("ELM")) { isStopped = false; } //skip it, this is a trick to stop ELM from listening to more messages and send ready char
                                    else if (rxMessage.StartsWith("?")) { isStopped = false; }
                                    else if (rxMessage.StartsWith("NO DATA"))
                                    {
                                        AddToSerialTrace("NO DATA");
                                        Console.WriteLine("NO DATA");
                                    }
                                    else if (rxMessage.Length == 19) // is it a valid line
                                    {
                                        try
                                        {
                                            rxMessage.Replace(" ", "");//remove all whitespaces
                                            uint id = Convert.ToUInt32(rxMessage.Substring(0, 3), 16);
                                            if (acceptMessageId(id))
                                            {
                                                canMessage.setID(id);
                                                canMessage.setLength(8); // TODO: alter to match data
                                                //canMessage.setData(0x0000000000000000); // reset message content
                                                canMessage.setData(ExtractDataFromString(rxMessage));

                                                lock (m_listeners)
                                                {
                                                    AddToCanTrace(string.Format("RX: {0} {1}", canMessage.getID().ToString("X3"), canMessage.getData().ToString("X16")));
                                                    foreach (ICANListener listener in m_listeners)
                                                    {
                                                        listener.handleMessage(canMessage);
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            //Console.WriteLine("MSG: " + rxMessage);
                                        }
                                    }
                                     //disable whitespace logging
                                    if (rxMessage.Length > 0)
                                    {
                                        AddToSerialTrace("SERRX: " + rxMessage);
                                    }
                                }
                            }
                            if (rawString.Contains(">") && !isStopped)
                            {
                                AddToSerialTrace("SERIAL READY");
                                sendDataSempahore.WaitOne(0);
                                sendDataSempahore.Release();
                                interfaceBusy = false;
                            }
                        }
                    }
                }
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:99,代码来源:CANELM327Device.cs

示例14: readMessages

        public void readMessages()
        {
            CANMessage canMessage = new CANMessage();
            string rxMessage = string.Empty;

            Console.WriteLine("readMessages started");
            while (true)
            {
                lock (m_synchObject)
                {
                    if (m_endThread)
                    {
                        Console.WriteLine("readMessages ended");
                        return;
                    }
                }

                try
                {
                    if (m_serialPort.IsOpen)
                    {
                        do
                        {
                            rxMessage = m_serialPort.ReadLine();
                            rxMessage = rxMessage.Replace("\r", ""); // remove prompt characters... we don't need that stuff
                            rxMessage = rxMessage.Replace("\n", ""); // remove prompt characters... we don't need that stuff
                        } while (rxMessage.StartsWith("w") == false);

                        uint id = Convert.ToUInt32(rxMessage.Substring(1, 3), 16);
                        if (acceptMessageId(id))
                        {
                            canMessage.setID(id);
                            canMessage.setLength(8);
                            canMessage.setData(0x0000000000000000);
                            for (uint i = 0; i < 8; i++)
                                canMessage.setCanData(Convert.ToByte(rxMessage.Substring(5 + (2 * (int)i), 2), 16), i);

                            lock (m_listeners)
                            {
                                AddToCanTrace("RX: " + canMessage.getID().ToString("X3") + " " + canMessage.getLength().ToString("X1") + " " + canMessage.getData().ToString("X16"));
                                //Console.WriteLine("MSG: " + rxMessage);
                                foreach (ICANListener listener in m_listeners)
                                {
                                    listener.handleMessage(canMessage);
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("MSG: " + rxMessage);
                }
            }
        }
开发者ID:josla972,项目名称:Trionic,代码行数:55,代码来源:Just4TrionicDevice.cs

示例15: SendMessage

 private void SendMessage(uint id, ulong data)
 {
     CANMessage msg = new CANMessage();
     msg.setID(id);
     msg.setLength(8);
     msg.setData(data);
     if (!canUsbDevice.sendMessage(msg))
     {
         Console.WriteLine("Failed to send message");
     }
 }
开发者ID:ChrisPea,项目名称:Trionic,代码行数:11,代码来源:Trionic8.cs


注:本文中的TrionicCANLib.CAN.CANMessage.setID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。