fixed various bugs in monitor-cli.

This commit is contained in:
gardners 2012-05-08 15:47:39 +09:30
parent c571493096
commit b198db38b9
2 changed files with 27 additions and 14 deletions

View File

@ -8,12 +8,26 @@
#include "serval.h"
char cmd[1024];
int cmdLen=0;
int cmdOfs=0;
int dataBytesExpected=0;
unsigned char data[65536];
int dataBytes=0;
#define STATE_CMD 1
#define STATE_DATA 2
int state=STATE_CMD;
int fd;
int writeLine(char *msg)
{
write(fd,msg,strlen(msg));
return 0;
}
int processChar(int c);
int app_monitor_cli(int argc, const char *const *argv, struct command_line_option *o)
{
const char *sid=NULL;
@ -88,6 +102,7 @@ int app_monitor_cli(int argc, const char *const *argv, struct command_line_optio
return 0;
}
int counter=0;
int callState=0;
int processLine(char *cmd,unsigned char *data,int dataLen)
{
@ -124,6 +139,7 @@ int processLine(char *cmd,unsigned char *data,int dataLen)
/* Send synthetic audio packet */
char buffer[1024];
sprintf(buffer,"*320:AUDIO:%x:8\n"
"%08d pasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
@ -132,25 +148,18 @@ int processLine(char *cmd,unsigned char *data,int dataLen)
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456"
"qwertyuiopasdfghjklzxcvbnm123456",l_id);
"qwertyuiopasdfghjklzxcvbnm123456",l_id,counter++);
writeLine(buffer);
printf("< *320:AUDIO:%x:8\\n<320 bytes>\n",l_id);
}
}
cmd[0]=0;
cmdLen=0;
dataBytes=0;
dataBytesExpected=0;
state=STATE_CMD;
return 0;
}
char cmd[1024];
int cmdLen=0;
int cmdOfs=0;
int dataBytesExpected=0;
unsigned char data[65536];
int dataBytes=0;
#define STATE_CMD 1
#define STATE_DATA 2
int state=STATE_CMD;
int processChar(int c)
{
switch(state) {
@ -180,4 +189,5 @@ int processChar(int c)
cmdLen=0;
}
}
return 0;
}

View File

@ -166,6 +166,8 @@ int monitor_poll()
for(i=0;i<vomp_call_count;i++) {
/* Push out any undelivered status changes */
monitor_call_status(&vomp_call_states[i]);
WHYF("Sending keepalives for call #%d",i);
/* And let far-end know that call is still alive */
snprintf(msg,128,"\nKEEPALIVE:%06x\n",vomp_call_states[i].local.session);
for(m=0;m<monitor_socket_count;m++)
@ -562,6 +564,7 @@ int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio)
fcntl(monitor_sockets[i].socket,F_SETFL,
fcntl(monitor_sockets[i].socket, F_GETFL, NULL)|O_NONBLOCK);
write(monitor_sockets[i].socket,msg,msglen);
WHYF("Writing AUDIOPACKET to client");
if (errno&&(errno!=EINTR)&&(errno!=EAGAIN)) {
/* error sending update, so kill monitor socket */
WHYF("Tearing down monitor client #%d due to errno=%d",