Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new Instance of VirtualTWI-Master (which is operating via M3S-Master/Slave)
        /// </summary>
        /// <param name="rDevComMaster">Ready Instance of M3S-Master</param>
        /// <param name="vM3SSlaveAddress">Address of M3S-Slave which is operating as a M3SSlave-to-TWIMaster</param>
        public VirtualTWIMaster(DevComMaster rDevComMaster, int vM3SSlaveAddress)
        {
            int checkValue = TBL.Check.CheckM3SSlaveAddress(vM3SSlaveAddress);

            if (checkValue != 0)
            {
                throw new System.ArgumentException("The passed vM3SSlaveAddress is invalid!! " + EDOLL.EDOLLHandler.Verbalize(checkValue) + System.Environment.NewLine + "Refer Documentation of M3S-Protocol for details. ");
            }
            master  = rDevComMaster;
            m3sAddr = vM3SSlaveAddress;
        }
Ejemplo n.º 2
0
        void Mnu_startClick(object sender, EventArgs e)
        {
            string readPort;
            // TODO: Auswahl TCP-Client oder USB

            form_cps selector = new form_cps();

            if (selector.ShowDialog() == DialogResult.OK)
            {
                readPort = selector.SelectedPort;
            }
            else
            {
                return;
            }

            string readBaudrate = TBL.Routines.InputBox("Specify Baudrate (bps): ", "Baudrate", devComSerialInterface.DefaultBaudrate.ToString());


            if (readBaudrate == string.Empty)
            {
                return;
            }

            int baudrate;

            if (!int.TryParse(readBaudrate, out baudrate))
            {
                stdOut.Error("Could not parse Baudrate. Only integer values allowed. Please try again");
                return;
            }



            devComSerialInterface client = new devComSerialInterface(readPort, 38400);

            busListener = new DevComMaster(client);

            if (busListener.ConnectWithoutReset())
            {
                this.Controls.Add(log.Visualisation);
                log.VisualizationFitWindowSize(this);
                log.Location              = frameLogTopLeft;
                busListener.ByteReceived += new ByteReceivedEventHandler(bufferAdded);
                mnu_start.Enabled         = false;
                mnu_stop.Enabled          = true;
            }
            else
            {
                stdOut.Error(EDOLLHandler.GetLastError(), busListener.InfoString);
            }
        }
Ejemplo n.º 3
0
        private static void ping(string[] mainArgs)
        {
            TBL.Communication.IDevComHardwareInterface hwIfc;

            if (0 == TBL.Check.CheckSerialPortName(mainArgs[1]))
            {
                int baudrate;


                if (mainArgs.Length < 4)
                {
                    Console.WriteLine("Baudrate defaults to " + TBL.Communication.devComSerialInterface.DefaultBaudrate + "bps");
                    baudrate = TBL.Communication.devComSerialInterface.DefaultBaudrate;
                }
                else
                if (!int.TryParse(mainArgs[3], out baudrate))
                {
                    Console.WriteLine("The specified Baudrate in parameter 4 suffers from invalid syntax: '" + mainArgs[3] + "'");
                    return;
                }


                hwIfc = new TBL.Communication.devComSerialInterface(mainArgs[1], baudrate);
            }
            else if (0 == TBL.Check.CheckIP(mainArgs[1]))
            {
                throw new NotImplementedException();
            }
            else
            {
                Console.WriteLine("The specified Interface (parameter 2) suffers from invalid syntax: '" + mainArgs[1] + "'");
                return;
            }

            int          slaveAddr;
            DevComMaster m3sMaster = new DevComMaster(hwIfc);

            if (!int.TryParse(mainArgs[2], out slaveAddr))
            {
                Console.WriteLine("The specified Slave-Address in parameter 3 suffers from invalid syntax: '" + mainArgs[2] + "'");
                return;
            }



            int err;

            if (!m3sMaster.Connect(out err))
            {
                Console.WriteLine("Could not connect on Interface." + Environment.NewLine + TBL.EDOLL.EDOLLHandler.Verbalize(err));
            }
            long rtt;

            if (m3sMaster.Ping(slaveAddr, out rtt, out err))
            {
                Console.WriteLine("Ping to Slave #" + slaveAddr.ToString() + " successful, RTT=" + rtt.ToString());
            }
            else
            {
                Console.WriteLine("ReadTimeout reached when pinging Slave #" + slaveAddr);
            }


            byte[] payload   = { 0xF0, 0xC0, 0xC0, 0xF8, 0x00, 0xC0, 0x80, 0x00, 0xC0, 0xC0, 0x80, 0xC0, 0x00, 0x00, 0x80, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x00, 0xF8, 0xF0, 0xC0, 0xC0, 0xF0, 0xC0, 0xC0, 0xF8 };
            byte[] updateCmd = { (byte)TBL.Communication.Protocol.M3SCommand.Update };
            byte[] errorCMD  = { 0xff };

            if (!m3sMaster.SendCommand(1, errorCMD, out err, true))
            {
                TBL.EDOLL.stdOut.Error(TBL.EDOLL.EDOLLHandler.Verbalize(err));
            }


            if (!m3sMaster.SendData(1, payload, out err, true))
            {
                TBL.EDOLL.stdOut.Error(TBL.EDOLL.EDOLLHandler.Verbalize(err));
            }

            if (!m3sMaster.SendCommandBroadcast(updateCmd, out err))
            {
                TBL.EDOLL.stdOut.Error(TBL.EDOLL.EDOLLHandler.Verbalize(err));
            }
        }
Ejemplo n.º 4
0
        /*public static void Main(string[] args)
         * {
         *      /*MySQLDatabaseHandler handler = new MySQLDatabaseHandler("localhost","gfi","gfi","habicht");
         *      handler.DebugMode = true;
         *      BlackboardDatabaseConnector conn = new BlackboardDatabaseConnector(handler,"MessageBoard");
         *
         *      Blackboard board = new Blackboard(conn,5);
         *
         *      Console.ReadLine();
         *
         *      Console.WriteLine(TBL.Runtime.ExecutableDirectory);
         *      Console.ReadLine();
         *
         * }	// */

        public static void Main(string[] args)
        {
            DevComMaster[] masters = DevComMaster.CreateDevComsFromCSV(@"D:\ticker\software\tickerOS\tickerOS\bin\DebugVirtualOut\bus.conf");
            Console.ReadLine();
        }               //*/