FreeCalypso > hg > freecalypso-tools
view rvinterf/asyncshell/tchplay.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 | 971906d7763d |
children |
line wrap: on
line source
/* * TCH uplink play-from-file functionality */ #include <sys/types.h> #include <ctype.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include "pktmux.h" #include "tch_feature.h" extern u_char rvi_msg[]; extern int rvi_msg_len; extern void async_msg_output(); static FILE *play_file; static int queued_frames; #define QUEUE_LIMIT 3 static void sync_msgout(msg) char *msg; { printf("%s\n", msg); } static decode_hex_digit(ch) { if (isdigit(ch)) return(ch - '0'); else if (isupper(ch)) return(ch - 'A' + 10); else return(ch - 'a' + 10); } static decode_hex_line(line, bytes) char *line; u_char *bytes; { int i; for (i = 0; i < 33; i++) { if (!isxdigit(line[0]) || !isxdigit(line[1])) return(-1); bytes[i] = (decode_hex_digit(line[0]) << 4) | decode_hex_digit(line[1]); line += 2; } for (; *line; line++) if (!isspace(*line)) return(-1); return(0); } static void fill_uplink(msgout) void (*msgout)(); { char line[80]; u_char sendpkt[35]; int cc; sendpkt[0] = RVT_TCH_HEADER; sendpkt[1] = TCH_ULBITS_REQ; while (queued_frames < QUEUE_LIMIT) { if (!fgets(line, sizeof line, play_file)) { msgout("TCH UL: file play finished"); fclose(play_file); play_file = 0; return; } if (decode_hex_line(line, sendpkt + 2) < 0) { msgout("TCH UL: bad file input, play aborted"); fclose(play_file); play_file = 0; return; } send_pkt_to_target(sendpkt, 35); queued_frames++; } } void tch_ulbits_conf() { if (queued_frames > 0) queued_frames--; if (play_file) fill_uplink(async_msg_output); } static void cmd_tch_play_start(filename) char *filename; { if (play_file) { printf("error: tch play session already in progress\n"); return; } play_file = fopen(filename, "r"); if (!play_file) { perror(filename); return; } printf("Starting TCH UL play from file\n"); tch_rx_control(1); fill_uplink(sync_msgout); } static void cmd_tch_play_stop() { if (!play_file) { printf("error: no tch play session in progress\n"); return; } fclose(play_file); play_file = 0; printf("TCH UL play from file terminated\n"); } void cmd_tch_play(argc, argv) char **argv; { if (argc < 2) { printf("error: too few arguments\n"); return; } if (strcmp(argv[1], "stop")) cmd_tch_play_start(argv[1]); else cmd_tch_play_stop(); } void show_tch_play_status() { printf("TCH UL play from file: %s\n", play_file ? "RUNNING" : "not running"); printf("Outstanding UL frames: %d\n", queued_frames); }