The modem_run function is the main thread that performs the
command sending actions needed to dial, listen, or disconnect from
the remote modem (when TCPnet and the local modem are in command
mode). The modem_run function also performs the timeout delays
that are necessary when waiting for a response from the local modem
and when sending successive commands.
The modem_run function for the null modem is in the
RL-TCPnet library. The prototype is defined in net_config.h. If you
want to use a standard modem connection, you must copy std_modem.c
into your project directory.
note
The TCPnet system calls modem_run on every system timer
tick interrupt, which occurs at 100 ms intervals by default.
Because of this regular interval, the modem_run function can
implement delays using a simple counter.
The modem driver functions must not use waiting loops because
loops block the TCPnet system. Hence, calling the modem_run
function every timer tick interval is ideal.
The functions modem_dial, modem_listen, and
modem_hangup only initiate the command sending process with
the modem. The modem_run function then continues the process
until completion.
void modem_run (void) {
/* This is a main thread for MODEM Control module. It is called on every */
/* system timer timer tick to implement delays easy. By default this is */
/* every 100ms. The 'sytem tick' timeout is set in 'Net_Config.c' */
if (delay) {
if (--delay) {
return;
}
}
switch (modem_st) {
case MODEM_IDLE:
case MODEM_ERROR:
/* Modem idle or in error */
break;
case MODEM_ONLINE:
/* Modem is online - connected */
break;
case MODEM_DIAL:
/* Dial target number */
proc_dial ();
break;
case MODEM_LISTEN:
/* Activate answering mode */
proc_listen ();
break;
case MODEM_HANGUP:
/* Hangup and reset the modem */
proc_hangup ();
break;
}
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.