Background: We are developing an application (or Windows service) that will listen for communication from various devices connected to virtual serial ports. The information of each device will be captured manually, so I know that the device will be on 1Com 5, the device is 2Com 6, etc. Any time a device transmits data, I have to capture it and write it elsewhere (originally in the log file).
With this in mind, is it possible to monitor more than one serial port on a thread, or I should create a new bag for each port (keep in mind that I know which Ports are monitored)
Or do you guys think that's a good way?
The prototype code I'm working on looks like this (only reads a port):
class program {public static zero main () {SerialPort mySerialPort = New SerialPort ("COM5"); MySerialPort.BaudRate = 9600; MySerialPort.Parity = Equality One; MySerialPort.StopBits = StopBits.One; MySerialPort.DataBits = 8; Messierport Airport Handshake = Handshake.No; MySerialPort.DataReceived + = New SerialDataReceivedEventHandler (DataReceivedHandler); MySerialPort.Open (); Console.light line ("press any key to continue ..."); Console.WriteLine (); Console.ReadKey (); MySerialPort.Close (); } Private static blank Deseecewandler (Object Sender, Serial Data RecivilEventErgus E) {Serialport SP = (Serial Port) Sender; String indenta = sp.ReadExisting (); Console.WriteLine (indata); Debug Print ("Received Data:"); Debug.Print (indata); }}
I am basically thinking that I should create a class for each port code in the console application, or if I should go to old school and write a huge procedural app Which once monitors them all.