/// <summary> /// Display LEGO Help to the console /// </summary> public static void ShowLegoHelp(LegoNxtService legoService) { legoService.LogConsoleError("Please make sure the LEGO NXT brick is turned on, connected\r\n" + " via Bluetooth, and configured to the proper port.\r\n" + " If you are having difficulty connecting for the first time,\r\n" + " please refer to the LEGO NXT readme found in your installation\r\n" + " directory at ...\\Samples\\Platforms\\LEGO\\NXT\\readme.htm\r\n"); }
/// <summary> /// Open a serial port. /// </summary> /// <param name="comPort"></param> /// <param name="baudRate"></param> /// <returns>A Ccr Port for receiving serial port data</returns> internal bool Open(int comPort, int baudRate) { if (buffer == null) { buffer = new byte[serialBufferLength]; } if (baudRate < 1200) { baudRate = 115200; } Close(); string portName = "COM" + comPort.ToString(System.Globalization.NumberFormatInfo.InvariantInfo); if (serialPort == null) { serialPort = new SerialPort(portName, baudRate); } else { serialPort.PortName = portName; serialPort.BaudRate = baudRate; } serialPort.Encoding = Encoding.Default; serialPort.Parity = Parity.None; serialPort.DataBits = 8; serialPort.StopBits = StopBits.One; serialPort.WriteTimeout = 2000; serialPort.ReadTimeout = 2000; try { serialPort.Open(); } catch { _legoService.LogConsoleError("Invalid Serial Port."); ShowLegoHelp(_legoService); return(false); } return(true); }