Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
94ca0be2
提交
94ca0be2
authored
4月 02, 2012
作者:
Giovanni Maruzzelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gsmopen: continue AT control with tcblib, basic calls ok
上级
3c27c1f8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
43 行增加
和
25 行删除
+43
-25
gsmopen_protocol.cpp
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
+43
-25
没有找到文件。
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
浏览文件 @
94ca0be2
...
...
@@ -546,7 +546,7 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u
{
int
select_err
=
1
;
int
res
;
fd_set
read_fds
;
//
fd_set read_fds;
struct
timeval
timeout
;
char
tmp_answer
[
AT_BUFSIZ
];
char
tmp_answer2
[
AT_BUFSIZ
];
...
...
@@ -557,13 +557,19 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u
int
la_counter
=
0
;
int
at_ack
=
-
1
;
int
la_read
=
0
;
int
timeout1
;
timeout1
=
(
timeout_sec
*
1000
)
+
(
timeout_usec
?
(
timeout_usec
/
1000
)
:
0
);
if
(
timeout1
!=
100
)
ERRORA
(
"TIMEOUT=%d
\n
"
,
GSMOPEN_P_LOG
,
timeout1
);
if
(
!
running
||
!
tech_pvt
->
running
){
return
-
1
;
}
FD_ZERO
(
&
read_fds
);
FD_SET
(
tech_pvt
->
controldevfd
,
&
read_fds
);
////
FD_ZERO(&read_fds);
//
FD_SET(tech_pvt->controldevfd, &read_fds);
//NOTICA (" INSIDE this gsmopen_serial_device %s \n", GSMOPEN_P_LOG, tech_pvt->controldevice_name);
tmp_answer_ptr
=
tmp_answer
;
...
...
@@ -574,18 +580,20 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u
PUSHA_UNLOCKA
(
tech_pvt
->
controldev_lock
);
LOKKA
(
tech_pvt
->
controldev_lock
);
while
((
!
tech_pvt
->
controldev_dead
)
&&
((
select_err
=
select
(
tech_pvt
->
controldevfd
+
1
,
&
read_fds
,
NULL
,
NULL
,
&
timeout
))
>
0
))
{
//while ((!tech_pvt->controldev_dead) && ((select_err = select(tech_pvt->controldevfd + 1, &read_fds, NULL, NULL, &timeout)) > 0)) {
while
(
(
!
tech_pvt
->
controldev_dead
)
&&
(
read_count
=
tech_pvt
->
serialPort_serial_control
->
Readv
(
tmp_answer_ptr
,
AT_BUFSIZ
-
(
tmp_answer_ptr
-
tmp_answer
),
(
timeout_sec
*
1000
)
+
(
timeout_usec
?
(
timeout_usec
/
1000
)
:
0
)
)
>
0
)
)
{
char
*
token_ptr
;
timeout
.
tv_sec
=
timeout_sec
;
//reset the timeout, linux modify it
timeout
.
tv_usec
=
timeout_usec
;
//reset the timeout, linux modify it
read_count
=
read
(
tech_pvt
->
controldevfd
,
tmp_answer_ptr
,
AT_BUFSIZ
-
(
tmp_answer_ptr
-
tmp_answer
));
//cicopet read_count = read(tech_pvt->controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
//cicopet read_count = tech_pvt->serialPort_serial_control->Readv(tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer), (timeout_sec * 1000) + (timeout_usec ? (timeout_usec / 1000) : 0 ) );
if
(
read_count
==
0
)
{
ERRORA
(
"read 0 bytes!!! Nenormalno! Marking this gsmopen_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
controldevice_name
);
tech_pvt
->
controldev_dead
=
1
;
close
(
tech_pvt
->
controldevfd
);
//cicopet
close(tech_pvt->controldevfd);
ERRORA
(
"gsmopen_serial_monitor failed, declaring %s dead
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
controldevice_name
);
tech_pvt
->
running
=
0
;
alarm_event
(
tech_pvt
,
ALARM_FAILED_INTERFACE
,
"gsmopen_serial_monitor failed, declaring interface dead"
);
...
...
@@ -1725,7 +1733,7 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u
if
(
select_err
==
-
1
)
{
ERRORA
(
"select returned -1 on %s, setting controldev_dead, error was: %s
\n
"
,
GSMOPEN_P_LOG
,
tech_pvt
->
controldevice_name
,
strerror
(
errno
));
tech_pvt
->
controldev_dead
=
1
;
close
(
tech_pvt
->
controldevfd
);
//cicopet
close(tech_pvt->controldevfd);
tech_pvt
->
running
=
0
;
alarm_event
(
tech_pvt
,
ALARM_FAILED_INTERFACE
,
"select returned -1 on interface, setting controldev_dead"
);
...
...
@@ -1796,48 +1804,54 @@ int gsmopen_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_u
return
0
;
}
//cicopet int gsmopen_serial_write_AT(private_t * tech_pvt, const char *data)
int
gsmopen_serial_write_AT
(
private_t
*
tech_pvt
,
const
char
*
data
)
{
int
howmany
;
int
i
;
int
res
;
int
count
;
char
*
Data
=
(
char
*
)
data
;
howmany
=
strlen
(
d
ata
);
howmany
=
strlen
(
D
ata
);
for
(
i
=
0
;
i
<
howmany
;
i
++
)
{
res
=
write
(
tech_pvt
->
controldevfd
,
&
data
[
i
],
1
);
//cicopetres = write(tech_pvt->controldevfd, &data[i], 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
(
&
Data
[
i
],
1
);
if
(
res
!=
1
)
{
DEBUGA_GSMOPEN
(
"Error sending (%.1s): %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
res
,
strerror
(
errno
));
DEBUGA_GSMOPEN
(
"Error sending (%.1s): %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
res
,
strerror
(
errno
));
gsmopen_sleep
(
100000
);
for
(
count
=
0
;
count
<
10
;
count
++
)
{
res
=
write
(
tech_pvt
->
controldevfd
,
&
data
[
i
],
1
);
//cicopet res = write(tech_pvt->controldevfd, &data[i], 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
(
&
Data
[
i
],
1
);
if
(
res
==
1
)
{
DEBUGA_GSMOPEN
(
"Successfully RE-sent (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
count
,
res
,
strerror
(
errno
));
DEBUGA_GSMOPEN
(
"Successfully RE-sent (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
count
,
res
,
strerror
(
errno
));
break
;
}
else
DEBUGA_GSMOPEN
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
count
,
res
,
strerror
(
errno
));
DEBUGA_GSMOPEN
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
count
,
res
,
strerror
(
errno
));
gsmopen_sleep
(
100000
);
}
if
(
res
!=
1
)
{
ERRORA
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
count
,
res
,
strerror
(
errno
));
ERRORA
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
count
,
res
,
strerror
(
errno
));
return
-
1
;
}
}
if
(
option_debug
>
1
)
DEBUGA_GSMOPEN
(
"sent data... (%.1s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
]);
DEBUGA_GSMOPEN
(
"sent data... (%.1s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
]);
gsmopen_sleep
(
1000
);
/* release the cpu */
}
res
=
write
(
tech_pvt
->
controldevfd
,
"
\r
"
,
1
);
//cicopet res = write(tech_pvt->controldevfd, "\r", 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
((
char
*
)
"
\r
"
,
1
);
if
(
res
!=
1
)
{
DEBUGA_GSMOPEN
(
"Error sending (carriage return): %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
res
,
strerror
(
errno
));
gsmopen_sleep
(
100000
);
for
(
count
=
0
;
count
<
10
;
count
++
)
{
res
=
write
(
tech_pvt
->
controldevfd
,
"
\r
"
,
1
);
//cicopet res = write(tech_pvt->controldevfd, "\r", 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
((
char
*
)
"
\r
"
,
1
);
if
(
res
==
1
)
{
DEBUGA_GSMOPEN
(
"Successfully RE-sent carriage return: %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
count
,
res
,
strerror
(
errno
));
...
...
@@ -1865,31 +1879,34 @@ int gsmopen_serial_write_AT_nocr(private_t * tech_pvt, const char *data)
int
i
;
int
res
;
int
count
;
char
*
Data
=
(
char
*
)
data
;
howmany
=
strlen
(
d
ata
);
howmany
=
strlen
(
D
ata
);
for
(
i
=
0
;
i
<
howmany
;
i
++
)
{
res
=
write
(
tech_pvt
->
controldevfd
,
&
data
[
i
],
1
);
//cicopet res = write(tech_pvt->controldevfd, &data[i], 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
(
&
Data
[
i
],
1
);
if
(
res
!=
1
)
{
DEBUGA_GSMOPEN
(
"Error sending (%.1s): %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
res
,
strerror
(
errno
));
DEBUGA_GSMOPEN
(
"Error sending (%.1s): %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
res
,
strerror
(
errno
));
gsmopen_sleep
(
100000
);
for
(
count
=
0
;
count
<
10
;
count
++
)
{
res
=
write
(
tech_pvt
->
controldevfd
,
&
data
[
i
],
1
);
//cicopet res = write(tech_pvt->controldevfd, &data[i], 1);
res
=
tech_pvt
->
serialPort_serial_control
->
Write
(
&
Data
[
i
],
1
);
if
(
res
==
1
)
break
;
else
DEBUGA_GSMOPEN
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
count
,
res
,
strerror
(
errno
));
DEBUGA_GSMOPEN
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
count
,
res
,
strerror
(
errno
));
gsmopen_sleep
(
100000
);
}
if
(
res
!=
1
)
{
ERRORA
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
],
count
,
res
,
strerror
(
errno
));
ERRORA
(
"Error RE-sending (%.1s): %d %d (%s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
],
count
,
res
,
strerror
(
errno
));
return
-
1
;
}
}
if
(
option_debug
>
1
)
DEBUGA_GSMOPEN
(
"sent data... (%.1s)
\n
"
,
GSMOPEN_P_LOG
,
&
d
ata
[
i
]);
DEBUGA_GSMOPEN
(
"sent data... (%.1s)
\n
"
,
GSMOPEN_P_LOG
,
&
D
ata
[
i
]);
gsmopen_sleep
(
1000
);
/* release the cpu */
}
...
...
@@ -1932,7 +1949,8 @@ int gsmopen_serial_write_AT_ack(private_t * tech_pvt, const char *data)
return
-
1
;
}
at_result
=
gsmopen_serial_read_AT
(
tech_pvt
,
1
,
500000
,
2
,
NULL
,
1
);
// 2.5 sec timeout
//cicopet at_result = gsmopen_serial_read_AT(tech_pvt, 1, 500000, 2, NULL, 1); // 2.5 sec timeout
at_result
=
gsmopen_serial_read_AT
(
tech_pvt
,
1
,
100000
,
0
,
NULL
,
1
);
// 1/10th sec timeout
UNLOCKA
(
tech_pvt
->
controldev_lock
);
POPPA_UNLOCKA
(
tech_pvt
->
controldev_lock
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论