Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
35d8aa44
提交
35d8aa44
authored
4月 06, 2012
作者:
Giovanni Maruzzelli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gsmopen: windows again, back to linux
上级
eaa37c3e
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
65 行增加
和
12 行删除
+65
-12
gsmopen.h
src/mod/endpoints/mod_gsmopen/gsmopen.h
+7
-4
gsmopen_protocol.cpp
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
+17
-2
mod_gsmopen.cpp
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
+41
-6
没有找到文件。
src/mod/endpoints/mod_gsmopen/gsmopen.h
浏览文件 @
35d8aa44
...
@@ -505,6 +505,9 @@ struct private_object {
...
@@ -505,6 +505,9 @@ struct private_object {
ctb
::
SerialPort
*
serialPort_serial_control
;
ctb
::
SerialPort
*
serialPort_serial_control
;
char
buffer2
[
320
];
int
buffer2_full
;
};
};
typedef
struct
private_object
private_t
;
typedef
struct
private_object
private_t
;
...
@@ -554,11 +557,11 @@ int gsmopen_socket_create_and_bind(private_t * tech_pvt, int *which_port);
...
@@ -554,11 +557,11 @@ int gsmopen_socket_create_and_bind(private_t * tech_pvt, int *which_port);
void
*
gsmopen_do_controldev_thread
(
void
*
data
);
void
*
gsmopen_do_controldev_thread
(
void
*
data
);
#ifdef WIN32
//
#ifdef WIN32
int
gsmopen_serial_init
(
private_t
*
tech_pvt
,
int
controldevice_speed
);
int
gsmopen_serial_init
(
private_t
*
tech_pvt
,
int
controldevice_speed
);
#else
//
#else
int
gsmopen_serial_init
(
private_t
*
tech_pvt
,
speed_t
controldevice_speed
);
//
int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed);
#endif //WIN32
//
#endif //WIN32
int
gsmopen_serial_monitor
(
private_t
*
tech_pvt
);
int
gsmopen_serial_monitor
(
private_t
*
tech_pvt
);
int
gsmopen_serial_sync
(
private_t
*
tech_pvt
);
int
gsmopen_serial_sync
(
private_t
*
tech_pvt
);
int
gsmopen_serial_sync_AT
(
private_t
*
tech_pvt
);
int
gsmopen_serial_sync_AT
(
private_t
*
tech_pvt
);
...
...
src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
浏览文件 @
35d8aa44
...
@@ -60,7 +60,8 @@ int gsmopen_serial_init(private_t * tech_pvt, int controldevice_speed)
...
@@ -60,7 +60,8 @@ int gsmopen_serial_init(private_t * tech_pvt, int controldevice_speed)
tech_pvt
->
serialPort_serial_control
=
new
ctb
::
SerialPort
();
tech_pvt
->
serialPort_serial_control
=
new
ctb
::
SerialPort
();
if
(
tech_pvt
->
serialPort_serial_control
->
Open
(
"COM9"
,
115200
,
"8N1"
,
ctb
::
SerialPort
::
NoFlowControl
)
>=
0
)
{
//if( tech_pvt->serialPort_serial_control->Open( "COM9", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
if
(
tech_pvt
->
serialPort_serial_control
->
Open
(
"/dev/ttyUSB3"
,
115200
,
"8N1"
,
ctb
::
SerialPort
::
NoFlowControl
)
>=
0
)
{
ERRORA
(
"port SUCCESS open
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"port SUCCESS open
\n
"
,
GSMOPEN_P_LOG
);
}
else
{
}
else
{
ERRORA
(
"port NOT open
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"port NOT open
\n
"
,
GSMOPEN_P_LOG
);
...
@@ -214,6 +215,16 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
...
@@ -214,6 +215,16 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
/* go until first empty preinit string, or last preinit string */
/* go until first empty preinit string, or last preinit string */
while
(
1
)
{
while
(
1
)
{
char
trash
[
4096
];
res
=
tech_pvt
->
serialPort_serial_control
->
Read
(
trash
,
4096
);
if
(
res
)
ERRORA
(
"READ %d on serialport init
\n
"
,
GSMOPEN_P_LOG
,
res
);
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT^CURC=0"
);
if
(
res
)
{
ERRORA
(
"no response to AT^CURC=0
\n
"
,
GSMOPEN_P_LOG
);
return
-
1
;
}
if
(
strlen
(
tech_pvt
->
at_preinit_1
))
{
if
(
strlen
(
tech_pvt
->
at_preinit_1
))
{
res
=
gsmopen_serial_write_AT_expect
(
tech_pvt
,
tech_pvt
->
at_preinit_1
,
tech_pvt
->
at_preinit_1_expect
);
res
=
gsmopen_serial_write_AT_expect
(
tech_pvt
,
tech_pvt
->
at_preinit_1
,
tech_pvt
->
at_preinit_1_expect
);
if
(
res
)
{
if
(
res
)
{
...
@@ -274,6 +285,9 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
...
@@ -274,6 +285,9 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
ERRORA
(
"no response to AT
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"no response to AT
\n
"
,
GSMOPEN_P_LOG
);
return
-
1
;
return
-
1
;
}
}
/* for motorola, bring it back to "normal" mode if it happens to be in another mode */
/* for motorola, bring it back to "normal" mode if it happens to be in another mode */
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+mode=0"
);
res
=
gsmopen_serial_write_AT_ack
(
tech_pvt
,
"AT+mode=0"
);
if
(
res
)
{
if
(
res
)
{
...
@@ -3578,7 +3592,8 @@ int gsmopen_serial_init_audio_port(private_t * tech_pvt, int controldevice_audio
...
@@ -3578,7 +3592,8 @@ int gsmopen_serial_init_audio_port(private_t * tech_pvt, int controldevice_audio
{
{
tech_pvt
->
serialPort_serial_audio
=
new
ctb
::
SerialPort
();
tech_pvt
->
serialPort_serial_audio
=
new
ctb
::
SerialPort
();
if
(
tech_pvt
->
serialPort_serial_audio
->
Open
(
"COM8"
,
115200
,
"8N1"
,
ctb
::
SerialPort
::
NoFlowControl
)
>=
0
)
{
//if( tech_pvt->serialPort_serial_audio->Open( "COM8", 115200, "8N1", ctb::SerialPort::NoFlowControl ) >= 0 ) {
if
(
tech_pvt
->
serialPort_serial_audio
->
Open
(
"/dev/ttyUSB2"
,
115200
,
"8N1"
,
ctb
::
SerialPort
::
NoFlowControl
)
>=
0
)
{
ERRORA
(
"port SUCCESS open
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"port SUCCESS open
\n
"
,
GSMOPEN_P_LOG
);
}
else
{
}
else
{
ERRORA
(
"port NOT open
\n
"
,
GSMOPEN_P_LOG
);
ERRORA
(
"port NOT open
\n
"
,
GSMOPEN_P_LOG
);
...
...
src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp
浏览文件 @
35d8aa44
...
@@ -810,7 +810,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
...
@@ -810,7 +810,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
int
samples
;
int
samples
;
int
samples2
;
int
samples2
;
char
digit_str
[
256
];
char
digit_str
[
256
];
short
buffer2
[
640
];
char
buffer2
[
640
];
channel
=
switch_core_session_get_channel
(
session
);
channel
=
switch_core_session_get_channel
(
session
);
...
@@ -842,9 +842,23 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
...
@@ -842,9 +842,23 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
if
((
samples
=
alsa_read
(
tech_pvt
,
(
short
*
)
tech_pvt
->
read_frame
.
data
,
tech_pvt
->
read_codec
.
implementation
->
samples_per_packet
))
>
0
)
if
((
samples
=
alsa_read
(
tech_pvt
,
(
short
*
)
tech_pvt
->
read_frame
.
data
,
tech_pvt
->
read_codec
.
implementation
->
samples_per_packet
))
>
0
)
#endif// GSMOPEN_ALSA
#endif// GSMOPEN_ALSA
if
((
samples
=
tech_pvt
->
serialPort_serial_audio
->
Read
((
char
*
)
tech_pvt
->
read_frame
.
data
,
320
))
>
0
)
// if ((samples = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0)
if
((
samples
=
tech_pvt
->
serialPort_serial_audio
->
Read
(
buffer2
,
640
))
>=
320
)
{
{
tech_pvt
->
buffer2_full
=
0
;
if
(
samples
>=
640
){
DEBUGA_GSMOPEN
(
"samples=%d
\n
"
,
GSMOPEN_P_LOG
,
samples
);
memcpy
(
tech_pvt
->
buffer2
,
buffer2
+
320
,
320
);
tech_pvt
->
buffer2_full
=
1
;
}
samples
=
320
;
memcpy
(
tech_pvt
->
read_frame
.
data
,
buffer2
,
320
);
tech_pvt
->
read_frame
.
datalen
=
samples
;
tech_pvt
->
read_frame
.
datalen
=
samples
;
tech_pvt
->
read_frame
.
samples
=
samples
/
2
;
tech_pvt
->
read_frame
.
samples
=
samples
/
2
;
...
@@ -852,14 +866,35 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
...
@@ -852,14 +866,35 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
*
frame
=
&
tech_pvt
->
read_frame
;
*
frame
=
&
tech_pvt
->
read_frame
;
if
((
samples2
=
tech_pvt
->
serialPort_serial_audio
->
Read
((
char
*
)
tech_pvt
->
read_frame
.
data
,
320
))
>
0
){
//if ((samples2 = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0){
WARNINGA
(
"samples2=%d
\n
"
,
GSMOPEN_P_LOG
,
samples2
);
// WARNINGA("samples2=%d\n", GSMOPEN_P_LOG, samples2);
//}
//status = SWITCH_STATUS_SUCCESS;
switch_set_flag
(
tech_pvt
,
TFLAG_VOICE
);
}
else
{
DEBUGA_GSMOPEN
(
"MINGA samples=%d
\n
"
,
GSMOPEN_P_LOG
,
samples
);
if
(
tech_pvt
->
buffer2_full
){
memcpy
(
tech_pvt
->
read_frame
.
data
,
tech_pvt
->
buffer2
,
320
);
tech_pvt
->
buffer2_full
=
0
;
samples
=
320
;
DEBUGA_GSMOPEN
(
"samples=%d FROM BUFFER
\n
"
,
GSMOPEN_P_LOG
,
samples
);
tech_pvt
->
read_frame
.
datalen
=
samples
;
tech_pvt
->
read_frame
.
samples
=
samples
/
2
;
tech_pvt
->
read_frame
.
timestamp
=
tech_pvt
->
timer_read
.
samplecount
;
}
*
frame
=
&
tech_pvt
->
read_frame
;
//if ((samples2 = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0){
// WARNINGA("samples2=%d\n", GSMOPEN_P_LOG, samples2);
//}
//status = SWITCH_STATUS_SUCCESS;
//status = SWITCH_STATUS_SUCCESS;
switch_set_flag
(
tech_pvt
,
TFLAG_VOICE
);
switch_set_flag
(
tech_pvt
,
TFLAG_VOICE
);
}
}
}
//WARNINGA("samples=%d\n", GSMOPEN_P_LOG, samples);
//WARNINGA("samples=%d\n", GSMOPEN_P_LOG, samples);
if
(
samples
!=
320
)
{
if
(
samples
!=
320
)
{
DEBUGA_GSMOPEN
(
"samples=%d
\n
"
,
GSMOPEN_P_LOG
,
samples
);
DEBUGA_GSMOPEN
(
"samples=%d
\n
"
,
GSMOPEN_P_LOG
,
samples
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论