public Form1() { InitializeComponent(); string[] comPorts = SerialPort.GetPortNames(); serialPortSelect.Items.AddRange(comPorts); serialPortSelect.SelectedIndex = 0; webcam = new WebCam(); webcam.InitializeWebCam(ref webcamPreviewBox); brain = new Brain(ref serialPort1, webcam); brain.FireLogMessage += OnLogMessage; brain.FireStartWebcam += OnStartWebcam; }
public Brain(ref SerialPort _serialPort, WebCam _webcam) { this.serialPort = _serialPort; this.webcam = _webcam; serialPort.BaudRate = 115200; serialPort.Parity = System.IO.Ports.Parity.None; serialPort.DataBits = 8; serialPort.StopBits = System.IO.Ports.StopBits.One; serialPort.Handshake = System.IO.Ports.Handshake.None; //serialPort.WriteBufferSize = 1048576; // 1MB serialPort.ReadBufferSize = 2048576; // MUST be > 307200 bytes to get full image back serialPort.ReadTimeout = 1400; serialPort.WriteTimeout = 1400; serialPort.DataReceived += DataReceivedHandler; }