Beispiel #1
0
        private void initAnalyzers()
        {
            ApiAnalyzer = new SerialComm(MachinePortName, MachineBaudrate, (byte)ModuleId_t.Touch_e);
            ApiAnalyzer.ReceiveOnlyMode = true;
            ApiAnalyzer.RegisterAckTimeoutHandler(apiAckTimeoutCallback);
            ApiAnalyzer.RegisterNackFailHandler(apiNackFailCallback);
            ApiAnalyzer.RegisterPacketReceivedHandler(apiReceivedCallback);
            ApiAnalyzer.RegisterPacketSentHandler(apiSentCallback);
            ApiAnalyzer.RegisterResponseTimeoutHandler(apiResponseTimeoutCallback);
            ApiAnalyzer.ackNackReceived += new SerialComm.PacketEvent(ApiAnalyzer_ackNackReceived);
            ApiAnalyzer.StartThread();

            MachineAnalyzer = new SerialComm(MachinePortName, MachineBaudrate, (byte)ModuleId_t.Api_e);
            MachineAnalyzer.ReceiveOnlyMode = true;
            MachineAnalyzer.RegisterAckTimeoutHandler(machineAckTimeoutCallback);
            MachineAnalyzer.RegisterNackFailHandler(machineNackFailCallback);
            MachineAnalyzer.RegisterPacketReceivedHandler(machineReceivedCallback);
            MachineAnalyzer.RegisterPacketSentHandler(machineSentCallback);
            MachineAnalyzer.RegisterResponseTimeoutHandler(machineResponseTimeoutCallback);
            MachineAnalyzer.ackNackReceived += new SerialComm.PacketEvent(MachineAnalyzer_ackNackReceived);
            MachineAnalyzer.StartThread();
        }
Beispiel #2
0
        /// <summary>
        /// Start the serial communication.
        /// </summary>
        private void serialportForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            SerialportForm spf = sender as SerialportForm;

            serialSession = new SerialComm(spf.serialPort.PortName, spf.serialPort.BaudRate, (byte)ModuleId_t.Api_e);
            serialSession.MaxSendRepetition = 3;

            // Register all handler methods for the various comm events.
            serialSession.RegisterPacketReceivedHandler(telegramReceivedCallback);
            serialSession.RegisterPacketSentHandler(telegramSentCallback);
            serialSession.RegisterAckTimeoutHandler(ackTimeoutCallback);
            serialSession.RegisterNackFailHandler(nackFailCallback);
            serialSession.RegisterResponseTimeoutHandler(responseTimeoutCallback);
            serialSession.ackNackReceived += new SerialComm.PacketEvent(ackNackReceivedHandler);

            ApiDataReceived += new PacketCallback(API_ReceiveData);

            serialSession.Start();

            // Comm Labels
            lblPort.Text = "Portname: " + spf.serialPort.PortName;
            lblBaud.Text = "Baudrate: " + spf.serialPort.BaudRate;
        }