Esempio n. 1
0
        private static void PerformFullSystemTest(int timeLimit)
        {
            BrctcSpaceLibrary.Vibe2020Programs.FullSystemSharedRTC test = new BrctcSpaceLibrary.Vibe2020Programs.FullSystemSharedRTC(true, false);

            CancellationTokenSource source = new CancellationTokenSource();

            CancellationToken token = source.Token;

            Console.WriteLine($"Time Limit: {timeLimit}");
            test.Run(timeLimit, token);

            using (BrctcSpaceLibrary.Device.UART telemetry = new BrctcSpaceLibrary.Device.UART())
            {
                telemetry.SerialSend(EOP);
            }

            Console.WriteLine("Program Finished!");
        }
Esempio n. 2
0
        private static void TelemetryTest(string[] args)
        {
            Console.WriteLine($"Available Ports: {string.Join(',', BrctcSpaceLibrary.Device.UART.GetPorts())}");
            bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

            using (BrctcSpaceLibrary.Device.UART telemetry = isLinux ? new BrctcSpaceLibrary.Device.UART() : new BrctcSpaceLibrary.Device.UART("COM6"))
            {
                if (args != null && args.Length > 0 && args[0].ToLowerInvariant() == "send")
                {
                    Console.WriteLine("Entering UART loop. Press enter to end loop and continue.");

                    while (true)
                    {
                        try
                        {
                            telemetry.SerialSend("Hello!");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error sending message: " + ex.Message);
                        }
                    }
                }
                else if (args != null && args.Length > 0 && args[0].ToLowerInvariant() == "receive")
                {
                    Console.WriteLine("Entering UART read loop. Press enter to end loop and continue.");

                    bool hasRead = false;
                    telemetry.Subscribe((s, e) =>
                    {
                        try
                        {
                            //hasRead = true; let's keep reading instead

                            var text = telemetry.SerialRead();
                            if (!string.IsNullOrEmpty(text))
                            {
                                Console.WriteLine("Recieved message: " + text);
                            }
                            else
                            {
                                Console.WriteLine("Event triggered, but no text could be read!");
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error sending message: " + ex.Message);
                        }
                        finally
                        {
                        }
                    });

                    while (!hasRead)
                    {
                    }

                    telemetry.Unsubscribe();
                }
                else
                {
                    //assumes rx and tx lines are shorted together
                    telemetry.SelfTest(100);
                }
            }
        }