view bwsplash/pbm2c.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 4d9f24c501f3
children
line wrap: on
line source

/*
 * This program compiles bwsplash.pbm into a C char array
 * for inclusion into phone UI firmware source.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

FILE *inf, *outf;
char *infname, linebuf[128];
int lineno;

void
get_input_line()
{
	char *cp;

	if (!fgets(linebuf, sizeof linebuf, inf)) {
		fprintf(stderr, "%s: premature EOF\n", infname);
		exit(1);
	}
	lineno++;
	cp = index(linebuf, '\n');
	if (!cp) {
		fprintf(stderr, "%s line %d: too long or missing newline\n",
			infname, lineno);
		exit(1);
	}
	*cp = '\0';
}

void
parse_pixel_line(outbuf, npix)
	u_char *outbuf;
	unsigned npix;
{
	char *cp;
	u_char *dp;
	unsigned n;

	cp = linebuf;
	dp = outbuf;
	for (n = 0; n < npix; n++) {
		if (*cp != '0' && *cp != '1') {
inv:			fprintf(stderr,
	"%s line %d: does not match expected line of %u 0/1 characters\n",
				infname, lineno, npix);
			exit(1);
		}
		*dp++ = *cp++ - '0';
	}
	if (*cp)
		goto inv;
}

void
pack_pixel_byte(bits)
	u_char *bits;
{
	unsigned byte, mask, n;

	byte = 0;
	for (n = 0, mask = 0x80; n < 8; n++, mask >>= 1)
		if (bits[n])
			byte |= mask;
	fprintf(outf, "0x%02X,", byte);
}

main(argc, argv)
	char **argv;
{
	unsigned nrow, ncol;
	u_char rowbuf[80];

	if (argc != 3) {
		fprintf(stderr, "usage: %s pbmfile outfile\n", argv[0]);
		exit(1);
	}
	infname = argv[1];
	inf = fopen(infname, "r");
	if (!inf) {
		perror(infname);
		exit(1);
	}
	get_input_line();
	if (strcmp(linebuf, "P1")) {
		fprintf(stderr,
			"error in %s: first line is not the expected \"P1\"\n",
			infname);
		exit(1);
	}
	get_input_line();
	if (strcmp(linebuf, "80 30")) {
		fprintf(stderr,
		"error in %s: second line is not the expected \"80 30\"\n",
			infname);
		exit(1);
	}
	outf = fopen(argv[2], "w");
	if (!outf) {
		perror(argv[2]);
		exit(1);
	}
	for (nrow = 0; nrow < 30; nrow++) {
		get_input_line();
		parse_pixel_line(rowbuf, 80);
		putc('\t', outf);
		for (ncol = 0; ncol < 80; ncol += 8)
			pack_pixel_byte(rowbuf + ncol);
		putc('\n', outf);
	}
	exit(0);
}