FreeCalypso > hg > freecalypso-sw
diff rvinterf/etmsync/interf.c @ 278:f77480d3dd21
fc-fsio: first ffs2ver command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 24 Feb 2014 04:41:57 +0000 |
parents | e23fc1228efd |
children |
line wrap: on
line diff
--- a/rvinterf/etmsync/interf.c Mon Feb 24 03:42:47 2014 +0000 +++ b/rvinterf/etmsync/interf.c Mon Feb 24 04:41:57 2014 +0000 @@ -121,3 +121,36 @@ } return(0); } + +etm_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) { + printf("error: packet from target is not ETM!\n"); + return(ERROR_TARGET); + } + if (rvi_msg_len < 5) { + printf("error: ETM response packet is too short\n"); + return(ERROR_TARGET); + } + c = 0; + for (i = 2; i < rvi_msg_len; i++) + c ^= rvi_msg[i]; + if (c) { + printf("ETM response checksum error!\n"); + return(ERROR_TARGET); + } + if (rvi_msg[2] != outbuf[1]) { + printf("error: target response is from wrong ETM component\n"); + return(ERROR_TARGET); + } + return(0); +}