The present invention provides for a virtual serial port (VSP) situated
between a serial port in a mobile electronic device, applications that
require a serial port connection handle, and other applications that
require command-mode access to the serial port. Data-communication
applications (e.g. web browsing, e-mail, etc.) connect to the serial port
through the VSP. The VSP creates a virtual connection handle that is
returned to the application. Command-mode requests (e.g., short messaging
requests) are received by the hardware abstraction layer, translated into
command-mode messages (e.g., AT commands) and placed in a queue. The VSP
multiplexes the serial port between the currently-open data communication
session (data-mode) and command-mode messages by periodically suspending
the currently-open connection and processing one or more command-mode
messages that are in the queue. A buffer continually stores incoming data
while the data communication session is suspended. The VSP uses a
heuristic calculation to determine the maximum time interval for which the
data-communication session can be interrupted. The heuristic calculation
takes a percentage of a time-quantum (e.g. 0.5 seconds) based upon the
ratio of an average bit rate for air communication (e.g. 7000 bits/sec)
and a bit rate for the serial port (e.g. 152,000 bits/sec). This ensures
that data-communications are not interrupted for a time interval long
enough to result in lost data-packets. The parameter for the time quantum
and other parameters may be statically or dynamically adjusted to account
for a finite buffer size in the hardware.