FreeCalypso > hg > fc-sim-tools
view serial/xmit.c @ 93:6041c601304d
fcsim1-mkprov: revert OTA key addition
It appears that GrcardSIM2 cards (which is what we got for FCSIM1)
do not support OTA after all, contrary to what we were previously
led to believe by some tech support emails from Grcard - apparently
those support emails and OTA descriptions referred to some other
card model(s).
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 21 Apr 2021 05:38:39 +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); }
