FreeCalypso > hg > freecalypso-tools
view rvinterf/etmsync/l1tmops.c @ 497:74610c4f10f7
target-utils: added 10 ms delay at the end of abb_power_off()
The deosmification of the ABB access code (replacement of osmo_delay_ms()
bogus delays with correctly-timed ones, which are significantly shorter)
had one annoying side effect: when executing the poweroff command from
any of the programs, one last '=' prompt character was being sent (and
received by the x86 host) as the Calypso board powers off. With delays
being shorter now, the abb_power_off() function was returning and the
standalone program's main loop was printing its prompt before the Iota chip
fully executed the switch-off sequence!
I thought about inserting an endless tight loop at the end of the
abb_power_off() function, but the implemented solution of a 10 ms delay
is a little nicer IMO because if the DEVOFF operation doesn't happen for
some reason in a manual hacking scenario, there won't be an artificial
blocker in the form of a tight loop keeping us from further poking around.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 25 May 2019 20:44:05 +0000 |
parents | 4469d73bbc60 |
children | 4694c7686ccd |
line wrap: on
line source
/* * In this module we implement the functions that access the L1TM operations * which we are going to use in fc-tmsync and fc-readcal. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "pktmux.h" #include "tm3.h" #include "l1tm.h" #include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; do_tms(arg) { u_char cmdpkt[5]; cmdpkt[1] = TM_MODE_SET; cmdpkt[2] = arg; cmdpkt[3] = arg >> 8; etm_pkt_exch(cmdpkt, 3); if (rvi_msg[3]) { fprintf(stderr, "target error %u in response to tms\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != 5) { fprintf(stderr, "target error: tms response wrong length\n"); return(ERROR_TARGET); } return(0); } do_rfpr(index, retp) u_short *retp; { u_char cmdpkt[5]; cmdpkt[1] = RF_PARAM_READ; cmdpkt[2] = index; cmdpkt[3] = index >> 8; etm_pkt_exch(cmdpkt, 3); if (rvi_msg[3]) { fprintf(stderr, "target error %u in response to rfpr\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != 8) { fprintf(stderr, "target error: rfpr response wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "target error: rfpr response wrong index\n"); return(ERROR_TARGET); } *retp = rvi_msg[5] | (rvi_msg[6] << 8); return(0); } do_rfpw(index, value) { u_char cmdpkt[7]; cmdpkt[1] = RF_PARAM_WRITE; cmdpkt[2] = index; cmdpkt[3] = index >> 8; cmdpkt[4] = value; cmdpkt[5] = value >> 8; etm_pkt_exch(cmdpkt, 5); if (rvi_msg[3]) { fprintf(stderr, "target error %u in response to rfpw\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "target error: rfpw response wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "target error: rfpw response wrong index\n"); return(ERROR_TARGET); } return(0); } do_rftr(index, table, size) u_char *table; { u_char cmdpkt[4]; cmdpkt[1] = RF_TABLE_READ; cmdpkt[2] = index; etm_pkt_exch(cmdpkt, 2); if (rvi_msg[3]) { fprintf(stderr, "target error %u in response to rftr\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len < size + 6) { fprintf(stderr, "target error: rftr response too short\n"); return(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "target error: rftr response wrong index\n"); return(ERROR_TARGET); } bcopy(rvi_msg + 5, table, size); return(0); } do_ttr(index, buf) u_char *buf; { u_char cmdpkt[4]; cmdpkt[1] = TX_TEMPLATE_READ; cmdpkt[2] = index; etm_pkt_exch(cmdpkt, 2); if (rvi_msg[3]) { fprintf(stderr, "target error %u in response to ttr\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != 38) { fprintf(stderr, "target error: ttr response wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "target error: ttr response wrong index\n"); return(ERROR_TARGET); } bcopy(rvi_msg + 5, buf, 32); return(0); }