gsmopen: windows again, back to linux
This commit is contained in:
parent
eaa37c3e41
commit
35d8aa44f8
|
@ -505,6 +505,9 @@ struct private_object {
|
|||
|
||||
ctb::SerialPort* serialPort_serial_control;
|
||||
|
||||
char buffer2[320];
|
||||
int buffer2_full;
|
||||
|
||||
};
|
||||
|
||||
typedef struct private_object private_t;
|
||||
|
@ -554,11 +557,11 @@ int gsmopen_socket_create_and_bind(private_t * tech_pvt, int *which_port);
|
|||
|
||||
|
||||
void *gsmopen_do_controldev_thread(void *data);
|
||||
#ifdef WIN32
|
||||
//#ifdef WIN32
|
||||
int gsmopen_serial_init(private_t * tech_pvt, int controldevice_speed);
|
||||
#else
|
||||
int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed);
|
||||
#endif //WIN32
|
||||
//#else
|
||||
//int gsmopen_serial_init(private_t * tech_pvt, speed_t controldevice_speed);
|
||||
//#endif //WIN32
|
||||
int gsmopen_serial_monitor(private_t * tech_pvt);
|
||||
int gsmopen_serial_sync(private_t * tech_pvt);
|
||||
int gsmopen_serial_sync_AT(private_t * tech_pvt);
|
||||
|
|
|
@ -60,7 +60,8 @@ int gsmopen_serial_init(private_t * tech_pvt, int controldevice_speed)
|
|||
|
||||
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);
|
||||
} else {
|
||||
ERRORA("port NOT open\n", GSMOPEN_P_LOG);
|
||||
|
@ -214,6 +215,16 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
|
|||
/* go until first empty preinit string, or last preinit string */
|
||||
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)) {
|
||||
res = gsmopen_serial_write_AT_expect(tech_pvt, tech_pvt->at_preinit_1, tech_pvt->at_preinit_1_expect);
|
||||
if (res) {
|
||||
|
@ -274,6 +285,9 @@ int gsmopen_serial_config_AT(private_t * tech_pvt)
|
|||
ERRORA("no response to AT\n", GSMOPEN_P_LOG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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");
|
||||
if (res) {
|
||||
|
@ -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();
|
||||
|
||||
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);
|
||||
} else {
|
||||
ERRORA("port NOT open\n", GSMOPEN_P_LOG);
|
||||
|
|
|
@ -810,7 +810,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
int samples;
|
||||
int samples2;
|
||||
char digit_str[256];
|
||||
short buffer2[640];
|
||||
char buffer2[640];
|
||||
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
@ -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 = alsa_read(tech_pvt, (short *) tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
||||
#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.samples = samples/2;
|
||||
|
||||
|
@ -852,14 +866,35 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
|||
|
||||
*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);
|
||||
|
||||
}
|
||||
//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;
|
||||
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;
|
||||
switch_set_flag(tech_pvt, TFLAG_VOICE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//WARNINGA("samples=%d\n", GSMOPEN_P_LOG, samples);
|
||||
if (samples != 320) {
|
||||
DEBUGA_GSMOPEN("samples=%d\n", GSMOPEN_P_LOG, samples);
|
||||
|
|
Loading…
Reference in New Issue