FreeCalypso > hg > freecalypso-sw
changeset 263:b5b54feb111a
fc-tmsh: set-imeisv command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 05 Feb 2014 07:32:42 +0000 |
parents | 577291a2ad76 |
children | 0c938d8b5ba3 |
files | rvinterf/tmsh/Makefile rvinterf/tmsh/ffs2.c rvinterf/tmsh/ffs2wr.c rvinterf/tmsh/usercmd.c |
diffstat | 4 files changed, 73 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/tmsh/Makefile Wed Feb 05 06:51:09 2014 +0000 +++ b/rvinterf/tmsh/Makefile Wed Feb 05 07:32:42 2014 +0000 @@ -3,8 +3,9 @@ PROGS= fc-tmsh INSTBIN=/usr/local/bin -TMSH_OBJS= abb.o etmbasic.o ffs2.o ffs2resp.o init.o interf.o launchrvif.o\ - main.o misc.o pktsort.o tmcore.o ttymagic.o usercmd.o +TMSH_OBJS= abb.o etmbasic.o ffs2.o ffs2resp.o ffs2wr.o init.o interf.o \ + launchrvif.o main.o misc.o pktsort.o tmcore.o ttymagic.o \ + usercmd.o all: ${PROGS}
--- a/rvinterf/tmsh/ffs2.c Wed Feb 05 06:51:09 2014 +0000 +++ b/rvinterf/tmsh/ffs2.c Wed Feb 05 07:32:42 2014 +0000 @@ -7,7 +7,6 @@ #include <string.h> #include <strings.h> #include <stdlib.h> -#include "pktmux.h" #include "limits.h" #include "localtypes.h" #include "etm.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/tmsh/ffs2wr.c Wed Feb 05 07:32:42 2014 +0000 @@ -0,0 +1,68 @@ +/* + * In this module we are going to implement some high-level FFS write + * operations, using the TMFFS2 protocol. + */ + +#include <sys/types.h> +#include <ctype.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "limits.h" +#include "localtypes.h" +#include "etm.h" +#include "ffs.h" +#include "tmffs2.h" + +void +cmd_set_imeisv(argc, argv) + char **argv; +{ + char *filename, *cp, digits[16]; + u_char bytes[8], cmdpkt[MAX_PKT_TO_TARGET], *dp; + int pcm_order, i; + + if (!strcmp(argv[1], "pcm")) { + filename = "/pcm/IMEI"; + pcm_order = 1; + } else if (!strcmp(argv[1], "fc")) { + filename = "/etc/IMEISV"; + pcm_order = 0; + } else { + printf( + "error: IMEISV storage type argument must be \"pcm\" or \"fc\"\n"); + return; + } + cp = argv[2]; + if (!isdigit(*cp)) { +inv: printf("error: 2nd argument must have 16 decimal digits\n"); + return; + } + for (i = 0; i < 16; i++) { + if (ispunct(*cp)) + cp++; + if (!isdigit(*cp)) + goto inv; + digits[i] = *cp++ - '0'; + } + if (*cp) + goto inv; + for (i = 0; i < 8; i++) + bytes[i] = pcm_order ? digits[i*2+1] << 4 | digits[i*2] + : digits[i*2] << 4 | digits[i*2+1]; + printf("Writing \"%02X %02X %02X %02X %02X %02X %02X %02X\" into %s\n", + bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], + bytes[6], bytes[7], filename); + dp = cmdpkt + 1; + *dp++ = ETM_FFS2; + *dp++ = TMFFS_FILE_WRITE; + *dp++ = strlen(filename) + 1; + strcpy(dp, filename); + dp += strlen(filename) + 1; + *dp++ = 8; /* data size in bytes */ + bcopy(bytes, dp, 8); + dp += 8; + *dp++ = FFS_O_CREATE | FFS_O_TRUNC; + send_etm_cmd(cmdpkt, dp - cmdpkt - 1); +}
--- a/rvinterf/tmsh/usercmd.c Wed Feb 05 06:51:09 2014 +0000 +++ b/rvinterf/tmsh/usercmd.c Wed Feb 05 07:32:42 2014 +0000 @@ -21,6 +21,7 @@ extern void cmd_r8(); extern void cmd_r16(); extern void cmd_r32(); +extern void cmd_set_imeisv(); extern void cmd_tgtreset(); extern void cmd_version(); extern void cmd_w8(); @@ -52,6 +53,7 @@ {"r8", 1, 2, cmd_r8}, {"r16", 1, 2, cmd_r16}, {"r32", 1, 2, cmd_r32}, + {"set-imeisv", 2, 2, cmd_set_imeisv}, {"tgtreset", 0, 0, cmd_tgtreset}, {"version", 1, 1, cmd_version}, {"w8", 2, 246, cmd_w8},