#include <net_config.h>
BOOL modem_process (
U8 ch ); /* New character sent by the modem. */
Description
The modem_process function processes characters that the
local modem sends to the TCPnet system. The function stores each
character in a buffer and checks the buffer for a valid modem
response. The argument ch is the new character that is
available from the modem.
The modem_process 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
TCPnet calls modem_process when a new character is
available from the local modem when TCPnet is in modem command
mode.
TCPnet is in modem command mode when it is in the process of
instructing the local modem to dial, listen, or disconnect (hangup)
from the remote modem.
The modem driver functions must not use waiting loops because
loops block the TCPnet system.
Return Value
The modem_process function returns __TRUE when it receives
the response "CONNECT" from the local modem. This means that the
local modem has connected to the remote modem. Otherwise, it returns
__FALSE.
BOOL modem_process (U8 ch) {
/* Modem character process event handler. This function is called when */
/* a new character has been received from the modem in command mode */
if (modem_st == MODEM_IDLE) {
mlen = 0;
return (__FALSE);
}
if (mlen < sizeof(mbuf)) {
mbuf[mlen++] = ch;
}
/* Modem driver is processing a command */
if (wait_for) {
/* 'modem_run()' is waiting for modem reply */
if (str_scomp (mbuf,reply) == __TRUE) {
wait_for = 0;
delay = 0;
if (wait_conn) {
/* OK, we are online here. */
wait_conn = 0;
modem_st = MODEM_ONLINE;
/* Inform the parent process we are online now. */
return (__TRUE);
}
}
}
/* Watch the modem disconnect because we do not use CD line */
if (mem_comp (mbuf,"NO CARRIER",10) == __TRUE) {
set_mode ();
}
if (ch == '\r' || ch == '\n') {
flush_buf ();
}
/* Modem not connected, return FALSE */
return (__FALSE);
}
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.