選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

39 行
1.0 KiB

  1. using System.Collections.Generic;
  2. using System.Diagnostics;
  3. using System.IO.Ports;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. namespace ThunderboltTimeSync {
  7. public partial class FormMain : Form {
  8. public FormMain() {
  9. // Check for admin rights
  10. // If running as admin:
  11. // Ask for COM port with dialog
  12. // Connect to COM port
  13. // When time message received:
  14. // If (time in UTC) AND (last time change was more than $MIN_UPDATE_INTERVAL ago) AND (error is less than $ERROR_THRESHOLD)
  15. // Change system time to GPS time
  16. // Else:
  17. // Display message to tell user to run as admin
  18. // Quit
  19. InitializeComponent();
  20. ThunderboltSerialPort tbsp = new ThunderboltSerialPort(new SerialPort("COM3"));
  21. tbsp.PacketReceived += (List<byte> packetBuffer) => {
  22. List<string> byteStrings = packetBuffer.Select(x => string.Format("{0:X2}", x)).ToList();
  23. Debug.WriteLine(
  24. string.Format(
  25. "Packet received: {0}",
  26. string.Join(" ", byteStrings)
  27. )
  28. );
  29. };
  30. tbsp.Open();
  31. }
  32. }
  33. }