using System;
using System.Collections.Generic;
using System.Linq;

using System.Windows.Forms;

namespace RS485tool
{
  static class Program
  {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]

    
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      string errmsg = "";
      bool ok = false;
      if (YAPI.TestHub("127.0.0.1", 200, ref errmsg) == YAPI.SUCCESS)
      { ok = (YAPI.RegisterHub("127.0.0.1", ref errmsg) == YAPI.SUCCESS);
        UsingVirtualHub = ok;
      } else ok = (YAPI.RegisterHub("usb", ref errmsg) == YAPI.SUCCESS) ;
      if (ok)  Application.Run(new MainForm());
      else MessageBox.Show("Failed to start Yoctopuce API (" + errmsg + ")", "RS485 tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
      YAPI.FreeAPI();
    }
    static public Boolean UsingVirtualHub = false;
  }
}
