I am trying to read sms by my own code. But my code is not working....
What is happened when a send the read sms command to GSM module it will send data
But my serialEvent never get any data...so it will not break the while loop.
Anyone have any idea what is going on why this is happened or what I am doing wrong .
But my serialEvent never get any data...so it will not break the while loop.
SerialEvent is a big GotYa !!!!, it doesn't get called on an interrupt at all
Its a hang over from Processing where the Arduino IDE was derived from.
If you look in the core code which calls setup() and then repeadly calls loop()
all that happens is that after loop() exits, a call to SerialEvent is made if there is serial data
So basically its pointless. and you should use serial.available in your loop()
SerialEvent is a big GotYa !!!!, it doesn't get called on an interrupt at all
That mean it's not serial interrupt at all? for that i have to set manually ?
I have another code which using two serials to operate GSM Modem manually it's working fine. that's why I suppose it's an serial interrupt.
is it possible SerialEvent is not Serial interrupt? or may be I did not define properly? apart from that it should be work.
The call to serialEvent() does not happen because of interrupts. It happens because loop() ended AND there was serial data to be dealt with.
The fact that there is serial data to be dealt with happens because of interrupts.
There is no real advantage in using serialEvent(). You could just as easily have
if(Serial.available() > 0)
dealWithSerialData();
at the start, or end, of loop(), and deal with the serial data in dealWithSerialData().
Obviously, you'd need another test, and another function to deal with Serial1 data.
The advantage of dealing with serial data yourself, with your own functions is that you can handle software serial data in exactly the same way. That may not matter to you, now, but consistency is good. It makes coding much simpler to write and understand.