FreeCalypso > hg > freecalypso-tools
changeset 4:971906d7763d
fc-shell tch commands: changed to raw hex file format
This "backward" change is needed for two reasons:
1) to support EFR in addition to 06.10
2) to preserve the DSP status words for the downlink
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 14 Jun 2016 01:02:48 +0000 |
parents | 6a029ad28212 |
children | 7eaa3307e5df |
files | rvinterf/asyncshell/Makefile rvinterf/asyncshell/tchplay.c rvinterf/asyncshell/tchrec.c |
diffstat | 3 files changed, 74 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/asyncshell/Makefile Sat Jun 11 01:52:51 2016 +0000 +++ b/rvinterf/asyncshell/Makefile Tue Jun 14 01:02:48 2016 +0000 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 -I../include PROG= fc-shell -OBJS= at.o gsm0610.o init.o main.o oneshot.o parse.o pktsort.o poweroff.o \ - rxctl.o sendarb.o sendsp.o tchcmd.o tchplay.o tchrec.o usercmd.o +OBJS= at.o init.o main.o oneshot.o parse.o pktsort.o poweroff.o rxctl.o \ + sendarb.o sendsp.o tchcmd.o tchplay.o tchrec.o usercmd.o LIBS= ../libasync/libasync.a ../libg23/libg23.a INSTBIN=/usr/local/bin
--- a/rvinterf/asyncshell/tchplay.c Sat Jun 11 01:52:51 2016 +0000 +++ b/rvinterf/asyncshell/tchplay.c Tue Jun 14 01:02:48 2016 +0000 @@ -3,6 +3,7 @@ */ #include <sys/types.h> +#include <ctype.h> #include <stdio.h> #include <string.h> #include <strings.h> @@ -15,7 +16,7 @@ extern void async_msg_output(); -static FILE *gsm_data_file; +static FILE *play_file; static int queued_frames; #define QUEUE_LIMIT 3 @@ -27,30 +28,60 @@ printf("%s\n", msg); } +static +decode_hex_digit(ch) +{ + if (isdigit(ch)) + return(ch - '0'); + else if (isupper(ch)) + return(ch - 'A' + 10); + else + return(ch - 'a' + 10); +} + +static +decode_hex_line(line, bytes) + char *line; + u_char *bytes; +{ + int i; + + for (i = 0; i < 33; i++) { + if (!isxdigit(line[0]) || !isxdigit(line[1])) + return(-1); + bytes[i] = (decode_hex_digit(line[0]) << 4) | + decode_hex_digit(line[1]); + line += 2; + } + for (; *line; line++) + if (!isspace(*line)) + return(-1); + return(0); +} + static void fill_uplink(msgout) void (*msgout)(); { - u_char readbytes[33], sendpkt[35]; + char line[80]; + u_char sendpkt[35]; int cc; sendpkt[0] = RVT_TCH_HEADER; sendpkt[1] = TCH_ULBITS_REQ; while (queued_frames < QUEUE_LIMIT) { - cc = fread(readbytes, 1, 33, gsm_data_file); - if (cc < 33) { - if (cc) - msgout("TCH UL: extra bytes at the end of the file"); + if (!fgets(line, sizeof line, play_file)) { msgout("TCH UL: file play finished"); - gsm_data_file = 0; + fclose(play_file); + play_file = 0; return; } - if ((readbytes[0] & 0xF0) != 0xD0) { + if (decode_hex_line(line, sendpkt + 2) < 0) { msgout("TCH UL: bad file input, play aborted"); - gsm_data_file = 0; + fclose(play_file); + play_file = 0; return; } - gsm0610_libgsm_to_tidsp(readbytes, sendpkt + 2); send_pkt_to_target(sendpkt, 35); queued_frames++; } @@ -61,7 +92,7 @@ { if (queued_frames > 0) queued_frames--; - if (gsm_data_file) + if (play_file) fill_uplink(async_msg_output); } @@ -69,12 +100,12 @@ cmd_tch_play_start(filename) char *filename; { - if (gsm_data_file) { + if (play_file) { printf("error: tch play session already in progress\n"); return; } - gsm_data_file = fopen(filename, "r"); - if (!gsm_data_file) { + play_file = fopen(filename, "r"); + if (!play_file) { perror(filename); return; } @@ -86,12 +117,12 @@ static void cmd_tch_play_stop() { - if (!gsm_data_file) { + if (!play_file) { printf("error: no tch play session in progress\n"); return; } - fclose(gsm_data_file); - gsm_data_file = 0; + fclose(play_file); + play_file = 0; printf("TCH UL play from file terminated\n"); } @@ -113,6 +144,6 @@ show_tch_play_status() { printf("TCH UL play from file: %s\n", - gsm_data_file ? "RUNNING" : "not running"); + play_file ? "RUNNING" : "not running"); printf("Outstanding UL frames: %d\n", queued_frames); }
--- a/rvinterf/asyncshell/tchrec.c Sat Jun 11 01:52:51 2016 +0000 +++ b/rvinterf/asyncshell/tchrec.c Tue Jun 14 01:02:48 2016 +0000 @@ -13,18 +13,29 @@ extern u_char rvi_msg[]; extern int rvi_msg_len; -static FILE *gsm_data_file; +static FILE *record_file; static u_long frame_count; void tch_dlbits_handler() { - u_char writebytes[33]; + u_char *ptr; + int i; - if (!gsm_data_file) + if (!record_file) return; - gsm0610_tidsp_to_libgsm(rvi_msg + 9, writebytes); - fwrite(writebytes, 1, 33, gsm_data_file); + /* DSP status words */ + ptr = rvi_msg + 3; + for (i = 0; i < 3; i++) { + fprintf(record_file, "%02X%02X ", ptr[0], ptr[1]); + ptr += 2; + } + /* frame bits */ + for (i = 0; i < 33; i++) { + fprintf(record_file, "%02X", *ptr); + ptr++; + } + putc('\n', record_file); frame_count++; } @@ -32,12 +43,12 @@ cmd_tch_record_start(filename) char *filename; { - if (gsm_data_file) { + if (record_file) { printf("error: tch record session already in progress\n"); return; } - gsm_data_file = fopen(filename, "w"); - if (!gsm_data_file) { + record_file = fopen(filename, "w"); + if (!record_file) { perror(filename); return; } @@ -50,12 +61,12 @@ static void cmd_tch_record_stop() { - if (!gsm_data_file) { + if (!record_file) { printf("error: no tch record session in progress\n"); return; } - fclose(gsm_data_file); - gsm_data_file = 0; + fclose(record_file); + record_file = 0; printf("TCH DL recording stopped, captured %lu speech frames\n", frame_count); send_tch_config_req(0); @@ -79,5 +90,5 @@ show_tch_record_status() { printf("TCH DL recording: %s\n", - gsm_data_file ? "RUNNING" : "not running"); + record_file ? "RUNNING" : "not running"); }