#include <cfg/os.h>
#include <sys/timer.h>
#include <dev/uart.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <memdebug.h>
#include <dev/chat.h>
Functions | |
void | NutTraceChat (FILE *stream, uint8_t flags) |
Control chat tracing. | |
int | NutChatExpectString (NUTCHAT *ci, char *str) |
Wait for a specific string to appear. | |
int | NutChatExpect (NUTCHAT *ci, char *str) |
int | NutChatSend (NUTCHAT *ci, char *str) |
Process a chat send argument. | |
NUTCHAT * | NutChatCreate (int fd) |
Create a NUTCHAT structure. | |
void | NutChatDestroy (NUTCHAT *ci) |
Destroy a previously created NUTCHAT structure. | |
int | NutChat (int fd, const char *script) |
Execute a conversational exchange with a serial device. | |
int | NutChat_P (int fd, PGM_P script) |
Execute a conversational exchange with a serial device. | |
Variables | |
uint8_t * | chat_report |
int NutChatExpectString | ( | NUTCHAT * | ci, |
char * | str | ||
) |
Wait for a specific string to appear.
ci | Pointer to a NUTCHAT structure, which must have been created by NutChatCreate(). |
str | Expected string. May be empty if nothing is expected. |
References _read(), NUTCHAT::chat_abomat, NUTCHAT::chat_abort, NUTCHAT::chat_aborts, NUTCHAT::chat_fd, CHAT_MAX_REPORT_SIZE, NUTCHAT::chat_repmat, chat_report, NUTCHAT::chat_report_search, NUTCHAT::chat_report_state, fprintf(), fprintf_P, fputc(), fputs_P, and prog_char.
Referenced by NutChatExpect().
int NutChatExpect | ( | NUTCHAT * | ci, |
char * | str | ||
) |
References NUTCHAT::chat_arg, CHAT_ARG_ABORT, CHAT_ARG_REPORT, CHAT_ARG_TIMEOUT, NUTCHAT::chat_fd, NUTCHAT::chat_repmat, NUTCHAT::chat_report_state, NutChatExpectString(), rc, and strcmp().
int NutChatSend | ( | NUTCHAT * | ci, |
char * | str | ||
) |
Process a chat send argument.
ci | Pointer to a NUTCHAT structure, which must have been created by NutChatCreate(). |
str | String containing the chat send argument. |
References _ioctl(), atol(), NUTCHAT::chat_abort, NUTCHAT::chat_aborts, NUTCHAT::chat_arg, CHAT_ARG_ABORT, CHAT_ARG_REPORT, CHAT_ARG_SEND, CHAT_ARG_TIMEOUT, CHAT_DEFAULT_TIMEOUT, NUTCHAT::chat_fd, CHAT_MAX_ABORTS, CHAT_MAX_REPORT_SIZE, chat_report, NUTCHAT::chat_report_search, malloc(), strlen(), and UART_SETREADTIMEOUT.
NUTCHAT* NutChatCreate | ( | int | fd | ) |
Create a NUTCHAT structure.
References NUTCHAT::chat_fd, malloc(), and memset().
void NutChatDestroy | ( | NUTCHAT * | ci | ) |
Destroy a previously created NUTCHAT structure.
ci | Pointer to a NUTCHAT structure, which must have been created by NutChatCreate(). |
References NUTCHAT::chat_abort, NUTCHAT::chat_aborts, and free().
int NutChat | ( | int | fd, |
const char * | script | ||
) |
Execute a conversational exchange with a serial device.
Its primary purpose is to establish a modem connection.
fd | Descriptor of a previously opened device. |
script | Pointer to a string containing the chat script. |
References free(), NULL, rc, and strdup().
int NutChat_P | ( | int | fd, |
PGM_P | script | ||
) |
Execute a conversational exchange with a serial device.
Similar to NutChat() except that the chat string is located in program memory.
References free(), malloc(), rc, strcpy_P, and strlen_P.
Referenced by NutChatExpectString(), and NutChatSend().