sms_tool: add option to set timeout for at
This commit is contained in:
parent
d7d36b2678
commit
8fbf63e329
60
application/sms-tool_q/patches/0002-add_timeout_option.patch
Normal file
60
application/sms-tool_q/patches/0002-add_timeout_option.patch
Normal file
@ -0,0 +1,60 @@
|
||||
--- a/sms_main.c 2024-10-08 23:11:01.169908895 +0800
|
||||
+++ b/sms_main.c 2024-10-08 23:10:52.929909691 +0800
|
||||
@@ -46,7 +46,8 @@
|
||||
static const char* dev = "/dev/ttyUSB0";
|
||||
static const char* storage = "";
|
||||
static const char* dateformat = "%D %T";
|
||||
-
|
||||
+FILE* pf;
|
||||
+FILE* pfi;
|
||||
static void setserial(int baudrate)
|
||||
{
|
||||
struct termios t;
|
||||
@@ -115,7 +116,9 @@
|
||||
static void timeout()
|
||||
{
|
||||
fprintf(stderr,"No response from modem.\n");
|
||||
- exit(2);
|
||||
+ if (pf) fclose(pf);
|
||||
+ if (pfi) fclose(pfi);
|
||||
+ exit(2);
|
||||
}
|
||||
|
||||
static int starts_with(const char* prefix, const char* str)
|
||||
@@ -168,12 +171,14 @@
|
||||
int rawoutput = 0;
|
||||
int jsonoutput = 0;
|
||||
int debug = 0;
|
||||
+ int user_set_timeout = 5;
|
||||
int dcs = -1;
|
||||
|
||||
- while ((ch = getopt(argc, argv, "b:c:d:Ds:f:jRr")) != -1){
|
||||
+ while ((ch = getopt(argc, argv, "b:c:t:d:Ds:f:jRr")) != -1){
|
||||
switch (ch) {
|
||||
case 'b': baudrate = atoi(optarg); break;
|
||||
case 'c': dcs = atoi(optarg); break;
|
||||
+ case 't': user_set_timeout = atoi(optarg);break;
|
||||
case 'd': dev = optarg; break;
|
||||
case 'D': debug = 1; break;
|
||||
case 's': storage = optarg; break;
|
||||
@@ -237,8 +242,8 @@
|
||||
if (port < 0)
|
||||
fprintf(stderr,"reopen(%s)\n", dev);
|
||||
|
||||
- FILE* pf = fdopen(port, "w");
|
||||
- FILE* pfi = fdopen(port, "r");
|
||||
+ pf = fdopen(port, "w");
|
||||
+ pfi = fdopen(port, "r");
|
||||
if (!pf || ! pfi)
|
||||
fprintf(stderr,"open port failed\n");
|
||||
if(setvbuf(pf, NULL, _IOLBF, 0))
|
||||
@@ -758,7 +763,8 @@
|
||||
|
||||
if (!strcmp("at", argv[0]))
|
||||
{
|
||||
- alarm(5);
|
||||
+
|
||||
+ alarm(user_set_timeout);
|
||||
fputs(argv[1], pf);
|
||||
fputs("\r\n", pf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user