changeset 841:379574e5cf5e

fc-tmsync aur command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 31 Jul 2021 08:29:24 +0000
parents 25a182bc031b
children 9da5fb3f42dd
files rvinterf/etmsync/Makefile rvinterf/etmsync/tmsaur.c rvinterf/etmsync/tmscmdtab.c
diffstat 3 files changed, 132 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile	Sat Jul 31 07:33:58 2021 +0000
+++ b/rvinterf/etmsync/Makefile	Sat Jul 31 08:29:24 2021 +0000
@@ -24,7 +24,7 @@
 READCAL_OBJS=	hostmkdir.o interf.o l1tmops.o readcal.o ${LIBINTERF}
 
 TMSYNC_OBJS=	cl_des.o dispatch.o interf.o l1tmcmd.o l1tmops.o memcmd.o \
-		memops.o piradccal.o pirimei.o tmscmdtab.o tmsmain.o \
+		memops.o piradccal.o pirimei.o tmsaur.o tmscmdtab.o tmsmain.o \
 		${LIBINTERF} ${LIBRFTAB}
 
 all:	${PROGS}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/tmsaur.c	Sat Jul 31 08:29:24 2021 +0000
@@ -0,0 +1,129 @@
+/*
+ * This fc-tmsync module implements aur commands and operations.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "etm.h"
+#include "audio.h"
+#include "limits.h"
+#include "localtypes.h"
+#include "exitcodes.h"
+
+extern u_char rvi_msg[];
+extern int rvi_msg_len;
+
+do_aur(param, data, size)
+	u_char *data;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_AUDIO;
+	cmdpkt[2] = 'R';
+	cmdpkt[3] = param;
+	etm_pkt_exch(cmdpkt, 3);
+	if (rvi_msg[3]) {
+		fprintf(stderr, "target error %u in response to aur\n",
+			rvi_msg[3]);
+		return(ERROR_TARGET);
+	}
+	if (rvi_msg_len < size + 7) {
+		fprintf(stderr, "target error: aur response too short\n");
+		return(ERROR_TARGET);
+	}
+	if (rvi_msg[4] != 'R') {
+		fprintf(stderr, "target error: aur response wrong type\n");
+		return(ERROR_TARGET);
+	}
+	if (rvi_msg[5] != param) {
+		fprintf(stderr, "target error: aur response wrong index\n");
+		return(ERROR_TARGET);
+	}
+	bcopy(rvi_msg + 6, data, size);
+	return(0);
+}
+
+cmd_aur(argc, argv)
+	char **argv;
+{
+	unsigned param, word;
+	u_char data[62];
+	int size, rc, i;
+
+	param = strtoul(argv[1], 0, 0);
+	switch (param) {
+	case AUDIO_PATH_USED:
+	case AUDIO_MICROPHONE_MODE:
+	case AUDIO_MICROPHONE_GAIN:
+	case AUDIO_MICROPHONE_EXTRA_GAIN:
+	case AUDIO_MICROPHONE_OUTPUT_BIAS:
+	case AUDIO_SPEAKER_MODE:
+	case AUDIO_SPEAKER_GAIN:
+	case AUDIO_SPEAKER_FILTER:
+	case AUDIO_SPEAKER_BUZZER_STATE:
+	case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE:
+	case AUDIO_SPEAKER_VOLUME_LEVEL:
+		size = 1;
+		break;
+	case AUDIO_MICROPHONE_FIR:
+	case AUDIO_SPEAKER_FIR:
+		size = 62;
+		break;
+	case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC:
+		size = 24;
+		break;
+	default:
+		fprintf(stderr, "error: unknown aur parameter\n");
+		return(ERROR_USAGE);
+	}
+	rc = do_aur(param, data, size);
+	if (rc)
+		return(rc);
+	switch (param) {
+	case AUDIO_PATH_USED:
+	case AUDIO_SPEAKER_VOLUME_LEVEL:
+		printf("%u\n", data[0]);
+		break;
+	case AUDIO_MICROPHONE_MODE:
+	case AUDIO_MICROPHONE_GAIN:
+	case AUDIO_MICROPHONE_EXTRA_GAIN:
+	case AUDIO_MICROPHONE_OUTPUT_BIAS:
+	case AUDIO_SPEAKER_MODE:
+	case AUDIO_SPEAKER_GAIN:
+	case AUDIO_SPEAKER_FILTER:
+	case AUDIO_SPEAKER_BUZZER_STATE:
+	case AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE:
+		i = data[0];
+		if (i >= 128)
+			i -= 256;
+		printf("%d\n", i);
+		break;
+	case AUDIO_MICROPHONE_FIR:
+	case AUDIO_SPEAKER_FIR:
+		fputs("fir-coeff-table\n\n", stdout);
+		for (i = 0; i < 31; i++) {
+			printf("0x%04X", (data[i*2+1] << 8) | data[i*2]);
+			if (i == 7 || i == 15 || i == 23 || i == 30)
+				putchar('\n');
+			else
+				putchar(' ');
+		}
+		break;
+	case AUDIO_MICROPHONE_SPEAKER_LOOP_AEC:
+		fputs("aec-new", stdout);
+		for (i = 0; i < 12; i++) {
+			putchar(' ');
+			word = (data[i*2+1] << 8) | data[i*2];
+			if (word)
+				printf("0x%X", word);
+			else
+				putchar('0');
+		}
+		putchar('\n');
+		break;
+	}
+	return(0);
+}
--- a/rvinterf/etmsync/tmscmdtab.c	Sat Jul 31 07:33:58 2021 +0000
+++ b/rvinterf/etmsync/tmscmdtab.c	Sat Jul 31 08:29:24 2021 +0000
@@ -4,6 +4,7 @@
 
 #include "cmdtab.h"
 
+extern int cmd_aur();
 extern int cmd_dieid();
 extern int cmd_exec();
 extern int cmd_exit();
@@ -20,6 +21,7 @@
 extern int get_pirelli_imei();
 
 struct cmdtab cmdtab[] = {
+	{"aur", 1, 1, cmd_aur},
 	{"dieid", 0, 0, cmd_dieid},
 	{"exec", 1, 1, cmd_exec},
 	{"exit", 0, 0, cmd_exit},