locked
Threading and Multiple SerialPorts. RRS feed

  • Question

  • I have a program that will program up to 256 devices over SerialPorts. (max in most Windows OS)
    I would probably stick to 5 at a time.

    I am going to multi-thread the program to do this and handle the reply from the external devices.
    So for ## devices, do I need to declare ## SerialPort classes???

    for example,
                string [ ] myString = SerialPort.GetPortNames(); 
                SerialPort [ ] mySerialPortArray = new SerialPort [ myString.Length ]; 
     
                Array.Sort( myString ); 
     
                for(int i = myString.Length - 1; i == 0; i++) 
                { 
                    mySerialPortArray [ i ].BaudRate = 115200; 
                    mySerialPortArray [ i ].DtrEnable = true
                    mySerialPortArray [ i ].Parity = Parity.None; 
                    mySerialPortArray [ i ].StopBits = StopBits.One; 
                    mySerialPortArray [ i ].DataBits = 8; 
                    mySerialPortArray [ i ].PortName = myString [ i ]; 
                } 
     

    • Moved by jack 321 Thursday, September 18, 2008 5:46 AM serial port issue (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Monday, September 15, 2008 3:44 PM

Answers