FreeCalypso > hg > fc-sim-tools
view serial/xmit.c @ 99:97ba63d9361a
scripts/fcsim1-sst: turn off STK & OTA services
In the initial unprogrammed state of the cards from Grcard, SST has
services 25 through 29 set to allocated and activated. However,
these cards appear to not actually support OTA, ENVELOPE commands
do nothing (just return SW 9000), and they were never observed
issuing any proactive SIM commands, even after a feature-generous
TERMINAL PROFILE. Therefore, let's list these STK & OTA services
as allocated, but not activated in our FCSIM1 SST.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 05 May 2021 04:26:07 +0000 |
parents | 5ee00413b8af |
children |
line wrap: on
line source
/* * This module implements the function for sending byte strings * to the SIM and collecting the UART echo. */ #include <sys/types.h> #include <sys/time.h> #include <sys/errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> extern int target_fd; extern int inverse_coding; send_bytes_to_sim(data, nbytes) u_char *data; unsigned nbytes; { u_char buf1[255], buf2[255]; fd_set fds; struct timeval tv; unsigned rcvd; int cc; bcopy(data, buf1, nbytes); if (inverse_coding) invert_bytes(buf1, nbytes); write(target_fd, buf1, nbytes); for (rcvd = 0; rcvd < nbytes; ) { FD_ZERO(&fds); FD_SET(target_fd, &fds); tv.tv_sec = 1; tv.tv_usec = 0; cc = select(target_fd+1, &fds, NULL, NULL, &tv); if (cc < 0) { if (errno == EINTR) continue; perror("select"); return(-1); } if (cc < 1) { fprintf(stderr, "error: timeout waiting for echo of Tx bytes\n"); return(-1); } cc = read(target_fd, buf2 + rcvd, nbytes - rcvd); if (cc <= 0) { perror("read after successful select"); return(-1); } rcvd += cc; } if (bcmp(buf1, buf2, nbytes)) { fprintf(stderr, "error: UART echo mismatch\n"); return(-1); } else return(0); }