Wait for serial port command and process other jobs together

Hi,

I am working on GM862 GPS. I want my device to wait for serial port command forever and when any command is sent then it should response/ change accordingly. But at the same time other jobs (like collecting data, sending data to the server, receiving sms etc) should be processed.

How can I do that? Any suggestion?

Thanks in advance.