void testSpeedDensity(void) { printf("*************************************************** testSpeedDensity\r\n"); EngineTestHelper eth(FORD_INLINE_6_1995); EXPAND_EngineTestHelper; schedulingQueue.clear(); // todo: there must be a better place for this eth.ec->trigger.customTotalToothCount = 8; eth.applyTriggerShape(); eth.fireTriggerEvents(36); assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F)); // 427 cubic inches, that's a LOT of engine eth.ec->specs.displacement = 6.99728; eth.ec->specs.cylindersCount = 8; eth.ec->injector.flow = gramm_second_to_cc_minute(5.303); float airMass = getAirMass(eth.ec, 0.92, 98, 293.16); assertEquals(0.9371, airMass); // 0.01414 sec or 14.14 ms assertEquals(0.01414, sdMath(eth.ec, airMass, 12.5)); }
void testIgnitionPlanning(void) { printf("*************************************************** testIgnitionPlanning\r\n"); EngineTestHelper eth(FORD_ESCORT_GT); EXPAND_EngineTestHelper; eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F); assertEqualsM("testIgnitionPlanning_AFR", 13.5, eth.engine.engineState.targetAFR); assertEquals(IM_BATCH, engineConfiguration->injectionMode); }
void GetEthernetList(StringCollection& dev) { CommandModel cmd; cmd.FuncName = FuncEthernetGetAll; cmd.Password = true; Value result; Rpc::Call(cmd, result); ENUM_LIST(EthernetInterface, List<EthernetInterface>(result), e) { EthernetInterface eth(*e); dev.insert(eth.Dev); }
static int __gfs_do_config(struct usb_configuration *c, int (*eth)(struct usb_configuration *c, u8 *ethaddr), u8 *ethaddr) { int ret; int index = 0; if (WARN_ON(!gfs_ffs_data)) return -ENODEV; if (gadget_is_otg(c->cdev->gadget)) { c->descriptors = gfs_otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } if (eth) { ret = eth(c, ethaddr); if (unlikely(ret < 0)) return ret; } ret = functionfs_add(c->cdev, c, gfs_ffs_data); if (unlikely(ret < 0)) return ret; /* After previous do_configs there may be some invalid * pointers in c->interface array. This happens every time * a user space function with fewer interfaces than a user * space function that was run before the new one is run. The * compasit's set_config() assumes that if there is no more * then MAX_CONFIG_INTERFACES interfaces in a configuration * then there is a NULL pointer after the last interface in * c->interface array. We need to make sure this is true. */ if (c->next_interface_id < ARRAY_SIZE(c->interface)) { c->interface[c->next_interface_id] = NULL; printk(KERN_ERR "=== usb_interface index = %d\n", c->next_interface_id); dump_stack(); for( index = 0 ; index < c->next_inteface_id ; index++ ) { printk(KERN_ERR "index = %d , function = %x \n", index , c->interface[index] ); } } return 0; }
void testMafLookup(void) { printf("*************************************************** testMafLookup\r\n"); EngineTestHelper eth(FORD_ESCORT_GT); EXPAND_EngineTestHelper; setBosch0280218037(config); engine->preCalculate(); assertEqualsM("@0", -34.5000, engine->mafDecodingLookup[0]); assertEqualsM("@1", -33.7875, engine->mafDecodingLookup[1]); assertEqualsM("@2", -33.0750, engine->mafDecodingLookup[2]); assertEqualsM("@200", 313.8826, engine->mafDecodingLookup[200]); assertEqualsM("@255", 738, engine->mafDecodingLookup[255]); }
void testSpeedDensity(void) { printf("*************************************************** testSpeedDensity\r\n"); EngineTestHelper eth(FORD_INLINE_6_1995); eth.ec->triggerConfig.customTotalToothCount = 8; eth.initTriggerShapeAndRpmCalculator(); eth.fireTriggerEvents(); assertEqualsM("RPM", 1500, eth.rpmState.rpm()); // 427 cubic inches, that's a LOT of engine eth.ec->displacement = 6.99728; eth.ec->cylindersCount = 8; eth.ec->injectorFlow = gramm_second_to_cc_minute(5.303); // 0.01414 sec or 14.14 ms assertEquals(0.01414, sdMath(eth.ec, 0.92, 98, 12.5, 293.16)); }
void testEngineMath(void) { printf("*************************************************** testEngineMath\r\n"); EngineTestHelper eth(FORD_ESCORT_GT); EXPAND_EngineTestHelper; engineConfiguration->operationMode = FOUR_STROKE_CAM_SENSOR; assertEqualsM("600 RPM", 50, getOneDegreeTimeMs(600) * 180); assertEqualsM("6000 RPM", 5, getOneDegreeTimeMs(6000) * 180); assertEquals(312.5, getTCharge(1000, 0, 300, 350 PASS_ENGINE_PARAMETER)); assertEquals(313.5833, getTCharge(1000, 50, 300, 350 PASS_ENGINE_PARAMETER)); assertEquals(314.6667, getTCharge(1000, 100, 300, 350 PASS_ENGINE_PARAMETER)); assertEquals(312.5, getTCharge(4000, 0, 300, 350 PASS_ENGINE_PARAMETER)); assertEquals(320.0833, getTCharge(4000, 50, 300, 350 PASS_ENGINE_PARAMETER)); assertEquals(327.6667, getTCharge(4000, 100, 300, 350 PASS_ENGINE_PARAMETER)); }
void testAngleResolver(void) { printf("*************************************************** testAngleResolver\r\n"); EngineTestHelper eth(FORD_ASPIRE_1996); Engine *engine = ð.engine; engine_configuration_s *engineConfiguration = eth.engine.engineConfiguration; engineConfiguration->globalTriggerAngleOffset = 175; assertTrue(engine->engineConfiguration2!=NULL); trigger_shape_s * ts = &engine->triggerShape; confgiureFordAspireTriggerShape(ts); ts->calculateTriggerSynchPoint(engineConfiguration, engine); assertEqualsM("index 2", 228.0450, ts->eventAngles[3]); // this angle is relation to synch point assertEqualsM("time 2", 0.3233, ts->wave.getSwitchTime(2)); assertEqualsM("index 5", 413.7470, ts->eventAngles[6]); assertEqualsM("time 5", 0.5692, ts->wave.getSwitchTime(5)); assertEquals(4, ts->getTriggerShapeSynchPointIndex()); assertEqualsM("shape size", 10, ts->getSize()); OutputSignalList list; ae.resetEventList(); printf("*************************************************** testAngleResolver 0\r\n"); findTriggerPosition(&ae.getNextActuatorEvent()->position, 53 - 175 PASS_ENGINE_PARAMETER); assertEqualsM("size", 1, ae.size); assertEquals(1, ae.events[0].position.eventIndex); assertEquals(3.1588, ae.events[0].position.angleOffset); printf("*************************************************** testAngleResolver 2\r\n"); ae.resetEventList(); findTriggerPosition(&ae.getNextActuatorEvent()->position, 51 + 180 - 175 PASS_ENGINE_PARAMETER); assertEquals(2, ae.events[0].position.eventIndex); assertEquals(112.3495, ae.events[0].position.angleOffset); }
void testFuelMap(void) { printf("*************************************************** testFuelMap\r\n"); EngineTestHelper eth(FORD_ASPIRE_1996); for (int k = 0; k < FUEL_LOAD_COUNT; k++) { for (int r = 0; r < FUEL_RPM_COUNT; r++) { eth.engine.engineConfiguration->fuelTable[k][r] = k * 200 + r; } } for (int i = 0; i < FUEL_LOAD_COUNT; i++) eth.engine.engineConfiguration->fuelLoadBins[i] = i; for (int i = 0; i < FUEL_RPM_COUNT; i++) eth.engine.engineConfiguration->fuelRpmBins[i] = i; assertEqualsM("base fuel table", 1005, getBaseTableFuel(eth.engine.engineConfiguration, 5, 5)); printf("*************************************************** initThermistors\r\n"); Engine *engine = ð.engine; engine_configuration_s *engineConfiguration = engine->engineConfiguration; initThermistors(engine); printf("*** getInjectorLag\r\n"); assertEquals(1.0, getInjectorLag(12 PASS_ENGINE_PARAMETER)); eth.engine.engineConfiguration->injectorLag = 0.5; for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) { eth.engine.engineConfiguration->battInjectorLagCorrBins[i] = i; eth.engine.engineConfiguration->battInjectorLagCorr[i] = 2 * i; } // because all the correction tables are zero printf("*************************************************** getRunningFuel 1\r\n"); float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F)); assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER)); printf("*************************************************** setting IAT table\r\n"); for (int i = 0; i < IAT_CURVE_SIZE; i++) { eth.engine.engineConfiguration->iatFuelCorrBins[i] = i; eth.engine.engineConfiguration->iatFuelCorr[i] = 2 * i; } eth.engine.engineConfiguration->iatFuelCorr[0] = 2; printf("*************************************************** setting CLT table\r\n"); for (int i = 0; i < CLT_CURVE_SIZE; i++) { eth.engine.engineConfiguration->cltFuelCorrBins[i] = i; eth.engine.engineConfiguration->cltFuelCorr[i] = 1; } eth.engine.engineConfiguration->injectorLag = 0; assertEquals(NAN, getIntakeAirTemperature(ð.engine)); float iatCorrection = getIatCorrection(-KELV PASS_ENGINE_PARAMETER); assertEqualsM("IAT", 2, iatCorrection); float cltCorrection = getCltCorrection(getCoolantTemperature(ð.engine) PASS_ENGINE_PARAMETER); assertEqualsM("CLT", 1, cltCorrection); float injectorLag = getInjectorLag(getVBatt(engineConfiguration) PASS_ENGINE_PARAMETER); assertEquals(0, injectorLag); testMafValue = 5; // 1005 * 2 for IAT correction printf("*************************************************** getRunningFuel 2\r\n"); baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F)); assertEqualsM("v1", 30150, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER)); testMafValue = 0; engineConfiguration->crankingSettings.baseCrankingFuel = 4; printf("*************************************************** getStartingFuel\r\n"); // NAN in case we have issues with the CLT sensor assertEqualsM("getStartingFuel nan", 4, getCrankingFuel3(engineConfiguration, NAN, 0)); assertEqualsM("getStartingFuel#1", 23.7333, getCrankingFuel3(engineConfiguration, 0, 4)); assertEqualsM("getStartingFuel#2", 18.0419, getCrankingFuel3(engineConfiguration, 8, 15)); assertEqualsM("getStartingFuel#3", 11.2000, getCrankingFuel3(engineConfiguration, 70, 0)); assertEqualsM("getStartingFuel#3", 5.6000, getCrankingFuel3(engineConfiguration, 70, 50)); }
int main(int argc, char* argv[], char* envp[]){ //silence warnings (void)envp; if(argc != 4){ printf("Wrong number of arguments. Usage %s <local port> <remote host> <remote port> \n", argv[0]); return 1; } int listenPort = atoi(argv[1]); //timing synchronization //apps will signal when they're all done pthread_mutex_init(&count_mutex, NULL); pthread_cond_init (&count_threshold_cv, NULL); struct timeval t1; struct timeval t2; // set up network ppETH eth(1, listenPort, argv[3], argv[2]); ppIP ip(2); ppTCP tcp(3); ppUDP udp(4); ppFTP ftp(5); ppTEL tel(6); ppRDP rdp(7); ppDNS dns(8); ftpAPP ftpApplication(5, true); telAPP telApplication(6, true); rdpAPP rdpApplication(7, true); dnsAPP dnsApplication(8, true); eth.registerHLP(ip); ip.registerHLP(tcp); ip.registerHLP(udp); tcp.registerHLP(ftp); tcp.registerHLP(tel); udp.registerHLP(rdp); udp.registerHLP(dns); dns.registerHLP(dnsApplication); ftp.registerHLP(ftpApplication); rdp.registerHLP(rdpApplication); tel.registerHLP(telApplication); ftp.registerLLP(tcp); tel.registerLLP(tcp); rdp.registerLLP(udp); dns.registerLLP(udp); tcp.registerLLP(ip); udp.registerLLP(ip); ip.registerLLP(eth); dnsApplication.registerLLP(dns); ftpApplication.registerLLP(ftp); rdpApplication.registerLLP(rdp); telApplication.registerLLP(tel); ip.start(); tcp.start(); udp.start(); ftp.start(); tel.start(); rdp.start(); dns.start(); //make sure everything is set before we start timing sleep(5); gettimeofday(&t1, NULL); // dnsApplication.startListen(); // ftpApplication.startListen(); // rdpApplication.startListen(); // telApplication.startListen(); dnsApplication.startApplication(); ftpApplication.startApplication(); rdpApplication.startApplication(); telApplication.startApplication(); //wait for apps to finish and then stop timing or whatever pthread_mutex_lock(&count_mutex); while (count<numApps*2) { pthread_cond_wait(&count_threshold_cv, &count_mutex); } pthread_mutex_unlock(&count_mutex); gettimeofday(&t2, NULL); printf("Listening on %d took %f ms\n", listenPort, diffms(t2,t1)); }
// get network interface info from file (should include all available interfaces) std::vector<std::map<std::string,std::string> > Responder::read_eth_info() { const std::string eth_file(_eth_file); std::vector<std::map<std::string,std::string> > eths; try { ifstream eth_info(eth_file.c_str()); if(!eth_info.is_open()){ return eths; } const int len = 256; char cline[len]; for(; !eth_info.eof() ;) { eth_info.getline(cline, len); std::string line(cline); if(line.find("## ETH Interface") != std::string::npos) { eth_info.getline(cline, len); std::string eth(cline); // cout << "interface=" << eth << endl; std::map<std::string,std::string> iface; iface["interface"] = eth; eths.push_back(iface); } const std::string ipstr("\tip "); if(line.find(ipstr) != std::string::npos) { std::string ip( line.replace(line.begin(), line.begin()+ipstr.length(), "") ); // cout << "ip=" << ip << endl; eths.back()["addr"] = ip; } const std::string macstr("\tmac "); if(line.find(macstr) != std::string::npos) { std::string mac( line.replace(line.begin(), line.begin()+macstr.length(), "") ); // cout << "mac=" << mac << endl; eths.back()["mac"] = mac; } const std::string vstr("\t\tvendor "); if(line.find(vstr) != std::string::npos) { std::string vendor( line.replace(line.begin(), line.begin()+vstr.length(), "") ); std::string vid( vendor.substr(0,6) ); vendor.replace(0, 7, ""); // cout << "id=" << vid << endl; // cout << "vendor=" << vendor << endl; eths.back()["vendor"] = vendor; eths.back()["vendor_id"] = vid; } const std::string dstr("\t\tdevice "); if(line.find(dstr) != std::string::npos) { std::string device( line.replace(line.begin(), line.begin()+dstr.length(), "") ); std::string did( device.substr(0,6) ); device.replace(0, 7, ""); // cout << "id=" << did << endl; // cout << "device=" << device << endl; eths.back()["device"] = device; eths.back()["device_id"] = did; } } } catch(...) { // nothing in yet } return eths; }
void switcher::on_nat_pkt(const byte_t *data, size_t size) { EthernetII eth(data, size); // nat_->nat_pkt(data, size); nat_->nat_in(eth); return; }
void testFuelMap(void) { chDbgCheck(engineConfiguration!=NULL, "engineConfiguration"); printf("*************************************************** testFuelMap\r\n"); for (int k = 0; k < FUEL_LOAD_COUNT; k++) { for (int r = 0; r < FUEL_RPM_COUNT; r++) { engineConfiguration->fuelTable[k][r] = k * 200 + r; } } printf("*************************************************** initThermistors\r\n"); initThermistors(); printf("*** getInjectorLag\r\n"); assertEquals(0, getInjectorLag(12)); for (int i = 0; i < FUEL_LOAD_COUNT; i++) engineConfiguration->fuelLoadBins[i] = i; for (int i = 0; i < FUEL_RPM_COUNT; i++) engineConfiguration->fuelRpmBins[i] = i; printf("*************************************************** prepareFuelMap\r\n"); assertEquals(1005, getBaseTableFuel(5, 5)); engineConfiguration->injectorLag = 0.5; for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) { engineConfiguration->battInjectorLagCorrBins[i] = i; engineConfiguration->battInjectorLagCorr[i] = 2 * i; } EngineTestHelper eth(FORD_ASPIRE_1996); // because all the correction tables are zero printf("*************************************************** getRunningFuel\r\n"); float baseFuel = getBaseTableFuel(5, getEngineLoadT(ð.engine)); assertEqualsM("value", 0.5, getRunningFuel(baseFuel, ð.engine, 5)); printf("*************************************************** setting IAT table\r\n"); for (int i = 0; i < IAT_CURVE_SIZE; i++) { engineConfiguration->iatFuelCorrBins[i] = i; engineConfiguration->iatFuelCorr[i] = 2 * i; } engineConfiguration->iatFuelCorr[0] = 2; printf("*************************************************** setting CLT table\r\n"); for (int i = 0; i < CLT_CURVE_SIZE; i++) { engineConfiguration->cltFuelCorrBins[i] = i; engineConfiguration->cltFuelCorr[i] = 1; } engineConfiguration->injectorLag = 0; assertEquals(NAN, getIntakeAirTemperature()); float iatCorrection = getIatCorrection(-KELV); assertEqualsM("IAT", 2, iatCorrection); float cltCorrection = getCltCorrection(getCoolantTemperature()); assertEqualsM("CLT", 1, cltCorrection); float injectorLag = getInjectorLag(getVBatt()); assertEquals(0, injectorLag); testMafValue = 5; // 1005 * 2 for IAT correction printf("*************************************************** getRunningFuel\r\n"); baseFuel = getBaseTableFuel(5, getEngineLoadT(ð.engine)); assertEqualsM("v1", 30150, getRunningFuel(baseFuel, ð.engine, 5)); testMafValue = 0; engineConfiguration->crankingSettings.coolantTempMaxC = 65; // 8ms at 65C engineConfiguration->crankingSettings.fuelAtMaxTempMs = 8; engineConfiguration->crankingSettings.coolantTempMinC = 0; // 20ms at 0C engineConfiguration->crankingSettings.fuelAtMinTempMs = 20; printf("*************************************************** getStartingFuel\r\n"); // NAN in case we have issues with the CLT sensor // assertEquals(16, getStartingFuel(NAN)); assertEquals(20, getStartingFuel(0)); assertEquals(18.5231, getStartingFuel(8)); assertEquals(8, getStartingFuel(70)); }