Exemplo n.º 1
0
        public void Connect()
        {
            if (serialPort != null)
            {
                Disconnect();
            }
            else
            {
                serialPort = new SerialPort(port, baud);
            }

            if (port != null)
            {
                serialPort.ReadTimeout  = 1000;
                serialPort.WriteTimeout = 1000;

                serialPort.Open();

                if (serialPort.IsOpen)
                {
                    WaitFor("wait", 5000);
                    Send(Gcode.ParseLine("M117 PrintSharp"));
                    WaitFor("ok 0", 5000);
                }
                else
                {
                    throw new Exception("Failed to open COM port " + port);
                }
            }
            else
            {
                throw new Exception("Cannot connect to NULL port");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string raw = "G1 F900 X49.728 Y37.435 E2.17868 ;Test";

            Command command = Gcode.ParseLine(raw);

            command.Debug = true;

            Console.WriteLine(command.ToString());

            Console.ReadLine();
        }
Exemplo n.º 3
0
        public void TestGcodeParseline()
        {
            string raw = "G1 F900 X49.728 Y37.435 E2.17868 ;Test";

            Command command = Gcode.ParseLine(raw);

            Assert.AreEqual(command.Text, raw);
            Assert.AreEqual(command.Code, "G1");
            Assert.AreEqual(command.Comment, "Test");
            Assert.AreNotEqual(command.Parameters, null);
            Assert.AreEqual(command.Parameters.Length, 4);
            Assert.AreEqual(command.Parameters[0], "F900");
            Assert.AreEqual(command.Parameters[1], "X49.728");
            Assert.AreEqual(command.Parameters[2], "Y37.435");
            Assert.AreEqual(command.Parameters[3], "E2.17868");
        }