chat.h File Reference

Go to the source code of this file.

Data Structures

struct  NUTCHAT

Defines

#define CHAT_ARG_SEND   0
#define CHAT_ARG_ABORT   1
#define CHAT_ARG_TIMEOUT   2
#define CHAT_ARG_REPORT   3
#define CHAT_MAX_ABORTS   10
 Maximum number of abort strings.
#define CHAT_MAX_REPORT_SIZE   32
 Maximum size of report strings.
#define CHAT_DEFAULT_TIMEOUT   45
 Default timeout.

Functions

void NutTraceChat (FILE *stream, u_char 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.
NUTCHATNutChatCreate (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

u_charchat_report


Define Documentation

#define CHAT_ARG_SEND   0

Definition at line 75 of file chat.h.

Referenced by NutChatSend().

#define CHAT_ARG_ABORT   1

Definition at line 76 of file chat.h.

Referenced by NutChatExpect(), and NutChatSend().

#define CHAT_ARG_TIMEOUT   2

Definition at line 77 of file chat.h.

Referenced by NutChatExpect(), and NutChatSend().

#define CHAT_ARG_REPORT   3

Definition at line 78 of file chat.h.

Referenced by NutChatExpect(), and NutChatSend().

#define CHAT_MAX_ABORTS   10

Maximum number of abort strings.

Definition at line 84 of file chat.h.

Referenced by NutChatSend().

#define CHAT_MAX_REPORT_SIZE   32

Maximum size of report strings.

Definition at line 91 of file chat.h.

Referenced by NutChatSend().

#define CHAT_DEFAULT_TIMEOUT   45

Default timeout.

Definition at line 98 of file chat.h.

Referenced by NutChatSend().


Function Documentation

void NutTraceChat ( FILE stream,
u_char  flags 
)

Control chat tracing.

Parameters:
stream Pointer to a previously opened stream or null to disable trace output.
flags Flags to enable specific traces.

Definition at line 77 of file chat.c.

References fprintf_P, and prog_char.

int NutChatExpectString ( NUTCHAT ci,
char *  str 
)

Wait for a specific string to appear.

Parameters:
ci Pointer to a NUTCHAT structure, which must have been created by NutChatCreate().
str Expected string. May be empty if nothing is expected.
Returns:
0 on success, 3 in case of a timeout error while waiting for an expected string, or the index of an abort string plus 4, if one has been received.

Definition at line 119 of file chat.c.

References _read(), NUTCHAT::chat_abomat, NUTCHAT::chat_abort, NUTCHAT::chat_aborts, NUTCHAT::chat_fd, fprintf(), fprintf_P, fputc(), fputs_P, and prog_char.

Referenced by NutChatExpect().

int NutChatExpect ( NUTCHAT ci,
char *  str 
)

Definition at line 345 of file chat.c.

References NUTCHAT::chat_arg, CHAT_ARG_ABORT, CHAT_ARG_REPORT, CHAT_ARG_TIMEOUT, NUTCHAT::chat_fd, NUTCHAT::chat_repmat, NUTCHAT::chat_report_state, NutChatExpectString(), and strcmp().

int NutChatSend ( NUTCHAT ci,
char *  str 
)

Process a chat send argument.

Parameters:
ci Pointer to a NUTCHAT structure, which must have been created by NutChatCreate().
str String containing the chat send argument.
Returns:
0 on success, 1 in case of invalid parameters, 2 in case of an I/O error, 3 in case of a timeout error while waiting for an expected string, or the index of an abort string plus 4, if one has been received.

Definition at line 401 of file chat.c.

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.

Returns:
Pointer to a new NUTCHAT structure.

Definition at line 504 of file chat.c.

References NUTCHAT::chat_fd, malloc, and memset().

void NutChatDestroy ( NUTCHAT ci  ) 

Destroy a previously created NUTCHAT structure.

Parameters:
ci Pointer to a NUTCHAT structure, which must have been created by NutChatCreate().

Definition at line 521 of file chat.c.

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.

Parameters:
fd Descriptor of a previously opened device.
script Pointer to a string containing the chat script.
Returns:
0 on success, 1 in case of invalid parameters, 2 in case of an I/O error, 3 in case of a timeout error while waiting for an expected string, or the index of an abort string plus 4, if one has been received.
Examples:
pppc/pppc.c.

Definition at line 650 of file chat.c.

References free, malloc, strcpy(), and strlen().

Referenced by main().

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.

Returns:
0 on success, 1 in case of invalid parameters, 2 in case of an I/O error, 3 in case of a timeout error while waiting for an expected string, or the index of an abort string plus 4, if one has been received.

Definition at line 678 of file chat.c.

References free, malloc, strcpy_P, and strlen_P.


Variable Documentation

u_char* chat_report

Definition at line 63 of file chat.c.

Referenced by NutChatSend().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/