/* g++ QR2SerialNum.C -o QR2SerialNum.exe */ #include #include #include #include #include #include using namespace std; int main (int argc, char *argv[]) { if (argc<2) { cerr << "not enough arguments: argc = " << argc << endl << "Syntax should be:\n./QR2SerialNum.exe QRCode" << endl << "Example:\n./QR2SerialNum.exe \"SAMPA V4G35F77.118/254182\"" << endl; return -1; } const int kFirstLot = 11; // see info on waferlots and prefix to be used for serial numbers in waferlots.txt // not so many, so I just setup the map here directly map lot_map; lot_map["G35F72.1"] = 0; lot_map["G35F73.1"] = 1; lot_map["G35F74.1"] = 2; lot_map["G35F75.1"] = 3; lot_map["G35F76.1"] = 4; lot_map["G35F77.1"] = 5; lot_map["G35F78.1"] = 6; lot_map["G35F79.1"] = 7; lot_map["G35F80.1"] = 8; lot_map["G35F81.1"] = 9; lot_map["G35F82.1"] = 10; lot_map["G35F83.1"] = 11; lot_map["G35F83.2"] = 12; // N.B.: special case; not sure if serial number within .2 lot will start at 0 or not lot_map["G35F84.1"] = 13; lot_map["G35F85.1"] = 14; lot_map["G39B57.1"] = 15; lot_map["G39B58.1"] = 16; lot_map["G6M389.1"] = 17; lot_map["GAHM81.1"] = 18; // let's get the parts of the argument string we need string str(argv[1]); string strLot = str.substr(8,8); // wafer lot part string strNum = str.substr(21,4); // last 4 digits; number within wafer lot cout << " chipStr " << str << " lot-id " << strLot << " serialNum " << strNum << endl; map::iterator it = lot_map.find(strLot); if (it != lot_map.end()) { // cout << " prefix " << it->second << endl; int ichip = atoi(strNum.c_str()); ichip += (it->second + kFirstLot)*10000; if (it->second == 17) { char *c = (char *) str.c_str(); char *pos = strstr(c, "20/07"); if (pos) { // original set, no offset needed } else { ichip += 5000; } } cout << " 6-digit-id: " << ichip << endl; } else { cerr << " unknown lot! " << endl; } return 0; }