diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 868b6e57c1..b69bc2c17d 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -299,14 +299,15 @@ void hwHandleVvtCamSignal(bool isRising, efitick_t nowNt, int index) { } switch(engineConfiguration->vvtMode[camIndex]) { - case VVT_2JZ: - // we do not know if we are in sync or out of sync, so we have to be looking for both possibilities - if ((currentPosition < engineConfiguration->scriptSetting[4] || currentPosition > engineConfiguration->scriptSetting[5]) && - (currentPosition < engineConfiguration->scriptSetting[4] + 360 || currentPosition > engineConfiguration->scriptSetting[5] + 360)) { - // outside of the expected range + case VVT_2JZ: { + // Consider the tooth in the first 1/3 of the engine phase + bool inRange = angleFromPrimarySyncPoint > 0 && angleFromPrimarySyncPoint < (720 / 3); + + if (!inRange) { return; } - break; + + } break; default: // else, do nothing break; diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 6c241e6b8a..0fa986c2ef 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -20,6 +20,7 @@ TESTS_SRC_CPP = \ tests/trigger/test_real_gm_24x.cpp \ tests/trigger/test_real_k24a2.cpp \ tests/trigger/test_real_k20.cpp \ + tests/trigger/test_real_toyota_3_tooth_cam.cpp \ tests/trigger/test_map_cam.cpp \ tests/trigger/test_rpm_multiplier.cpp \ tests/trigger/test_quad_cam.cpp \ diff --git a/unit_tests/tests/trigger/resources/toyota_3_tooth_cam.csv b/unit_tests/tests/trigger/resources/toyota_3_tooth_cam.csv new file mode 100755 index 0000000000..8ebc228354 --- /dev/null +++ b/unit_tests/tests/trigger/resources/toyota_3_tooth_cam.csv @@ -0,0 +1,1582 @@ +Time [s],Channel 0,Channel 1 +0.000000000,1,1 +0.000141125,0,1 +0.000607312,1,1 +0.001202250,0,1 +0.001666813,1,1 +0.002259438,0,1 +0.002723562,1,1 +0.003315750,0,1 +0.003780812,1,1 +0.004373625,0,1 +0.004838125,1,1 +0.005431813,0,1 +0.005896188,1,1 +0.006489687,0,1 +0.006954687,1,1 +0.007547062,0,1 +0.008011125,1,1 +0.008604063,0,1 +0.009067313,1,1 +0.009661250,0,1 +0.010123875,1,1 +0.010715562,0,1 +0.011182375,1,1 +0.011774625,0,1 +0.012236750,1,1 +0.012828625,0,1 +0.013293875,1,1 +0.013885563,0,1 +0.014209688,0,0 +0.014349437,1,0 +0.014940125,0,0 +0.015404312,1,0 +0.015996063,0,0 +0.016460000,1,0 +0.017052125,0,0 +0.017516125,1,0 +0.018107625,0,0 +0.018571687,1,0 +0.019164062,0,0 +0.019206938,0,1 +0.019624563,1,1 +0.020214000,0,1 +0.020923687,1,1 +0.023301250,0,1 +0.023861375,1,1 +0.024439250,0,1 +0.024892062,1,1 +0.025481062,0,1 +0.025943937,1,1 +0.026531063,0,1 +0.026993125,1,1 +0.027581250,0,1 +0.028044750,1,1 +0.028633375,0,1 +0.029096500,1,1 +0.029685562,0,1 +0.030148062,1,1 +0.030736438,0,1 +0.031199500,1,1 +0.031788562,0,1 +0.032251812,1,1 +0.032840688,0,1 +0.033303000,1,1 +0.033893375,0,1 +0.034353625,1,1 +0.034941437,0,1 +0.035404813,1,1 +0.035992562,0,1 +0.036453625,1,1 +0.037041625,0,1 +0.037503312,1,1 +0.038091813,0,1 +0.038554250,1,1 +0.039144563,0,1 +0.039605562,1,1 +0.039626812,1,0 +0.040194000,0,0 +0.040654875,1,0 +0.041242125,0,0 +0.041703188,1,0 +0.042290812,0,0 +0.042751625,1,0 +0.043341000,0,0 +0.043801063,1,0 +0.044389937,0,0 +0.044489687,0,1 +0.044852000,1,1 +0.045440250,0,1 +0.045901188,1,1 +0.046490562,0,1 +0.046950125,1,1 +0.047539687,0,1 +0.047999313,1,1 +0.048586312,0,1 +0.049049438,1,1 +0.049636687,0,1 +0.050094937,1,1 +0.050681938,0,1 +0.051143125,1,1 +0.051730500,0,1 +0.052190500,1,1 +0.052776562,0,1 +0.053236625,1,1 +0.053824062,0,1 +0.054283750,1,1 +0.054871938,0,1 +0.055332625,1,1 +0.055919062,0,1 +0.056380125,1,1 +0.056967188,0,1 +0.057424375,1,1 +0.058009687,0,1 +0.058716250,1,1 +0.061074625,0,1 +0.061631063,1,1 +0.062204750,0,1 +0.062654750,1,1 +0.063239125,0,1 +0.063699312,1,1 +0.064282563,0,1 +0.064602375,0,0 +0.064741437,1,0 +0.065326250,0,0 +0.065786375,1,0 +0.066371687,0,0 +0.066831313,1,0 +0.067416875,0,0 +0.067875937,1,0 +0.068460625,0,0 +0.068920187,1,0 +0.069504750,0,0 +0.069577562,0,1 +0.069965125,1,1 +0.070549250,0,1 +0.071008437,1,1 +0.071594125,0,1 +0.072051000,1,1 +0.072634562,0,1 +0.073093500,1,1 +0.073677125,0,1 +0.074134312,1,1 +0.074716937,0,1 +0.075175500,1,1 +0.075758937,0,1 +0.076216563,1,1 +0.076801000,0,1 +0.077256875,1,1 +0.077839250,0,1 +0.078294500,1,1 +0.078876500,0,1 +0.079332875,1,1 +0.079915625,0,1 +0.080371750,1,1 +0.080955375,0,1 +0.081411250,1,1 +0.081994375,0,1 +0.082451563,1,1 +0.083034625,0,1 +0.083490812,1,1 +0.084074438,0,1 +0.084529875,1,1 +0.085113563,0,1 +0.085568937,1,1 +0.086150625,0,1 +0.086610250,1,1 +0.087192750,0,1 +0.087646813,1,1 +0.088228562,0,1 +0.088686187,1,1 +0.089268500,0,1 +0.089575688,0,0 +0.089725125,1,0 +0.090306375,0,0 +0.090763063,1,0 +0.091345750,0,0 +0.091801437,1,0 +0.092384375,0,0 +0.092840625,1,0 +0.093421688,0,0 +0.093879062,1,0 +0.094460750,0,0 +0.094509563,0,1 +0.094914062,1,1 +0.095493438,0,1 +0.096197688,1,1 +0.098529063,0,1 +0.099080625,1,1 +0.099648250,0,1 +0.100093500,1,1 +0.100672813,0,1 +0.101128000,1,1 +0.101705875,0,1 +0.102159562,1,1 +0.102738750,0,1 +0.103195063,1,1 +0.103774062,0,1 +0.104229875,1,1 +0.104809750,0,1 +0.105264812,1,1 +0.105844812,0,1 +0.106300875,1,1 +0.106880875,0,1 +0.107337750,1,1 +0.107918687,0,1 +0.108375625,1,1 +0.108958875,0,1 +0.109414438,1,1 +0.109995625,0,1 +0.110454563,1,1 +0.111038375,0,1 +0.111493187,1,1 +0.112076500,0,1 +0.112534875,1,1 +0.113119250,0,1 +0.113578062,1,1 +0.114164562,0,1 +0.114622813,1,1 +0.114638688,1,0 +0.115208563,0,0 +0.115666312,1,0 +0.116250188,0,0 +0.116708750,1,0 +0.117293687,0,0 +0.117751938,1,0 +0.118338875,0,0 +0.118797000,1,0 +0.119384062,0,0 +0.119480125,0,1 +0.119843937,1,1 +0.120430375,0,1 +0.120891187,1,1 +0.121479313,0,1 +0.121940625,1,1 +0.122529813,0,1 +0.122991813,1,1 +0.123581875,0,1 +0.124044062,1,1 +0.124634063,0,1 +0.125095500,1,1 +0.125686437,0,1 +0.126150062,1,1 +0.126741250,0,1 +0.127204812,1,1 +0.127794938,0,1 +0.128259375,1,1 +0.128851313,0,1 +0.129315375,1,1 +0.129907063,0,1 +0.130371750,1,1 +0.130963688,0,1 +0.131429187,1,1 +0.132022688,0,1 +0.132484750,1,1 +0.133076500,0,1 +0.133789938,1,1 +0.136185562,0,1 +0.136747375,1,1 +0.137331375,0,1 +0.137789187,1,1 +0.138384813,0,1 +0.138853375,1,1 +0.139448250,0,1 +0.139783375,0,0 +0.139916375,1,0 +0.140512500,0,0 +0.140982313,1,0 +0.141579563,0,0 +0.142049125,1,0 +0.142646937,0,0 +0.143115688,1,0 +0.143711937,0,0 +0.144181438,1,0 +0.144777125,0,0 +0.144870063,0,1 +0.145246188,1,1 +0.145840937,0,1 +0.146308125,1,1 +0.146904312,0,1 +0.147368375,1,1 +0.147961375,0,1 +0.148426312,1,1 +0.149020563,0,1 +0.149482875,1,1 +0.150073750,0,1 +0.150538813,1,1 +0.151129938,0,1 +0.151595062,1,1 +0.152188000,0,1 +0.152651250,1,1 +0.153242187,0,1 +0.153704687,1,1 +0.154296062,0,1 +0.154759750,1,1 +0.155351938,0,1 +0.155815000,1,1 +0.156407688,0,1 +0.156871062,1,1 +0.157463125,0,1 +0.157927625,1,1 +0.158519187,0,1 +0.158982812,1,1 +0.159575875,0,1 +0.160038563,1,1 +0.160631500,0,1 +0.161087625,1,1 +0.161685187,0,1 +0.162149625,1,1 +0.162740313,0,1 +0.163201500,1,1 +0.163791750,0,1 +0.164256812,1,1 +0.164847562,0,1 +0.165172812,0,0 +0.165311125,1,0 +0.165901437,0,0 +0.166365625,1,0 +0.166957562,0,0 +0.167421125,1,0 +0.168013625,0,0 +0.168477500,1,0 +0.169069063,0,0 +0.169534375,1,0 +0.170127438,0,0 +0.170167563,0,1 +0.170589625,1,1 +0.171180625,0,1 +0.171894375,1,1 +0.174288625,0,1 +0.174852125,1,1 +0.175436125,0,1 +0.175893375,1,1 +0.176488250,0,1 +0.176956562,1,1 +0.177550500,0,1 +0.178017875,1,1 +0.178614313,0,1 +0.179083562,1,1 +0.179680375,0,1 +0.180149250,1,1 +0.180745938,0,1 +0.181214188,1,1 +0.181810125,0,1 +0.182279688,1,1 +0.182876437,0,1 +0.183346375,1,1 +0.183943812,0,1 +0.184412875,1,1 +0.185013500,0,1 +0.185480687,1,1 +0.186078375,0,1 +0.186547125,1,1 +0.187146875,0,1 +0.187614562,1,1 +0.188212187,0,1 +0.188683000,1,1 +0.189282375,0,1 +0.189752750,1,1 +0.190353750,0,1 +0.190823375,1,1 +0.190854750,1,0 +0.191423813,0,0 +0.191893062,1,0 +0.192492125,0,0 +0.192962187,1,0 +0.193562062,0,0 +0.194032188,1,0 +0.194633937,0,0 +0.195103438,1,0 +0.195704938,0,0 +0.195804062,0,1 +0.196176625,1,1 +0.196777250,0,1 +0.197248687,1,1 +0.197851250,0,1 +0.198322875,1,1 +0.198927250,0,1 +0.199390938,1,1 +0.200002750,0,1 +0.200477125,1,1 +0.201081375,0,1 +0.201553375,1,1 +0.202157375,0,1 +0.202632438,1,1 +0.203237312,0,1 +0.203712063,1,1 +0.204315875,0,1 +0.204790438,1,1 +0.205397250,0,1 +0.205871688,1,1 +0.206478562,0,1 +0.206954063,1,1 +0.207560063,0,1 +0.208037250,1,1 +0.208644750,0,1 +0.209117812,1,1 +0.209723437,0,1 +0.210447625,1,1 +0.212903563,0,1 +0.213479375,1,1 +0.214077062,0,1 +0.214545000,1,1 +0.215153813,0,1 +0.215632750,1,1 +0.216241437,0,1 +0.216620563,0,0 +0.216719750,1,0 +0.217328938,0,0 +0.217809250,1,0 +0.218419250,0,0 +0.218899312,1,0 +0.219510062,0,0 +0.219989688,1,0 +0.220600500,0,0 +0.221081187,1,0 +0.221691937,0,0 +0.221774312,0,1 +0.222173437,1,1 +0.222784813,0,1 +0.223264625,1,1 +0.223879375,0,1 +0.224359063,1,1 +0.224972000,0,1 +0.225455812,1,1 +0.226068313,0,1 +0.226548250,1,1 +0.227161562,0,1 +0.227642687,1,1 +0.228258688,0,1 +0.228741375,1,1 +0.229357750,0,1 +0.229839375,1,1 +0.230453625,0,1 +0.230934813,1,1 +0.231550188,0,1 +0.232031938,1,1 +0.232647875,0,1 +0.233130125,1,1 +0.233747875,0,1 +0.234230688,1,1 +0.234848187,0,1 +0.235333375,1,1 +0.235951000,0,1 +0.236435312,1,1 +0.237055437,0,1 +0.237539438,1,1 +0.238159938,0,1 +0.238644750,1,1 +0.239265500,0,1 +0.239752000,1,1 +0.240372937,0,1 +0.240858938,1,1 +0.241479250,0,1 +0.241967688,1,1 +0.242590562,0,1 +0.243007438,0,0 +0.243077750,1,0 +0.243699063,0,0 +0.244187938,1,0 +0.244810688,0,0 +0.245299187,1,0 +0.245922375,0,0 +0.246410812,1,0 +0.247032500,0,0 +0.247521437,1,0 +0.248143562,0,0 +0.248180812,0,1 +0.248628563,1,1 +0.249248125,0,1 +0.249981813,1,1 +0.252484250,0,1 +0.253068125,1,1 +0.253673812,0,1 +0.254148312,1,1 +0.254763875,0,1 +0.255248750,1,1 +0.255864500,0,1 +0.256348438,1,1 +0.256965312,0,1 +0.257452000,1,1 +0.258069437,0,1 +0.258555188,1,1 +0.259173062,0,1 +0.259657937,1,1 +0.260275188,0,1 +0.260760188,1,1 +0.261376312,0,1 +0.261861187,1,1 +0.262475500,0,1 +0.262958125,1,1 +0.263574812,0,1 +0.264054063,1,1 +0.264666313,0,1 +0.265148750,1,1 +0.265759125,0,1 +0.266236937,1,1 +0.266848562,0,1 +0.267328375,1,1 +0.267942063,0,1 +0.268423000,1,1 +0.269036812,0,1 +0.269517125,1,1 +0.269575250,1,0 +0.270130188,0,0 +0.270610000,1,0 +0.271223375,0,0 +0.271703562,1,0 +0.272316375,0,0 +0.272796938,1,0 +0.273411187,0,0 +0.273891188,1,0 +0.274505438,0,0 +0.274608000,0,1 +0.274986813,1,1 +0.275598813,0,1 +0.276078625,1,1 +0.276691062,0,1 +0.277169438,1,1 +0.277781000,0,1 +0.278254125,1,1 +0.278868375,0,1 +0.279346688,1,1 +0.279955813,0,1 +0.280431750,1,1 +0.281040000,0,1 +0.281518125,1,1 +0.282127187,0,1 +0.282604750,1,1 +0.283213063,0,1 +0.283691062,1,1 +0.284301125,0,1 +0.284778750,1,1 +0.285389375,0,1 +0.285867375,1,1 +0.286475937,0,1 +0.286955813,1,1 +0.287565750,0,1 +0.288040813,1,1 +0.288648438,0,1 +0.289374313,1,1 +0.291824500,0,1 +0.292398375,1,1 +0.292992125,0,1 +0.293456812,1,1 +0.294061250,0,1 +0.294536438,1,1 +0.295140687,0,1 +0.295503500,0,0 +0.295615750,1,0 +0.296221063,0,0 +0.296698875,1,0 +0.297305563,0,0 +0.297783313,1,0 +0.298392125,0,0 +0.298868875,1,0 +0.299476813,0,0 +0.299954813,1,0 +0.300561937,0,0 +0.300655625,0,1 +0.301039438,1,1 +0.301645625,0,1 +0.302121375,1,1 +0.302728375,0,1 +0.303201813,1,1 +0.303806875,0,1 +0.304283187,1,1 +0.304888250,0,1 +0.305361250,1,1 +0.305964875,0,1 +0.306440250,1,1 +0.307044188,0,1 +0.307518687,1,1 +0.308124625,0,1 +0.308597250,1,1 +0.309201312,0,1 +0.309673313,1,1 +0.310276312,0,1 +0.310749312,1,1 +0.311352688,0,1 +0.311825000,1,1 +0.312429125,0,1 +0.312901188,1,1 +0.313505000,0,1 +0.313977687,1,1 +0.314580500,0,1 +0.315052687,1,1 +0.315655937,0,1 +0.316127687,1,1 +0.316731625,0,1 +0.317201625,1,1 +0.317803250,0,1 +0.318277500,1,1 +0.318879313,0,1 +0.319349125,1,1 +0.319950375,0,1 +0.320423375,1,1 +0.321024375,0,1 +0.321388375,0,0 +0.321496375,1,0 +0.322096500,0,0 +0.322568937,1,0 +0.323170875,0,0 +0.323641375,1,0 +0.324243312,0,0 +0.324714312,1,0 +0.325314312,0,0 +0.325787250,1,0 +0.326387563,0,0 +0.326437250,0,1 +0.326855813,1,1 +0.327454437,0,1 +0.328171188,1,1 +0.330588312,0,1 +0.331155625,1,1 +0.331742437,0,1 +0.332202000,1,1 +0.332800000,0,1 +0.333270000,1,1 +0.333866500,0,1 +0.334335375,1,1 +0.334932500,0,1 +0.335403625,1,1 +0.336000875,0,1 +0.336470563,1,1 +0.337069562,0,1 +0.337538625,1,1 +0.338136437,0,1 +0.338605938,1,1 +0.339202938,0,1 +0.339673250,1,1 +0.340270313,0,1 +0.340738875,1,1 +0.341337312,0,1 +0.341803625,1,1 +0.342399375,0,1 +0.342868438,1,1 +0.343465187,0,1 +0.343931312,1,1 +0.344526625,0,1 +0.344995250,1,1 +0.345590625,0,1 +0.346058688,1,1 +0.346656125,0,1 +0.347122812,1,1 +0.347177562,1,0 +0.347719125,0,0 +0.348185688,1,0 +0.348781125,0,0 +0.349247625,1,0 +0.349843000,0,0 +0.350310063,1,0 +0.350906687,0,0 +0.351372750,1,0 +0.351969188,0,0 +0.352076625,0,1 +0.352437063,1,1 +0.353032750,0,1 +0.353499125,1,1 +0.354095938,0,1 +0.354561875,1,1 +0.355158625,0,1 +0.355624312,1,1 +0.356218375,0,1 +0.356687375,1,1 +0.357281813,0,1 +0.357746375,1,1 +0.358340500,0,1 +0.358807375,1,1 +0.359401875,0,1 +0.359868187,1,1 +0.360461188,0,1 +0.360927125,1,1 +0.361521938,0,1 +0.361987750,1,1 +0.362582750,0,1 +0.363049062,1,1 +0.363642000,0,1 +0.364109000,1,1 +0.364703000,0,1 +0.365165813,1,1 +0.365758187,0,1 +0.366469125,1,1 +0.368858000,0,1 +0.369420062,1,1 +0.370000375,0,1 +0.370454938,1,1 +0.371046125,0,1 +0.371511250,1,1 +0.372101813,0,1 +0.372426000,0,0 +0.372565062,1,0 +0.373156563,0,0 +0.373621688,1,0 +0.374212687,0,0 +0.374677938,1,0 +0.375268938,0,0 +0.375733313,1,0 +0.376324312,0,0 +0.376788687,1,0 +0.377379688,0,0 +0.377470688,0,1 +0.377844125,1,1 +0.378434563,0,1 +0.378898125,1,1 +0.379489937,0,1 +0.379951250,1,1 +0.380540500,0,1 +0.381004312,1,1 +0.381593500,0,1 +0.382054813,1,1 +0.382643000,0,1 +0.383105937,1,1 +0.383694563,0,1 +0.384157812,1,1 +0.384747375,0,1 +0.385208000,1,1 +0.385796125,0,1 +0.386256312,1,1 +0.386844313,0,1 +0.387305187,1,1 +0.387893125,0,1 +0.388355125,1,1 +0.388944313,0,1 +0.389405250,1,1 +0.389994750,0,1 +0.390456812,1,1 +0.391046438,0,1 +0.391508062,1,1 +0.392097875,0,1 +0.392558313,1,1 +0.393148438,0,1 +0.393609500,1,1 +0.394197313,0,1 +0.394662250,1,1 +0.395251688,0,1 +0.395711250,1,1 +0.396299625,0,1 +0.396762000,1,1 +0.397351438,0,1 +0.397677187,0,0 +0.397813937,1,0 +0.398402437,0,0 +0.398864188,1,0 +0.399453563,0,0 +0.399914875,1,0 +0.400504437,0,0 +0.400966000,1,0 +0.401554062,0,0 +0.402016563,1,0 +0.402604813,0,0 +0.402649750,0,1 +0.403063500,1,1 +0.403649500,0,1 +0.404358563,1,1 +0.406718625,0,1 +0.407275875,1,1 +0.407849938,0,1 +0.408300125,1,1 +0.408884625,0,1 +0.409345313,1,1 +0.409928937,0,1 +0.410387563,1,1 +0.410972563,0,1 +0.411433687,1,1 +0.412018687,0,1 +0.412479312,1,1 +0.413065250,0,1 +0.413524563,1,1 +0.414109813,0,1 +0.414569688,1,1 +0.415154625,0,1 +0.415615125,1,1 +0.416199437,0,1 +0.416659563,1,1 +0.417245437,0,1 +0.417702562,1,1 +0.418286062,0,1 +0.418745437,1,1 +0.419329625,0,1 +0.419787000,1,1 +0.420371000,0,1 +0.420829875,1,1 +0.421414250,0,1 +0.421872625,1,1 +0.422458375,0,1 +0.422915563,1,1 +0.422928562,1,0 +0.423499750,0,0 +0.423957125,1,0 +0.424540937,0,0 +0.424998250,1,0 +0.425581000,0,0 +0.426039125,1,0 +0.426623688,0,0 +0.427080438,1,0 +0.427665187,0,0 +0.427767438,0,1 +0.428123250,1,1 +0.428707438,0,1 +0.429164750,1,1 +0.429749625,0,1 +0.430206000,1,1 +0.430790687,0,1 +0.431247250,1,1 +0.431828687,0,1 +0.432289313,1,1 +0.432872125,0,1 +0.433326938,1,1 +0.433909250,0,1 +0.434366750,1,1 +0.434948875,0,1 +0.435405875,1,1 +0.435987000,0,1 +0.436443812,1,1 +0.437027125,0,1 +0.437483000,1,1 +0.438067062,0,1 +0.438523125,1,1 +0.439105062,0,1 +0.439562625,1,1 +0.440144500,0,1 +0.440598687,1,1 +0.441178750,0,1 +0.441882625,1,1 +0.444217625,0,1 +0.444770375,1,1 +0.445338500,0,1 +0.445784438,1,1 +0.446365063,0,1 +0.446820312,1,1 +0.447399687,0,1 +0.447696125,0,0 +0.447853625,1,0 +0.448433750,0,0 +0.448889938,1,0 +0.449469438,0,0 +0.449926250,1,0 +0.450506813,0,0 +0.450962188,1,0 +0.451542563,0,0 +0.451998812,1,0 +0.452579687,0,0 +0.452671000,0,1 +0.453036500,1,1 +0.453617875,0,1 +0.454075625,1,1 +0.454658687,0,1 +0.455115063,1,1 +0.455697125,0,1 +0.456156250,1,1 +0.456740937,0,1 +0.457195750,1,1 +0.457778813,0,1 +0.458238313,1,1 +0.458822000,0,1 +0.459282000,1,1 +0.459867750,0,1 +0.460325750,1,1 +0.460910750,0,1 +0.461367625,1,1 +0.461953375,0,1 +0.462411313,1,1 +0.462997625,0,1 +0.463456563,1,1 +0.464043563,0,1 +0.464502187,1,1 +0.465089688,0,1 +0.465550562,1,1 +0.466138375,0,1 +0.466599812,1,1 +0.467187937,0,1 +0.467649938,1,1 +0.468239063,0,1 +0.468701313,1,1 +0.469292625,0,1 +0.469755188,1,1 +0.470346625,0,1 +0.470807875,1,1 +0.471399313,0,1 +0.471863750,1,1 +0.472455937,0,1 +0.472778437,0,0 +0.472920813,1,0 +0.473511937,0,0 +0.473976687,1,0 +0.474569500,0,0 +0.475033563,1,0 +0.475627062,0,0 +0.476091938,1,0 +0.476684375,0,0 +0.477149812,1,0 +0.477743125,0,0 +0.477789500,0,1 +0.478206187,1,1 +0.478797688,0,1 +0.479514312,1,1 +0.481910250,0,1 +0.482474000,1,1 +0.483058250,0,1 +0.483516125,1,1 +0.484112062,0,1 +0.484581125,1,1 +0.485176750,0,1 +0.485644813,1,1 +0.486242063,0,1 +0.486712500,1,1 +0.487310375,0,1 +0.487780812,1,1 +0.488379000,0,1 +0.488848000,1,1 +0.489445625,0,1 +0.489915250,1,1 +0.490512125,0,1 +0.490981813,1,1 +0.491578500,0,1 +0.492047687,1,1 +0.492644875,0,1 +0.493109937,1,1 +0.493704188,0,1 +0.494171625,1,1 +0.494764937,0,1 +0.495230000,1,1 +0.495822250,0,1 +0.496288187,1,1 +0.496880750,0,1 +0.497347250,1,1 +0.497942687,0,1 +0.498407437,1,1 +0.498435125,1,0 +0.499001812,0,0 +0.499465437,1,0 +0.500058625,0,0 +0.500523250,1,0 +0.501115938,0,0 +0.501581375,1,0 +0.502175750,0,0 +0.502639813,1,0 +0.503234500,0,0 +0.503338437,0,1 +0.503700438,1,1 +0.504294375,0,1 +0.504759625,1,1 +0.505353875,0,1 +0.505817500,1,1 +0.506411063,0,1 +0.506874562,1,1 +0.507464313,0,1 +0.507932250,1,1 +0.508523813,0,1 +0.508984750,1,1 +0.509576250,0,1 +0.510040438,1,1 +0.510632125,0,1 +0.511095750,1,1 +0.511685375,0,1 +0.512149750,1,1 +0.512742125,0,1 +0.513205750,1,1 +0.513798437,0,1 +0.514263187,1,1 +0.514855125,0,1 +0.515321563,1,1 +0.515915625,0,1 +0.516378875,1,1 +0.516972312,0,1 +0.517685813,1,1 +0.520084875,0,1 +0.520650500,1,1 +0.521235625,0,1 +0.521693750,1,1 +0.522290687,0,1 +0.522760125,1,1 +0.523356562,0,1 +0.523705562,0,0 +0.523824938,1,0 +0.524422125,0,0 +0.524893125,1,0 +0.525490313,0,0 +0.525960375,1,0 +0.526558312,0,0 +0.527027125,1,0 +0.527624375,0,0 +0.528093250,1,0 +0.528690750,0,0 +0.528775625,0,1 +0.529161000,1,1 +0.529758437,0,1 +0.530229250,1,1 +0.530828437,0,1 +0.531295875,1,1 +0.531894500,0,1 +0.532365813,1,1 +0.532966125,0,1 +0.533434813,1,1 +0.534033625,0,1 +0.534505125,1,1 +0.535104438,0,1 +0.535576000,1,1 +0.536177187,0,1 +0.536646687,1,1 +0.537246937,0,1 +0.537716063,1,1 +0.538316125,0,1 +0.538785938,1,1 +0.539386625,0,1 +0.539857750,1,1 +0.540459375,0,1 +0.540930313,1,1 +0.541533125,0,1 +0.542005750,1,1 +0.542608500,0,1 +0.543081062,1,1 +0.543685000,0,1 +0.544156562,1,1 +0.544760812,0,1 +0.545233688,1,1 +0.545835687,0,1 +0.546313000,1,1 +0.546918937,0,1 +0.547390812,1,1 +0.547997063,0,1 +0.548472813,1,1 +0.549078125,0,1 +0.549454750,0,0 +0.549554750,1,0 +0.550159813,0,0 +0.550635875,1,0 +0.551243875,0,0 +0.551718687,1,0 +0.552326813,0,0 +0.552802750,1,0 +0.553409313,0,0 +0.553887062,1,0 +0.554494438,0,0 +0.554526375,0,1 +0.554968875,1,1 +0.555575188,0,1 +0.556298437,1,1 +0.558759312,0,1 +0.559337125,1,1 +0.559936563,0,1 +0.560404438,1,1 +0.561014375,0,1 +0.561494750,1,1 +0.562103125,0,1 +0.562581500,1,1 +0.563192313,0,1 +0.563673938,1,1 +0.564285375,0,1 +0.564766250,1,1 +0.565378562,0,1 +0.565858688,1,1 +0.566470563,0,1 +0.566951750,1,1 +0.567564625,0,1 +0.568046375,1,1 +0.568658563,0,1 +0.569141125,1,1 +0.569755438,0,1 +0.570235250,1,1 +0.570848937,0,1 +0.571332188,1,1 +0.571948688,0,1 +0.572430125,1,1 +0.573042125,0,1 +0.573526000,1,1 +0.574141375,0,1 +0.574626063,1,1 +0.575244437,0,1 +0.575727500,1,1 +0.575799000,1,0 +0.576344562,0,0 +0.576826875,1,0 +0.577444000,0,0 +0.577927312,1,0 +0.578544063,0,0 +0.579028750,1,0 +0.579646438,0,0 +0.580129937,1,0 +0.580748687,0,0 +0.580843187,0,1 +0.581233500,1,1 +0.581852125,0,1 +0.582337813,1,1 +0.582956625,0,1 +0.583442812,1,1 +0.584064438,0,1 +0.584550438,1,1 +0.585173437,0,1 +0.585665187,1,1 +0.586280875,0,1 +0.586767875,1,1 +0.587390813,0,1 +0.587879250,1,1 +0.588501125,0,1 +0.588990688,1,1 +0.589611875,0,1 +0.590101312,1,1 +0.590724937,0,1 +0.591213500,1,1 +0.591838688,0,1 +0.592328562,1,1 +0.592951750,0,1 +0.593442250,1,1 +0.594066187,0,1 +0.594552250,1,1 +0.595175187,0,1 +0.595913187,1,1 +0.598436375,0,1 +0.599025625,1,1 +0.599633562,0,1 +0.600112250,1,1 +0.600733938,0,1 +0.601222750,1,1 +0.601843812,0,1 +0.602250938,0,0 +0.602331687,1,0 +0.602953813,0,0 +0.603444125,1,0 +0.604066125,0,0 +0.604555000,1,0 +0.605178250,0,0 +0.605666500,1,0 +0.606287875,0,0 +0.606777000,1,0 +0.607398125,0,0 +0.607494312,0,1 +0.607886438,1,1 +0.608506625,0,1 +0.608994438,1,1 +0.609615313,0,1 +0.610099687,1,1 +0.610717500,0,1 +0.611203750,1,1 +0.611823688,0,1 +0.612307750,1,1 +0.612921500,0,1 +0.613407438,1,1 +0.614024438,0,1 +0.614509688,1,1 +0.615127750,0,1 +0.615611750,1,1 +0.616230188,0,1 +0.616712813,1,1 +0.617330562,0,1 +0.617814813,1,1 +0.618432000,0,1 +0.618917000,1,1 +0.619536562,0,1 +0.620020187,1,1 +0.620639000,0,1 +0.621124312,1,1 +0.621741688,0,1 +0.622226250,1,1 +0.622842937,0,1 +0.623327188,1,1 +0.623945875,0,1 +0.624427875,1,1 +0.625045188,0,1 +0.625532563,1,1 +0.626140937,0,1 +0.626623625,1,1 +0.627239437,0,1 +0.627722875,1,1 +0.628337750,0,1 +0.628741062,0,0 +0.628820250,1,0 +0.629434313,0,0 +0.629917562,1,0 +0.630534250,0,0 +0.631016500,1,0 +0.631632375,0,0 +0.632114750,1,0 +0.632728687,0,0 +0.633212125,1,0 +0.633827438,0,0 +0.633876125,0,1 +0.634306625,1,1 +0.634918125,0,1 +0.635649625,1,1 +0.638115250,0,1 +0.638690688,1,1 +0.639286875,0,1 +0.639755875,1,1 +0.640364125,0,1 +0.640842937,1,1 +0.641450312,0,1 +0.641927875,1,1 +0.642537500,0,1 +0.643017188,1,1 +0.643626062,0,1 +0.644106625,1,1 +0.644715938,0,1 +0.645194250,1,1 +0.645804313,0,1 +0.646283250,1,1 +0.646893250,0,1 +0.647372437,1,1 +0.647981250,0,1 +0.648460000,1,1 +0.649069250,0,1 +0.649545062,1,1 +0.650152437,0,1 +0.650629500,1,1 +0.651236062,0,1 +0.651710500,1,1 +0.652316000,0,1 +0.652792000,1,1 +0.653397563,0,1 +0.653874687,1,1 +0.654483812,0,1 +0.654958562,1,1 +0.655002375,1,0 +0.655565562,0,0 +0.656039938,1,0 +0.656646687,0,0 +0.657121750,1,0 +0.657728438,0,0 +0.658204125,1,0 +0.658811438,0,0 +0.659287250,1,0 +0.659894937,0,0 +0.659998500,0,1 +0.660371375,1,1 +0.660978687,0,1 +0.661454250,1,1 +0.662062438,0,1 +0.662537313,1,1 +0.663145688,0,1 +0.663620563,1,1 +0.664225687,0,1 +0.664704063,1,1 +0.665310625,0,1 +0.665784313,1,1 +0.666390750,0,1 +0.666867563,1,1 +0.667475250,0,1 +0.667951000,1,1 +0.668555812,0,1 +0.669032437,1,1 +0.669638813,0,1 +0.670114063,1,1 +0.670721375,0,1 +0.671196875,1,1 +0.671802875,0,1 +0.672279312,1,1 +0.672884687,0,1 +0.673358313,1,1 +0.673961625,0,1 +0.674684125,1,1 +0.677126563,0,1 +0.677699687,1,1 +0.678292187,0,1 +0.678756625,1,1 +0.679359375,0,1 +0.679833937,1,1 +0.680437562,0,1 +0.680802250,0,0 +0.680910625,1,0 +0.681514188,0,0 +0.681989250,1,0 +0.682592437,0,0 +0.683068250,1,0 +0.683671500,0,0 +0.684145250,1,0 +0.684749063,0,0 +0.685223125,1,0 +0.685826750,0,0 +0.685919813,0,1 +0.686300812,1,1 +0.686903313,0,1 +0.687376937,1,1 +0.687980875,0,1 +0.688452063,1,1 +0.689054000,0,1 +0.689527375,1,1 +0.690129625,0,1 +0.690600437,1,1 +0.691201250,0,1 +0.691673688,1,1 +0.692274313,0,1 +0.692747438,1,1 +0.693348813,0,1 +0.693819250,1,1 +0.694420500,0,1 +0.694889625,1,1 +0.695490687,0,1 +0.695960625,1,1 +0.696561437,0,1 +0.697032312,1,1 +0.697633125,0,1 +0.698103313,1,1 +0.698704500,0,1 +0.699175625,1,1 +0.699776875,0,1 +0.700247000,1,1 +0.700848687,0,1 +0.701318688,1,1 +0.701920312,0,1 +0.702390188,1,1 +0.702988875,0,1 +0.703462062,1,1 +0.704062875,0,1 +0.704531062,1,1 +0.705131500,0,1 +0.705602313,1,1 +0.706202312,0,1 +0.706551938,0,0 +0.706673375,1,0 +0.707271625,0,0 +0.707742625,1,0 +0.708342438,0,0 +0.708812312,1,0 +0.709413000,0,0 +0.709882563,1,0 +0.710481125,0,0 +0.710952375,1,0 +0.711550875,0,0 +0.711601938,0,1 +0.712018250,1,1 +0.712614312,0,1 +0.713331375,1,1 +0.715736813,0,1 +0.716303187,1,1 +0.716887375,0,1 +0.717345750,1,1 +0.717940250,0,1 +0.718408687,1,1 +0.719003125,0,1 +0.719470000,1,1 +0.720066125,0,1 +0.720535000,1,1 +0.721130125,0,1 +0.721599250,1,1 +0.722194438,0,1 +0.722662250,1,1 +0.723257938,0,1 +0.723725562,1,1 +0.724320813,0,1 +0.724789375,1,1 +0.725384187,0,1 +0.725851812,1,1 +0.726448625,0,1 +0.726913188,1,1 +0.727507125,0,1 +0.727974375,1,1 +0.728567562,0,1 +0.729033313,1,1 +0.729626625,0,1 +0.730092625,1,1 +0.730686687,0,1 +0.731154063,1,1 +0.731749500,0,1 +0.732214500,1,1 +0.732245000,1,0 +0.732808687,0,0 +0.733273375,1,0 +0.733866687,0,0 +0.734332063,1,0 +0.734925188,0,0 +0.735390437,1,0 +0.735984813,0,0 +0.736449750,1,0 +0.737044313,0,0 +0.737146750,0,1 +0.737510125,1,1 +0.738104312,0,1 +0.738569062,1,1 +0.739163438,0,1 +0.739627562,1,1 +0.740221750,0,1 +0.740686437,1,1 +0.741277063,0,1 +0.741745312,1,1 +0.742338313,0,1 +0.742800812,1,1 +0.743394125,0,1 +0.743858750,1,1 +0.744451187,0,1 +0.744915187,1,1 +0.745505500,0,1 +0.745970937,1,1 +0.746563250,0,1 +0.747027375,1,1 +0.747620500,0,1 +0.748084625,1,1 +0.748676688,0,1 +0.749141500,1,1 +0.749734000,0,1 +0.750194937,1,1 +0.750784187,0,1 +0.751494250,1,1 +0.753872375,0,1 +0.754433313,1,1 +0.755011187,0,1 +0.755464750,1,1 +0.756054250,0,1 +0.756516875,1,1 +0.757105563,0,1 +0.757429875,0,0 +0.757566938,1,0 +0.758156375,0,0 +0.758619375,1,0 +0.759208250,0,0 +0.759672563,1,0 +0.760261562,0,0 +0.760724125,1,0 +0.761313250,0,0 +0.761775813,1,0 +0.762365250,0,0 +0.762452687,0,1 +0.762828125,1,1 +0.763416312,0,1 +0.763878313,1,1 +0.764467563,0,1 +0.764927812,1,1 +0.765514625,0,1 +0.765976813,1,1 +0.766563438,0,1 +0.767023375,1,1 +0.767610125,0,1 +0.768070687,1,1 +0.768657438,0,1 +0.769118750,1,1 +0.769706500,0,1 +0.770165813,1,1 +0.770752000,0,1 +0.771209812,1,1 +0.771795688,0,1 +0.772254688,1,1 +0.772841000,0,1 +0.773300500,1,1 +0.773886562,0,1 +0.774346437,1,1 +0.774933375,0,1 +0.775393312,1,1 +0.775980500,0,1 +0.776439750,1,1 +0.777027687,0,1 +0.777485688,1,1 +0.778073750,0,1 +0.778531938,1,1 +0.779116062,0,1 +0.779580125,1,1 +0.780166687,0,1 +0.780623938,1,1 +0.781209500,0,1 +0.781670000,1,1 +0.782256250,0,1 +0.782563375,0,0 +0.782715875,1,0 +0.783301062,0,0 +0.783762188,1,0 +0.784348625,0,0 +0.784807313,1,0 +0.785394125,0,0 +0.785852875,1,0 +0.786438500,0,0 +0.786897938,1,0 +0.787483687,0,0 +0.787534188,0,1 +0.787940312,1,1 +0.788522063,0,1 +0.789228250,1,1 +0.791573938,0,1 +0.792129125,1,1 +0.792699625,0,1 +0.793147250,1,1 +0.793729125,0,1 +0.794186500,1,1 +0.794767312,0,1 +0.795223563,1,1 +0.795805063,0,1 +0.796263750,1,1 +0.796845375,0,1 +0.797303937,1,1 +0.797886375,0,1 +0.798343375,1,1 +0.798925750,0,1 +0.799383125,1,1 +0.799965625,0,1 +0.800423375,1,1 +0.801005375,0,1 +0.801462563,1,1 +0.802045875,0,1 +0.802500375,1,1 +0.803080875,0,1 +0.803538000,1,1 +0.804119000,0,1 +0.804574125,1,1 +0.805154812,0,1 +0.805611375,1,1 +0.806191312,0,1 +0.806648188,1,1 +0.807230500,0,1 +0.807683313,0,0 +0.807685500,1,0 +0.808266687,0,0 +0.808721250,1,0 +0.809302375,0,0 +0.809756625,1,0 +0.810337813,0,0 +0.810792562,1,0 +0.811374250,0,0 +0.811829250,1,0 +0.812410562,0,0 +0.812506750,0,1 +0.812866500,1,1 +0.813448000,0,1 +0.813903250,1,1 +0.814485500,0,1 +0.814939813,1,1 +0.815521375,0,1 +0.815975688,1,1 +0.816554875,0,1 +0.817012688,1,1 +0.817593750,0,1 +0.818046188,1,1 +0.818626813,0,1 +0.819081938,1,1 +0.819662250,0,1 +0.820116313,1,1 +0.820694750,0,1 +0.821149500,1,1 +0.821729438,0,1 +0.822183625,1,1 +0.822764625,0,1 +0.823218937,1,1 +0.823797875,0,1 +0.824253438,1,1 +0.824832750,0,1 +0.825284812,1,1 +0.825861875,0,1 +0.826563875,1,1 +0.828888125,0,1 +0.829438250,1,1 +0.830004312,0,1 +0.830448750,1,1 +0.831026125,0,1 +0.831479750,1,1 +0.832055813,0,1 +0.832354313,0,0 +0.832508187,1,0 +0.833085938,0,0 +0.833540687,1,0 +0.834117563,0,0 +0.834572312,1,0 +0.835149438,0,0 +0.835603813,1,0 +0.836181562,0,0 +0.836635625,1,0 +0.837214375,0,0 +0.837301750,0,1 +0.837669000,1,1 +0.838247938,0,1 +0.838703375,1,1 +0.839284062,0,1 +0.839738625,1,1 +0.840318187,0,1 +0.840775250,1,1 +0.841357250,0,1 +0.841809937,1,1 +0.842391062,0,1 +0.842847812,1,1 +0.843429312,0,1 +0.843887250,1,1 +0.844469750,0,1 +0.844926875,1,1 +0.845508875,0,1 +0.845963750,1,1 +0.846547250,0,1 +0.847002937,1,1 +0.847586437,0,1 +0.848043563,1,1 +0.848628375,0,1 +0.849085187,1,1 +0.849670062,0,1 +0.850128750,1,1 +0.850714312,0,1 +0.851173500,1,1 +0.851759188,0,1 +0.851968000,0,1 diff --git a/unit_tests/tests/trigger/test_real_toyota_3_tooth_cam.cpp b/unit_tests/tests/trigger/test_real_toyota_3_tooth_cam.cpp new file mode 100644 index 0000000000..fdbb1007ed --- /dev/null +++ b/unit_tests/tests/trigger/test_real_toyota_3_tooth_cam.cpp @@ -0,0 +1,42 @@ +#include "pch.h" +#include "logicdata_csv_reader.h" + +TEST(realToyota3ToothCam, running) { + CsvReader reader(1, /* vvtCount */ 1); + + reader.open("tests/trigger/resources/toyota_3_tooth_cam.csv"); + EngineTestHelper eth(engine_type_e::TEST_ENGINE); + engineConfiguration->isFasterEngineSpinUpEnabled = true; + engineConfiguration->alwaysInstantRpm = true; + + engineConfiguration->vvtMode[0] = VVT_2JZ; + engineConfiguration->vvtOffsets[0] = 152.583f; + + engineConfiguration->trigger.customTotalToothCount = 36; + engineConfiguration->trigger.customSkippedToothCount = 2; + eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL); + + bool hasSeenFirstVvt = false; + + while (reader.haveMore()) { + reader.processLine(ð); + float vvt1 = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); + + if (vvt1 != 0) { + if (!hasSeenFirstVvt) { + EXPECT_NEAR(vvt1, 0, /*precision*/1); + hasSeenFirstVvt = true; + } + + // cam position should never be reported outside of correct range + EXPECT_TRUE(vvt1 > -3 && vvt1 < 3); + } + } + + EXPECT_NEAR(engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0), 0, 1); + ASSERT_EQ(3078, round(Sensor::getOrZero(SensorType::Rpm))); + + // TODO: why warnings? + ASSERT_EQ(1, eth.recentWarnings()->getCount()); + ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(0).Code); +}