Скрипт для устройства
#include <sys/modem.h>struct modem_script {char curstate; /* This state */char curflags; /* Set to zero */char newstate; /* State to goto on a match (0 means done) */char newflags; /* Flags to use for nextstate */char newtimeout; /* Timeout to use for nextstate */char newquiet; /* Quiet time to use for nextstate */short retvalue; /* Return value on match with nextstate 0 */char *pattern; /* Input matching pattern */char *response; /* Output response to a pattern match in input */char *progress; /* A progress message passed to the io callback on state change */};
Тип позволяет производить разметку скриптов для устройства. Структура включает следующие поля:
MODEM_NOECHO
set, the response is given to the callback function passed as the io parameter. Here's an example that demonstrates the operation of the script:
/** curstate curflags newstate newflags newtimeout newquiet retvalue pattern response*/struct modem_script table[] = {{1, 0, 1, 0, 2, 5, 0, NULL, "ATZ\\r\\P0a"},{1, 0, 2, 0, 30, 5, 0, "*ok*", "ATDT5910934"},{2, MODEM_BAUD, 3, MODEM_LASTLINE, 10, 5, 0, "*connect*", NULL},{3, 0, 4, 0, 8, 5, 0, "*login:*", "guest"},{4, MODEM_NOECHO, 5, 0, 15, 5, 0, "*password:*", "xxxx"},{5, 0, 0, 0, 0, 0, 0, "*$ *", NULL},{0, 0, 0, 0, 0, 0, 1, "*no carrier*", NULL},{0, 0, 0, 0, 0, 0, 2, "*no answer*", NULL},{0, 0, 0, 0, 0, 0, 3, "*no dialtone*", NULL},{0, 0, 0, 0, 0, 0, 4, "*busy*", NULL},{ NULL }};
ЗОСРВ «Нейтрино»
fnmatch(), modem_read(), modem_script()
Предыдущий раздел: Описание API системной библиотеки