I'm trying to read data from the serial port. Problem is, that i always have to query the port for new data, and in 99.9% of acses my query doesn't return the result cause of the fact it's done when the modems is seding the answers.
I've tried using a timer, but still i get errors. Same while using DTR enable/false. How i can safely send the query without getting over the momdem response ?
I'm using DataRecived event, to read the com.
Expand|Select|Wrap|Line Numbers
- private void portserial_DataReceived(object sender, SerialDataReceivedEventArgs e)
- {
- while (portserial.BytesToRead > 0)
- {
- data += Convert.ToChar(portserial.ReadByte());
- }
- }
Expand|Select|Wrap|Line Numbers
- function name....
- {
- string temp;
- string sms; int j; int k; int indx = 0;
- string[] sirNr = new string[250];
- lRuleaza = true;
- try
- {
- //MessageBox.Show(portserial.DtrEnable.ToString());
- portserial.Write("at+cmgl=\"ALL\"\r"); //the command i try to send without affecting the reading.
- ....parse the info read....
- }