#!/usr/bin/nickle
string[] speeds = { "57600", "19200", "9600" };

string make_set_nmea(string speed) {
	return sprintf ("PUBX,41,1,3,1,%s,0", speed);
}

int csum(string x) {
	int csum = 0;
	for (int i = 0; i < String::length(x); i++)
		csum ^= x[i];
	return csum;
}

for (int i = 0; i < dim(speeds); i++) {
	string s = make_set_nmea(speeds[i]);
	int c = csum(s);
	printf ("/* $%s* */\n", s);
	printf ("#define SERIAL_SPEED_STRING   \"%s\"\n", speeds[i]);
	printf ("#define SERIAL_SPEED_CHECKSUM \"%02x\"\n", c);
}
	
	
