Skip to content

Commit 9b09e14

Browse files
committed
tom_modem: improved stability
1 parent e4f867a commit 9b09e14

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

application/tom_modem/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(INCLUDE_DIR)/kernel.mk
33

44
PKG_NAME:= tom_modem
55
PKG_RELEASE:=1
6-
PKG_VERSION:=1.0.0
6+
PKG_VERSION:=1.0.1
77

88
include $(INCLUDE_DIR)/package.mk
99

application/tom_modem/src/modem_types.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#define SMS_BUF_SIZE 65536
5656
#define LINE_BUF 1024
5757
#define SMS_LIST_SIZE 128
58-
#define COMMON_BUF_SIZE 16384
58+
#define COMMON_BUF_SIZE 65536
5959
#define PHONE_NUMBER_SIZE 64
6060
#define SMS_TEXT_SIZE 256
6161
#define SMS_PDU_STR_SIZE 512
@@ -108,6 +108,11 @@ typedef struct _SMS {
108108
char *sms_pdu;
109109
} SMS_T;
110110

111+
typedef struct _AT_MESSAGE {
112+
char *message;
113+
int len;
114+
} AT_MESSAGE_T;
115+
111116
enum ERROR_CODES {
112117
COMM_ERROR = -1,
113118
SUCCESS = 0,
@@ -116,6 +121,7 @@ enum ERROR_CODES {
116121
INVALID_PARAM,
117122
INVALID_HEX,
118123
UNKNOWN_ERROR,
124+
BUFFER_OVERFLOW,
119125
};
120126

121127
enum SMS_CHARSET {

application/tom_modem/src/ttydevice.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ int tty_open_device(PROFILE_T *profile,FDS_T *fds)
9191
err_msg("Error setting tty device");
9292
return COMM_ERROR;
9393
}
94+
95+
fds->tty_fd = open(profile->tty_dev, O_RDWR | O_NOCTTY | O_NONBLOCK);
96+
fds->fdi = fdopen(fds->tty_fd, "r");
97+
if (setvbuf(fds->fdi , NULL, _IOFBF, 0))
98+
{
99+
err_msg("Error setting buffer for fdi");
100+
return COMM_ERROR;
101+
}
102+
usleep(10000);
94103
tcflush(fds->tty_fd, TCIOFLUSH);
95104
if (fds->tty_fd >= 0)
96105
close(fds->tty_fd);
@@ -138,6 +147,12 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_
138147
{
139148
read_flag = 1;
140149
dbg_msg("%s", tmp);
150+
if (msg_len + strlen(tmp) >= len)
151+
{
152+
err_msg("Error: output buffer is too small");
153+
exitcode = BUFFER_OVERFLOW;
154+
break;
155+
}
141156
if (output != NULL)
142157
msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp);
143158

@@ -177,7 +192,7 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_
177192
}
178193
}
179194
#endif
180-
usleep(10000);
195+
usleep(5000);
181196
}
182197
if (read_flag == 0)
183198
{

0 commit comments

Comments
 (0)