private void port_DataReceive(object sender, SerialDataReceivedEventArgs e)
{
string data;
data = ComPort.ReadExisting();
if (numbers < numbers_selected+1)
{// numbers - the number of numbers received from the serial port
//numbers_selected - number of numbers that I need to received
if (digits <= 3)
{//the numbers are comming in digits,only one digit at a time, so digits - number of digits from the current number the I receive from the serial port
digits_number = string.Concat(data);
digits++;
//digits_number - is the final number, that i will add to the arraylist
}
else
{
MyArrayList.Add(digits_number);
digits = 0;
numbers++;
}
}
}
So, I have an ArrayList(MyArrayList) that save 6 positions, first the number of numbers that need treceived from the serial port and is taken from a comand button, and the 5 numbers(that is the maximum number of numbers that I can take from the serial port). But now, the port is working @ 9600 and I don't know exaclty if this algorithm is enough fast...
That's my algorithm but I don't think that is the right one, but if someone has another idea,I can change mine.

New Topic/Question
Reply




MultiQuote





|