tom_modem: improved stability
This commit is contained in:
parent
e4f867a6d2
commit
9b09e14a23
@ -3,7 +3,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
|||||||
|
|
||||||
PKG_NAME:= tom_modem
|
PKG_NAME:= tom_modem
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.1
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
#define SMS_BUF_SIZE 65536
|
#define SMS_BUF_SIZE 65536
|
||||||
#define LINE_BUF 1024
|
#define LINE_BUF 1024
|
||||||
#define SMS_LIST_SIZE 128
|
#define SMS_LIST_SIZE 128
|
||||||
#define COMMON_BUF_SIZE 16384
|
#define COMMON_BUF_SIZE 65536
|
||||||
#define PHONE_NUMBER_SIZE 64
|
#define PHONE_NUMBER_SIZE 64
|
||||||
#define SMS_TEXT_SIZE 256
|
#define SMS_TEXT_SIZE 256
|
||||||
#define SMS_PDU_STR_SIZE 512
|
#define SMS_PDU_STR_SIZE 512
|
||||||
@ -108,6 +108,11 @@ typedef struct _SMS {
|
|||||||
char *sms_pdu;
|
char *sms_pdu;
|
||||||
} SMS_T;
|
} SMS_T;
|
||||||
|
|
||||||
|
typedef struct _AT_MESSAGE {
|
||||||
|
char *message;
|
||||||
|
int len;
|
||||||
|
} AT_MESSAGE_T;
|
||||||
|
|
||||||
enum ERROR_CODES {
|
enum ERROR_CODES {
|
||||||
COMM_ERROR = -1,
|
COMM_ERROR = -1,
|
||||||
SUCCESS = 0,
|
SUCCESS = 0,
|
||||||
@ -116,6 +121,7 @@ enum ERROR_CODES {
|
|||||||
INVALID_PARAM,
|
INVALID_PARAM,
|
||||||
INVALID_HEX,
|
INVALID_HEX,
|
||||||
UNKNOWN_ERROR,
|
UNKNOWN_ERROR,
|
||||||
|
BUFFER_OVERFLOW,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SMS_CHARSET {
|
enum SMS_CHARSET {
|
||||||
|
@ -91,6 +91,15 @@ int tty_open_device(PROFILE_T *profile,FDS_T *fds)
|
|||||||
err_msg("Error setting tty device");
|
err_msg("Error setting tty device");
|
||||||
return COMM_ERROR;
|
return COMM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fds->tty_fd = open(profile->tty_dev, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||||
|
fds->fdi = fdopen(fds->tty_fd, "r");
|
||||||
|
if (setvbuf(fds->fdi , NULL, _IOFBF, 0))
|
||||||
|
{
|
||||||
|
err_msg("Error setting buffer for fdi");
|
||||||
|
return COMM_ERROR;
|
||||||
|
}
|
||||||
|
usleep(10000);
|
||||||
tcflush(fds->tty_fd, TCIOFLUSH);
|
tcflush(fds->tty_fd, TCIOFLUSH);
|
||||||
if (fds->tty_fd >= 0)
|
if (fds->tty_fd >= 0)
|
||||||
close(fds->tty_fd);
|
close(fds->tty_fd);
|
||||||
@ -138,6 +147,12 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_
|
|||||||
{
|
{
|
||||||
read_flag = 1;
|
read_flag = 1;
|
||||||
dbg_msg("%s", tmp);
|
dbg_msg("%s", tmp);
|
||||||
|
if (msg_len + strlen(tmp) >= len)
|
||||||
|
{
|
||||||
|
err_msg("Error: output buffer is too small");
|
||||||
|
exitcode = BUFFER_OVERFLOW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp);
|
msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp);
|
||||||
|
|
||||||
@ -177,7 +192,7 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
usleep(10000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
if (read_flag == 0)
|
if (read_flag == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user