I'm working on a project in WPF where I read in serial data from my "Serial_In" class. Currently I am using:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
namespace Airlink_II
{
class Serial_In
{
private string data;
public System.IO.Ports.SerialPort Serial;
public void GPS_Init()
{
Serial = new SerialPort();
Serial.PortName = "COM1";
Serial.BaudRate = 9600;
Serial.Parity = Parity.None;
Serial.StopBits = StopBits.One;
Serial.DataBits = 8;
Serial.Handshake = Handshake.None;
Serial.ReadTimeout = 50000;
Serial.WriteTimeout = 50000;
Serial.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
Serial.Close();
Serial.Open();
}
void DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// data = recieved string that I want to pass back to my "public MainWindow()" (which is the entry point for WPF)
}
}
}
The strings received on the serial port will be random and I need to parse and populate a structure with the information before I can read in another string. I'm having problems with this, I don't want to have one large .cs file I would like to have it split up.
Here is my WPF entry point:
namespace Airlink_II
{
public partial class MainWindow : Window
{
Aircraft_Database WMI_AC;
Serial_In SERIAL;
public MainWindow()
{
InitializeComponent();
controller();
}
public void controller()
{
WMI_AC = new Aircraft_Database(); //My structure that I want to parse and populate with serial data
SERIAL = new Serial_In();
SERIAL.GPS_Init();
}
}
}
Any help or suggestions would be greatly appreciated!
Much thanks,
Kane

New Topic/Question
Reply




MultiQuote






|