# HG changeset patch # User Mychaela Falconia # Date 1495475130 0 # Node ID 1c4abfe8bcd90d891e4d10570255241393129165 # Parent 724e16223187f9336baad9a6a6a4663e44979eab autocal/l1tmops.c started diff -r 724e16223187 -r 1c4abfe8bcd9 autocal/Makefile --- a/autocal/Makefile Sun May 21 23:04:42 2017 +0000 +++ b/autocal/Makefile Mon May 22 17:45:30 2017 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -I/opt/freecalypso/include -OBJS= rvinterf.o tsidsock.o +OBJS= l1tmops.o rvinterf.o tsidsock.o all: ${OBJS} diff -r 724e16223187 -r 1c4abfe8bcd9 autocal/l1tmops.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/l1tmops.c Mon May 22 17:45:30 2017 +0000 @@ -0,0 +1,49 @@ +/* + * In this module we are going to implement the functions for executing + * various L1TM operations on the DUT. + */ + +#include +#include +#include +#include +#include +#include +#include + +extern u_char rvi_msg[]; +extern int rvi_msg_len; + +l1tm_pkt_exch(outbuf, outlen) + u_char *outbuf; +{ + int i, c; + + outbuf[0] = RVT_TM_HEADER; + c = 0; + for (i = 1; i <= outlen; i++) + c ^= outbuf[i]; + outbuf[i] = c; + target_pkt_exch(outbuf, outlen + 2); + if (rvi_msg[1] != RVT_TM_HEADER) { + fprintf(stderr, + "DUT error: response packet is not on TM channel\n"); + exit(ERROR_TARGET); + } + if (rvi_msg_len < 5) { + fprintf(stderr, "DUT error: TM response packet is too short\n"); + exit(ERROR_TARGET); + } + c = 0; + for (i = 2; i < rvi_msg_len; i++) + c ^= rvi_msg[i]; + if (c) { + fprintf(stderr, "DUT error: TM response bad checksum\n"); + exit(ERROR_TARGET); + } + if (rvi_msg[2] != outbuf[1]) { + fprintf(stderr, "DUT error: TM response has wrong CID\n"); + exit(ERROR_TARGET); + } + return(0); +}