2
0

v18_tests.c 343 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995
  1. /*
  2. * SpanDSP - a series of DSP components for telephony
  3. *
  4. * v18_tests.c
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. *
  8. * Copyright (C) 2004-2009 Steve Underwood
  9. *
  10. * All rights reserved.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2, as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. /*! \page v18_tests_page V.18 tests
  26. \section v18_tests_page_sec_1 What does it do?
  27. */
  28. #if defined(HAVE_CONFIG_H)
  29. #include "config.h"
  30. #endif
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <fcntl.h>
  34. #include <unistd.h>
  35. #include <string.h>
  36. #include <sndfile.h>
  37. #include "spandsp.h"
  38. #include "spandsp-sim.h"
  39. #define OUTPUT_FILE_NAME "v18.wav"
  40. #define SAMPLES_PER_CHUNK 160
  41. #define CHUNKS_PER_SECOND 50
  42. #define TESTER 0
  43. #define TUT 1
  44. int log_audio = false;
  45. SNDFILE *outhandle = NULL;
  46. char result[2][1024];
  47. int unexpected_echo = false;
  48. char *decode_test_file = NULL;
  49. int good_message_received;
  50. both_ways_line_model_state_t *model;
  51. int rbs_pattern = 0;
  52. int line_model_no = 0;
  53. #if 0
  54. float echo_level_cpe1 = -15.0f;
  55. float echo_level_co1 = -15.0f;
  56. float echo_level_cpe2 = -15.0f;
  57. float echo_level_co2 = -15.0f;
  58. #else
  59. float echo_level_cpe1 = -99.0f;
  60. float echo_level_co1 = -99.0f;
  61. float echo_level_cpe2 = -99.0f;
  62. float echo_level_co2 = -99.0f;
  63. #endif
  64. float noise_level = -70.0f;
  65. int channel_codec = MUNGE_CODEC_NONE;
  66. v18_state_t *v18[2];
  67. const char *qbf_tx = "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()'";
  68. const char *qbf_rx = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789!X$$/'+.()'";
  69. const char *full_baudot_rx =
  70. "\b \n\n\n\r?\n\n\n !\"$$/+'().+,-./"
  71. "0123456789:;(=)?"
  72. "XABCDEFGHIJKLMNOPQRSTUVWXYZ(/)' "
  73. "'ABCDEFGHIJKLMNOPQRSTUVWXYZ(!) ";
  74. static void put_text_msg(void *user_data, const uint8_t *msg, int len)
  75. {
  76. if (strcmp((const char *) msg, qbf_rx))
  77. {
  78. printf("Result:\n%s\n", msg);
  79. printf("Reference result:\n%s\n", qbf_rx);
  80. }
  81. else
  82. {
  83. good_message_received = true;
  84. }
  85. }
  86. /*- End of function --------------------------------------------------------*/
  87. static void basic_tests(int mode)
  88. {
  89. logging_state_t *logging;
  90. int16_t amp[2][SAMPLES_PER_CHUNK];
  91. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  92. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  93. int outframes;
  94. int samples;
  95. int push;
  96. int i;
  97. int j;
  98. printf("Testing %s\n", v18_mode_to_str(mode));
  99. v18[TESTER] = v18_init(NULL, true, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  100. logging = v18_get_logging_state(v18[TESTER]);
  101. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  102. span_log_set_tag(logging, "Tester");
  103. v18[TUT] = v18_init(NULL, false, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  104. logging = v18_get_logging_state(v18[TUT]);
  105. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  106. span_log_set_tag(logging, "TUT");
  107. if ((model = both_ways_line_model_init(line_model_no,
  108. noise_level,
  109. echo_level_cpe1,
  110. echo_level_co1,
  111. line_model_no,
  112. noise_level,
  113. echo_level_cpe2,
  114. echo_level_co2,
  115. channel_codec,
  116. rbs_pattern)) == NULL)
  117. {
  118. fprintf(stderr, " Failed to create line model\n");
  119. exit(2);
  120. }
  121. /* Fake an OK condition for the first message test */
  122. good_message_received = true;
  123. push = 0;
  124. if (v18_put(v18[TESTER], qbf_tx, -1) != strlen(qbf_tx))
  125. {
  126. printf("V.18 put failed\n");
  127. exit(2);
  128. }
  129. result[TESTER][0] =
  130. result[TUT][0] = '\0';
  131. for (i = 0; i < 10000; i++)
  132. {
  133. if (push == 0)
  134. {
  135. if ((samples = v18_tx(v18[TESTER], amp[0], SAMPLES_PER_CHUNK)) == 0)
  136. push = 10;
  137. }
  138. else
  139. {
  140. samples = 0;
  141. /* Push a little silence through, to flush things out */
  142. if (--push == 0)
  143. {
  144. if (!good_message_received)
  145. {
  146. printf("No message received\n");
  147. exit(2);
  148. }
  149. good_message_received = false;
  150. if (v18_put(v18[TESTER], qbf_tx, -1) != strlen(qbf_tx))
  151. {
  152. printf("V.18 put failed\n");
  153. exit(2);
  154. }
  155. }
  156. }
  157. if (samples < SAMPLES_PER_CHUNK)
  158. {
  159. vec_zeroi16(&amp[0][samples], SAMPLES_PER_CHUNK - samples);
  160. samples = SAMPLES_PER_CHUNK;
  161. }
  162. if ((samples = v18_tx(v18[TUT], amp[1], SAMPLES_PER_CHUNK)) == 0)
  163. push = 10;
  164. if (samples < SAMPLES_PER_CHUNK)
  165. {
  166. vec_zeroi16(&amp[1][samples], SAMPLES_PER_CHUNK - samples);
  167. samples = SAMPLES_PER_CHUNK;
  168. }
  169. if (log_audio)
  170. {
  171. for (j = 0; j < samples; j++)
  172. {
  173. out_amp[2*j + 0] = amp[0][j];
  174. out_amp[2*j + 1] = amp[1][j];
  175. }
  176. outframes = sf_writef_short(outhandle, out_amp, samples);
  177. if (outframes != samples)
  178. {
  179. fprintf(stderr, " Error writing audio file\n");
  180. exit(2);
  181. }
  182. }
  183. #if 1
  184. both_ways_line_model(model,
  185. model_amp[0],
  186. amp[0],
  187. model_amp[1],
  188. amp[1],
  189. samples);
  190. #else
  191. vec_copyi16(model_amp[0], amp[0], samples);
  192. vec_copyi16(model_amp[1], amp[1], samples);
  193. #endif
  194. v18_rx(v18[TESTER], model_amp[1], samples);
  195. v18_rx(v18[TUT], model_amp[0], samples);
  196. }
  197. v18_free(v18[TESTER]);
  198. v18_free(v18[TUT]);
  199. }
  200. /*- End of function --------------------------------------------------------*/
  201. static void misc_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
  202. {
  203. }
  204. /*- End of function --------------------------------------------------------*/
  205. static int test_misc_01(void)
  206. {
  207. logging_state_t *logging;
  208. int16_t amp[2][SAMPLES_PER_CHUNK];
  209. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  210. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  211. int outframes;
  212. int samples;
  213. int push;
  214. int i;
  215. int j;
  216. /*
  217. III.5.4.1.1 No disconnection test
  218. Purpose: To verify that the DCE does not initiate a disconnection.
  219. Preamble: N/A
  220. Method: A call is made to the TUT from the tester which remains off hook for 10 minutes
  221. without sending any signal.
  222. Pass criteria: The TUT should answer the call and enter the probing state after 3s. The
  223. TUT should continue to probe until the test is terminated.
  224. Comments: This feature should also be verified by observation during the automoding tests.
  225. */
  226. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_01_put_text_msg, (void *) (intptr_t) 0);
  227. logging = v18_get_logging_state(v18[TESTER]);
  228. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  229. span_log_set_tag(logging, "Tester");
  230. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_01_put_text_msg, (void *) (intptr_t) 1);
  231. logging = v18_get_logging_state(v18[TUT]);
  232. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  233. span_log_set_tag(logging, "TUT");
  234. if ((model = both_ways_line_model_init(line_model_no,
  235. noise_level,
  236. echo_level_cpe1,
  237. echo_level_co1,
  238. line_model_no,
  239. noise_level,
  240. echo_level_cpe2,
  241. echo_level_co2,
  242. channel_codec,
  243. rbs_pattern)) == NULL)
  244. {
  245. fprintf(stderr, " Failed to create line model\n");
  246. exit(2);
  247. }
  248. result[TESTER][0] =
  249. result[TUT][0] = '\0';
  250. for (i = 0; i < 10000; i++)
  251. {
  252. for (j = 0; j < 2; j++)
  253. {
  254. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  255. push = 10;
  256. if (samples < SAMPLES_PER_CHUNK)
  257. {
  258. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  259. samples = SAMPLES_PER_CHUNK;
  260. }
  261. }
  262. if (log_audio)
  263. {
  264. for (j = 0; j < samples; j++)
  265. {
  266. out_amp[2*j + 0] = amp[0][j];
  267. out_amp[2*j + 1] = amp[1][j];
  268. }
  269. outframes = sf_writef_short(outhandle, out_amp, samples);
  270. if (outframes != samples)
  271. {
  272. fprintf(stderr, " Error writing audio file\n");
  273. exit(2);
  274. }
  275. }
  276. #if 1
  277. both_ways_line_model(model,
  278. model_amp[0],
  279. amp[0],
  280. model_amp[1],
  281. amp[1],
  282. samples);
  283. #else
  284. vec_copyi16(model_amp[0], amp[0], samples);
  285. vec_copyi16(model_amp[1], amp[1], samples);
  286. #endif
  287. v18_rx(v18[TESTER], model_amp[1], samples);
  288. v18_rx(v18[TUT], model_amp[0], samples);
  289. }
  290. v18_free(v18[TESTER]);
  291. v18_free(v18[TUT]);
  292. printf("Test not yet implemented\n");
  293. return 1;
  294. }
  295. /*- End of function --------------------------------------------------------*/
  296. static void misc_02_put_text_msg(void *user_data, const uint8_t *msg, int len)
  297. {
  298. }
  299. /*- End of function --------------------------------------------------------*/
  300. static int test_misc_02(void)
  301. {
  302. logging_state_t *logging;
  303. int16_t amp[2][SAMPLES_PER_CHUNK];
  304. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  305. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  306. int outframes;
  307. int samples;
  308. int push;
  309. int i;
  310. int j;
  311. /*
  312. III.5.4.1.2 Automatic resumption of automoding
  313. Purpose: To ensure that the DCE can be configured to automatically re-assume the automode
  314. calling state after 10s of no valid signal.
  315. Preamble: The TUT should be configured to automatically re-assume the initial automoding
  316. state.
  317. Method: The tester should set up a call to the TUT in V.21 mode and then drop the carrier.
  318. The tester will then transmit silence for 11s followed by a 1300Hz tone for
  319. 5s (i.e. V.23).
  320. Pass criteria: 1) 10s after dropping the carrier the TUT should return to state Monitor 1.
  321. 2) After 2.7+-0.3s the TUT should select V.23 mode and send a 390Hz tone.
  322. Comments: The TUT should indicate that carrier has been lost at some time after the 1650Hz
  323. signal is lost.
  324. */
  325. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_02_put_text_msg, (void *) (intptr_t) 0);
  326. logging = v18_get_logging_state(v18[TESTER]);
  327. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  328. span_log_set_tag(logging, "Tester");
  329. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_02_put_text_msg, (void *) (intptr_t) 1);
  330. logging = v18_get_logging_state(v18[TUT]);
  331. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  332. span_log_set_tag(logging, "TUT");
  333. if ((model = both_ways_line_model_init(line_model_no,
  334. noise_level,
  335. echo_level_cpe1,
  336. echo_level_co1,
  337. line_model_no,
  338. noise_level,
  339. echo_level_cpe2,
  340. echo_level_co2,
  341. channel_codec,
  342. rbs_pattern)) == NULL)
  343. {
  344. fprintf(stderr, " Failed to create line model\n");
  345. exit(2);
  346. }
  347. result[TESTER][0] =
  348. result[TUT][0] = '\0';
  349. for (i = 0; i < 10000; i++)
  350. {
  351. for (j = 0; j < 2; j++)
  352. {
  353. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  354. push = 10;
  355. if (samples < SAMPLES_PER_CHUNK)
  356. {
  357. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  358. samples = SAMPLES_PER_CHUNK;
  359. }
  360. }
  361. if (log_audio)
  362. {
  363. for (j = 0; j < samples; j++)
  364. {
  365. out_amp[2*j + 0] = amp[0][j];
  366. out_amp[2*j + 1] = amp[1][j];
  367. }
  368. outframes = sf_writef_short(outhandle, out_amp, samples);
  369. if (outframes != samples)
  370. {
  371. fprintf(stderr, " Error writing audio file\n");
  372. exit(2);
  373. }
  374. }
  375. #if 1
  376. both_ways_line_model(model,
  377. model_amp[0],
  378. amp[0],
  379. model_amp[1],
  380. amp[1],
  381. samples);
  382. #else
  383. vec_copyi16(model_amp[0], amp[0], samples);
  384. vec_copyi16(model_amp[1], amp[1], samples);
  385. #endif
  386. v18_rx(v18[TESTER], model_amp[1], samples);
  387. v18_rx(v18[TUT], model_amp[0], samples);
  388. }
  389. v18_free(v18[TESTER]);
  390. v18_free(v18[TUT]);
  391. printf("Test not yet implemented\n");
  392. return 1;
  393. }
  394. /*- End of function --------------------------------------------------------*/
  395. static void misc_03_put_text_msg(void *user_data, const uint8_t *msg, int len)
  396. {
  397. }
  398. /*- End of function --------------------------------------------------------*/
  399. static int test_misc_03(void)
  400. {
  401. logging_state_t *logging;
  402. int16_t amp[2][SAMPLES_PER_CHUNK];
  403. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  404. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  405. int outframes;
  406. int samples;
  407. int push;
  408. int i;
  409. int j;
  410. /*
  411. III.5.4.1.3 Retention of selected mode on loss of signal
  412. Purpose: To ensure that the DCE stays in the selected transmission mode if it is not
  413. configured to automatically re-assume the initial automoding state.
  414. Preamble: The TUT should be configured to remain in the selected transmission mode when
  415. the carrier is lost.
  416. Method: The tester should set up a call to the TUT in V.21 mode, for example. It will drop
  417. the carrier for 9s and then re-start transmission of the same carrier for
  418. 1s followed by a short message.
  419. Pass criteria: The TUT should resume operation in V.21 mode and capture the entire test
  420. message.
  421. Comments: The TUT should indicate that carrier has been lost at some time after the carrier
  422. signal is removed and not disconnect.
  423. */
  424. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_03_put_text_msg, (void *) (intptr_t) 0);
  425. logging = v18_get_logging_state(v18[TESTER]);
  426. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  427. span_log_set_tag(logging, "Tester");
  428. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_03_put_text_msg, (void *) (intptr_t) 1);
  429. logging = v18_get_logging_state(v18[TUT]);
  430. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  431. span_log_set_tag(logging, "TUT");
  432. if ((model = both_ways_line_model_init(line_model_no,
  433. noise_level,
  434. echo_level_cpe1,
  435. echo_level_co1,
  436. line_model_no,
  437. noise_level,
  438. echo_level_cpe2,
  439. echo_level_co2,
  440. channel_codec,
  441. rbs_pattern)) == NULL)
  442. {
  443. fprintf(stderr, " Failed to create line model\n");
  444. exit(2);
  445. }
  446. result[TESTER][0] =
  447. result[TUT][0] = '\0';
  448. for (i = 0; i < 10000; i++)
  449. {
  450. for (j = 0; j < 2; j++)
  451. {
  452. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  453. push = 10;
  454. if (samples < SAMPLES_PER_CHUNK)
  455. {
  456. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  457. samples = SAMPLES_PER_CHUNK;
  458. }
  459. }
  460. if (log_audio)
  461. {
  462. for (j = 0; j < samples; j++)
  463. {
  464. out_amp[2*j + 0] = amp[0][j];
  465. out_amp[2*j + 1] = amp[1][j];
  466. }
  467. outframes = sf_writef_short(outhandle, out_amp, samples);
  468. if (outframes != samples)
  469. {
  470. fprintf(stderr, " Error writing audio file\n");
  471. exit(2);
  472. }
  473. }
  474. #if 1
  475. both_ways_line_model(model,
  476. model_amp[0],
  477. amp[0],
  478. model_amp[1],
  479. amp[1],
  480. samples);
  481. #else
  482. vec_copyi16(model_amp[0], amp[0], samples);
  483. vec_copyi16(model_amp[1], amp[1], samples);
  484. #endif
  485. v18_rx(v18[TESTER], model_amp[1], samples);
  486. v18_rx(v18[TUT], model_amp[0], samples);
  487. }
  488. v18_free(v18[TESTER]);
  489. v18_free(v18[TUT]);
  490. printf("Test not yet implemented\n");
  491. return 1;
  492. }
  493. /*- End of function --------------------------------------------------------*/
  494. static void misc_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
  495. {
  496. }
  497. /*- End of function --------------------------------------------------------*/
  498. static int test_misc_04(void)
  499. {
  500. logging_state_t *logging;
  501. int16_t amp[2][SAMPLES_PER_CHUNK];
  502. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  503. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  504. int outframes;
  505. int samples;
  506. int push;
  507. int i;
  508. int j;
  509. /*
  510. III.5.4.1.4 Detection of BUSY tone
  511. Purpose: To ensure that the DCE provides the call progress indication "BUSY" in presence of
  512. the national busy tone.
  513. Preamble: N/A
  514. Method: The TUT should be configured to dial out and then be presented with the
  515. appropriate national busy tone.
  516. Pass criteria: Detection of busy tone should be displayed by the TUT.
  517. Comments: ITU-T V.18 specifies that the DCE should not hang up, but that is intended to apply
  518. to the case where a connection is established and then lost. A terminal may
  519. automatically hang up when busy tone is detected. PABX busy tones may differ in
  520. frequency and cadence from national parameters.
  521. */
  522. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_04_put_text_msg, (void *) (intptr_t) 0);
  523. logging = v18_get_logging_state(v18[TESTER]);
  524. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  525. span_log_set_tag(logging, "Tester");
  526. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_04_put_text_msg, (void *) (intptr_t) 1);
  527. logging = v18_get_logging_state(v18[TUT]);
  528. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  529. span_log_set_tag(logging, "TUT");
  530. if ((model = both_ways_line_model_init(line_model_no,
  531. noise_level,
  532. echo_level_cpe1,
  533. echo_level_co1,
  534. line_model_no,
  535. noise_level,
  536. echo_level_cpe2,
  537. echo_level_co2,
  538. channel_codec,
  539. rbs_pattern)) == NULL)
  540. {
  541. fprintf(stderr, " Failed to create line model\n");
  542. exit(2);
  543. }
  544. result[TESTER][0] =
  545. result[TUT][0] = '\0';
  546. for (i = 0; i < 10000; i++)
  547. {
  548. for (j = 0; j < 2; j++)
  549. {
  550. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  551. push = 10;
  552. if (samples < SAMPLES_PER_CHUNK)
  553. {
  554. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  555. samples = SAMPLES_PER_CHUNK;
  556. }
  557. }
  558. if (log_audio)
  559. {
  560. for (j = 0; j < samples; j++)
  561. {
  562. out_amp[2*j + 0] = amp[0][j];
  563. out_amp[2*j + 1] = amp[1][j];
  564. }
  565. outframes = sf_writef_short(outhandle, out_amp, samples);
  566. if (outframes != samples)
  567. {
  568. fprintf(stderr, " Error writing audio file\n");
  569. exit(2);
  570. }
  571. }
  572. #if 1
  573. both_ways_line_model(model,
  574. model_amp[0],
  575. amp[0],
  576. model_amp[1],
  577. amp[1],
  578. samples);
  579. #else
  580. vec_copyi16(model_amp[0], amp[0], samples);
  581. vec_copyi16(model_amp[1], amp[1], samples);
  582. #endif
  583. v18_rx(v18[TESTER], model_amp[1], samples);
  584. v18_rx(v18[TUT], model_amp[0], samples);
  585. }
  586. v18_free(v18[TESTER]);
  587. v18_free(v18[TUT]);
  588. printf("Test not yet implemented\n");
  589. return 1;
  590. }
  591. /*- End of function --------------------------------------------------------*/
  592. static void misc_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
  593. {
  594. }
  595. /*- End of function --------------------------------------------------------*/
  596. static int test_misc_05(void)
  597. {
  598. logging_state_t *logging;
  599. int16_t amp[2][SAMPLES_PER_CHUNK];
  600. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  601. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  602. int outframes;
  603. int samples;
  604. int push;
  605. int i;
  606. int j;
  607. /*
  608. III.5.4.1.5 Detection of RINGING
  609. Purpose: To ensure that the DCE provides the call progress indication "RINGING" in
  610. presence of the national ringing tone.
  611. Preamble: N/A
  612. Method: The tester will make a call to the TUT using the nationally recommended cadence
  613. and the minimum recommended ring voltage/current.
  614. Pass criteria: The RINGING condition should be visually indicated by the TUT.
  615. Comments: This test should be repeated across a range of valid timings and ring voltages.
  616. */
  617. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_05_put_text_msg, (void *) (intptr_t) 0);
  618. logging = v18_get_logging_state(v18[TESTER]);
  619. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  620. span_log_set_tag(logging, "Tester");
  621. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_05_put_text_msg, (void *) (intptr_t) 1);
  622. logging = v18_get_logging_state(v18[TUT]);
  623. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  624. span_log_set_tag(logging, "TUT");
  625. if ((model = both_ways_line_model_init(line_model_no,
  626. noise_level,
  627. echo_level_cpe1,
  628. echo_level_co1,
  629. line_model_no,
  630. noise_level,
  631. echo_level_cpe2,
  632. echo_level_co2,
  633. channel_codec,
  634. rbs_pattern)) == NULL)
  635. {
  636. fprintf(stderr, " Failed to create line model\n");
  637. exit(2);
  638. }
  639. result[TESTER][0] =
  640. result[TUT][0] = '\0';
  641. for (i = 0; i < 10000; i++)
  642. {
  643. for (j = 0; j < 2; j++)
  644. {
  645. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  646. push = 10;
  647. if (samples < SAMPLES_PER_CHUNK)
  648. {
  649. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  650. samples = SAMPLES_PER_CHUNK;
  651. }
  652. }
  653. if (log_audio)
  654. {
  655. for (j = 0; j < samples; j++)
  656. {
  657. out_amp[2*j + 0] = amp[0][j];
  658. out_amp[2*j + 1] = amp[1][j];
  659. }
  660. outframes = sf_writef_short(outhandle, out_amp, samples);
  661. if (outframes != samples)
  662. {
  663. fprintf(stderr, " Error writing audio file\n");
  664. exit(2);
  665. }
  666. }
  667. #if 1
  668. both_ways_line_model(model,
  669. model_amp[0],
  670. amp[0],
  671. model_amp[1],
  672. amp[1],
  673. samples);
  674. #else
  675. vec_copyi16(model_amp[0], amp[0], samples);
  676. vec_copyi16(model_amp[1], amp[1], samples);
  677. #endif
  678. v18_rx(v18[TESTER], model_amp[1], samples);
  679. v18_rx(v18[TUT], model_amp[0], samples);
  680. }
  681. v18_free(v18[TESTER]);
  682. v18_free(v18[TUT]);
  683. printf("Test not yet implemented\n");
  684. return 1;
  685. }
  686. /*- End of function --------------------------------------------------------*/
  687. static void misc_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
  688. {
  689. }
  690. /*- End of function --------------------------------------------------------*/
  691. static int test_misc_06(void)
  692. {
  693. logging_state_t *logging;
  694. int16_t amp[2][SAMPLES_PER_CHUNK];
  695. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  696. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  697. int outframes;
  698. int samples;
  699. int push;
  700. int i;
  701. int j;
  702. /*
  703. III.5.4.1.6 "LOSS OF CARRIER" indication
  704. Purpose: To ensure that the DCE provides the call progress indication "LOSS OF CARRIER"
  705. upon a loss of carrier in full duplex modes, i.e. V.21, V.23, Bell 103.
  706. Preamble: N/A
  707. Method: Set up a call in each of the full duplex modes and force a carrier failure to the TUT.
  708. Pass criteria: Loss of carrier should be indicated and disappear when the carrier is restored.
  709. Comments: The V.18 modem should not automatically disconnect when used in a manual
  710. conversation mode. However, a V.18 equipped terminal may disconnect based on
  711. operational decisions, e.g. when it is a terminal in automatic answering machine
  712. mode. There may be other cases, e.g. where the V.18 DCE is used in a gateway,
  713. when automatic disconnection is required.
  714. */
  715. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_06_put_text_msg, (void *) (intptr_t) 0);
  716. logging = v18_get_logging_state(v18[TESTER]);
  717. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  718. span_log_set_tag(logging, "Tester");
  719. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_06_put_text_msg, (void *) (intptr_t) 1);
  720. logging = v18_get_logging_state(v18[TUT]);
  721. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  722. span_log_set_tag(logging, "TUT");
  723. if ((model = both_ways_line_model_init(line_model_no,
  724. noise_level,
  725. echo_level_cpe1,
  726. echo_level_co1,
  727. line_model_no,
  728. noise_level,
  729. echo_level_cpe2,
  730. echo_level_co2,
  731. channel_codec,
  732. rbs_pattern)) == NULL)
  733. {
  734. fprintf(stderr, " Failed to create line model\n");
  735. exit(2);
  736. }
  737. result[TESTER][0] =
  738. result[TUT][0] = '\0';
  739. for (i = 0; i < 10000; i++)
  740. {
  741. for (j = 0; j < 2; j++)
  742. {
  743. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  744. push = 10;
  745. if (samples < SAMPLES_PER_CHUNK)
  746. {
  747. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  748. samples = SAMPLES_PER_CHUNK;
  749. }
  750. }
  751. if (log_audio)
  752. {
  753. for (j = 0; j < samples; j++)
  754. {
  755. out_amp[2*j + 0] = amp[0][j];
  756. out_amp[2*j + 1] = amp[1][j];
  757. }
  758. outframes = sf_writef_short(outhandle, out_amp, samples);
  759. if (outframes != samples)
  760. {
  761. fprintf(stderr, " Error writing audio file\n");
  762. exit(2);
  763. }
  764. }
  765. #if 1
  766. both_ways_line_model(model,
  767. model_amp[0],
  768. amp[0],
  769. model_amp[1],
  770. amp[1],
  771. samples);
  772. #else
  773. vec_copyi16(model_amp[0], amp[0], samples);
  774. vec_copyi16(model_amp[1], amp[1], samples);
  775. #endif
  776. v18_rx(v18[TESTER], model_amp[1], samples);
  777. v18_rx(v18[TUT], model_amp[0], samples);
  778. }
  779. v18_free(v18[TESTER]);
  780. v18_free(v18[TUT]);
  781. printf("Test not yet implemented\n");
  782. return 1;
  783. }
  784. /*- End of function --------------------------------------------------------*/
  785. static void misc_07_put_text_msg(void *user_data, const uint8_t *msg, int len)
  786. {
  787. }
  788. /*- End of function --------------------------------------------------------*/
  789. static int test_misc_07(void)
  790. {
  791. logging_state_t *logging;
  792. int16_t amp[2][SAMPLES_PER_CHUNK];
  793. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  794. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  795. int outframes;
  796. int samples;
  797. int push;
  798. int i;
  799. int j;
  800. /*
  801. III.5.4.1.7 Call progress indication
  802. Purpose: To ensure that the DCE provides the call progress indication "CONNECT(x)" upon
  803. a connection.
  804. Preamble: N/A
  805. Method: Correct CONNECT messages should be verified during the Automode tests that
  806. follow.
  807. Pass criteria: The relevant mode should be indicated by the DCE when automoding is complete.
  808. However, this may possibly not be indicated by the DTE.
  809. Comments: The possible modes are: V.21, V.23, Baudot 45, Baudot 50, EDT, Bell 103, DTMF.
  810. */
  811. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_07_put_text_msg, (void *) (intptr_t) 0);
  812. logging = v18_get_logging_state(v18[TESTER]);
  813. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  814. span_log_set_tag(logging, "Tester");
  815. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_07_put_text_msg, (void *) (intptr_t) 1);
  816. logging = v18_get_logging_state(v18[TUT]);
  817. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  818. span_log_set_tag(logging, "TUT");
  819. if ((model = both_ways_line_model_init(line_model_no,
  820. noise_level,
  821. echo_level_cpe1,
  822. echo_level_co1,
  823. line_model_no,
  824. noise_level,
  825. echo_level_cpe2,
  826. echo_level_co2,
  827. channel_codec,
  828. rbs_pattern)) == NULL)
  829. {
  830. fprintf(stderr, " Failed to create line model\n");
  831. exit(2);
  832. }
  833. result[TESTER][0] =
  834. result[TUT][0] = '\0';
  835. for (i = 0; i < 10000; i++)
  836. {
  837. for (j = 0; j < 2; j++)
  838. {
  839. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  840. push = 10;
  841. if (samples < SAMPLES_PER_CHUNK)
  842. {
  843. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  844. samples = SAMPLES_PER_CHUNK;
  845. }
  846. }
  847. if (log_audio)
  848. {
  849. for (j = 0; j < samples; j++)
  850. {
  851. out_amp[2*j + 0] = amp[0][j];
  852. out_amp[2*j + 1] = amp[1][j];
  853. }
  854. outframes = sf_writef_short(outhandle, out_amp, samples);
  855. if (outframes != samples)
  856. {
  857. fprintf(stderr, " Error writing audio file\n");
  858. exit(2);
  859. }
  860. }
  861. #if 1
  862. both_ways_line_model(model,
  863. model_amp[0],
  864. amp[0],
  865. model_amp[1],
  866. amp[1],
  867. samples);
  868. #else
  869. vec_copyi16(model_amp[0], amp[0], samples);
  870. vec_copyi16(model_amp[1], amp[1], samples);
  871. #endif
  872. v18_rx(v18[TESTER], model_amp[1], samples);
  873. v18_rx(v18[TUT], model_amp[0], samples);
  874. }
  875. v18_free(v18[TESTER]);
  876. v18_free(v18[TUT]);
  877. printf("Test not yet implemented\n");
  878. return 1;
  879. }
  880. /*- End of function --------------------------------------------------------*/
  881. static void misc_08_put_text_msg(void *user_data, const uint8_t *msg, int len)
  882. {
  883. }
  884. /*- End of function --------------------------------------------------------*/
  885. static int test_misc_08(void)
  886. {
  887. logging_state_t *logging;
  888. int16_t amp[2][SAMPLES_PER_CHUNK];
  889. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  890. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  891. int outframes;
  892. int samples;
  893. int push;
  894. int i;
  895. int j;
  896. /*
  897. III.5.4.1.8 Circuit 135 Test
  898. Purpose: To ensure that the DCE implements circuit 135 or an equivalent way of indicating
  899. presence of a signal.
  900. Preamble: N/A
  901. Method: A call from the TUT should be answered in voice mode after 20s. The tester
  902. will transmit sampled voice messages. V.24 circuit 135 or its equivalent should be
  903. observed.
  904. Pass criteria: The ring tone and speech shall be indicated by circuit 135.
  905. Comment: The response times and signal level thresholds of Circuit 135 are not specified in
  906. ITU-T V.18 or V.24 and therefore the pattern indicated may vary.
  907. */
  908. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_08_put_text_msg, (void *) (intptr_t) 0);
  909. logging = v18_get_logging_state(v18[TESTER]);
  910. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  911. span_log_set_tag(logging, "Tester");
  912. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_08_put_text_msg, (void *) (intptr_t) 1);
  913. logging = v18_get_logging_state(v18[TUT]);
  914. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  915. span_log_set_tag(logging, "TUT");
  916. if ((model = both_ways_line_model_init(line_model_no,
  917. noise_level,
  918. echo_level_cpe1,
  919. echo_level_co1,
  920. line_model_no,
  921. noise_level,
  922. echo_level_cpe2,
  923. echo_level_co2,
  924. channel_codec,
  925. rbs_pattern)) == NULL)
  926. {
  927. fprintf(stderr, " Failed to create line model\n");
  928. exit(2);
  929. }
  930. result[TESTER][0] =
  931. result[TUT][0] = '\0';
  932. for (i = 0; i < 10000; i++)
  933. {
  934. for (j = 0; j < 2; j++)
  935. {
  936. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  937. push = 10;
  938. if (samples < SAMPLES_PER_CHUNK)
  939. {
  940. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  941. samples = SAMPLES_PER_CHUNK;
  942. }
  943. }
  944. if (log_audio)
  945. {
  946. for (j = 0; j < samples; j++)
  947. {
  948. out_amp[2*j + 0] = amp[0][j];
  949. out_amp[2*j + 1] = amp[1][j];
  950. }
  951. outframes = sf_writef_short(outhandle, out_amp, samples);
  952. if (outframes != samples)
  953. {
  954. fprintf(stderr, " Error writing audio file\n");
  955. exit(2);
  956. }
  957. }
  958. #if 1
  959. both_ways_line_model(model,
  960. model_amp[0],
  961. amp[0],
  962. model_amp[1],
  963. amp[1],
  964. samples);
  965. #else
  966. vec_copyi16(model_amp[0], amp[0], samples);
  967. vec_copyi16(model_amp[1], amp[1], samples);
  968. #endif
  969. v18_rx(v18[TESTER], model_amp[1], samples);
  970. v18_rx(v18[TUT], model_amp[0], samples);
  971. }
  972. v18_free(v18[TESTER]);
  973. v18_free(v18[TUT]);
  974. printf("Test not yet implemented\n");
  975. return 1;
  976. }
  977. /*- End of function --------------------------------------------------------*/
  978. static void misc_09_put_text_msg(void *user_data, const uint8_t *msg, int len)
  979. {
  980. }
  981. /*- End of function --------------------------------------------------------*/
  982. static int test_misc_09(void)
  983. {
  984. logging_state_t *logging;
  985. int16_t amp[2][SAMPLES_PER_CHUNK];
  986. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  987. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  988. int outframes;
  989. int samples;
  990. int push;
  991. int i;
  992. int j;
  993. /*
  994. III.5.4.1.9 Connection procedures
  995. Purpose: To ensure that the TUT implements the call connect procedure described in
  996. clause 6.
  997. Preamble: N/A
  998. Method: TBD
  999. Pass criteria: TBD
  1000. Comment: TBD
  1001. */
  1002. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_09_put_text_msg, (void *) (intptr_t) 0);
  1003. logging = v18_get_logging_state(v18[TESTER]);
  1004. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1005. span_log_set_tag(logging, "Tester");
  1006. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, misc_09_put_text_msg, (void *) (intptr_t) 1);
  1007. logging = v18_get_logging_state(v18[TUT]);
  1008. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1009. span_log_set_tag(logging, "TUT");
  1010. if ((model = both_ways_line_model_init(line_model_no,
  1011. noise_level,
  1012. echo_level_cpe1,
  1013. echo_level_co1,
  1014. line_model_no,
  1015. noise_level,
  1016. echo_level_cpe2,
  1017. echo_level_co2,
  1018. channel_codec,
  1019. rbs_pattern)) == NULL)
  1020. {
  1021. fprintf(stderr, " Failed to create line model\n");
  1022. exit(2);
  1023. }
  1024. result[TESTER][0] =
  1025. result[TUT][0] = '\0';
  1026. for (i = 0; i < 10000; i++)
  1027. {
  1028. for (j = 0; j < 2; j++)
  1029. {
  1030. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1031. push = 10;
  1032. if (samples < SAMPLES_PER_CHUNK)
  1033. {
  1034. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1035. samples = SAMPLES_PER_CHUNK;
  1036. }
  1037. }
  1038. if (log_audio)
  1039. {
  1040. for (j = 0; j < samples; j++)
  1041. {
  1042. out_amp[2*j + 0] = amp[0][j];
  1043. out_amp[2*j + 1] = amp[1][j];
  1044. }
  1045. outframes = sf_writef_short(outhandle, out_amp, samples);
  1046. if (outframes != samples)
  1047. {
  1048. fprintf(stderr, " Error writing audio file\n");
  1049. exit(2);
  1050. }
  1051. }
  1052. #if 1
  1053. both_ways_line_model(model,
  1054. model_amp[0],
  1055. amp[0],
  1056. model_amp[1],
  1057. amp[1],
  1058. samples);
  1059. #else
  1060. vec_copyi16(model_amp[0], amp[0], samples);
  1061. vec_copyi16(model_amp[1], amp[1], samples);
  1062. #endif
  1063. v18_rx(v18[TESTER], model_amp[1], samples);
  1064. v18_rx(v18[TUT], model_amp[0], samples);
  1065. }
  1066. v18_free(v18[TESTER]);
  1067. v18_free(v18[TUT]);
  1068. printf("Test not yet implemented\n");
  1069. return 1;
  1070. }
  1071. /*- End of function --------------------------------------------------------*/
  1072. static void org_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1073. {
  1074. }
  1075. /*- End of function --------------------------------------------------------*/
  1076. static int test_org_01(void)
  1077. {
  1078. logging_state_t *logging;
  1079. int16_t amp[2][SAMPLES_PER_CHUNK];
  1080. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1081. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1082. int outframes;
  1083. int samples;
  1084. int push;
  1085. int i;
  1086. int j;
  1087. /*
  1088. III.5.4.2.1 CI and XCI signal coding and cadence
  1089. Purpose: To verify that TUT correctly emits the CI and XCI signals with the ON/OFF
  1090. cadence defined in 5.1.1.
  1091. Preamble: N/A
  1092. Method: V.21 demodulator is used to decode the CI sequence and a timer to measure the
  1093. silence intervals between them. The XCI signal is also monitored and decoded to
  1094. check for correct coding and timing of the signal.
  1095. Pass criteria: 1) No signal should be transmitted for one second after connecting to the line.
  1096. 2) Four CI patterns are transmitted for each repetition.
  1097. 3) No signal is transmitted for 2s after the end of each CI.
  1098. 4) Each CI must have the correct bit pattern.
  1099. 5) The CI patterns followed by 2s of silence must be repeated twice.
  1100. 6) One second after every 3 blocks CI an XCI signal must be transmitted.
  1101. 7) The XCI should have the structure defined in 3.11.
  1102. 8) The whole sequence should be repeated until the call is cleared.
  1103. 9) When V.18 to V.18, the XCI must not force V.23 or Minitel mode.
  1104. */
  1105. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_01_put_text_msg, (void *) (intptr_t) 0);
  1106. logging = v18_get_logging_state(v18[TESTER]);
  1107. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1108. span_log_set_tag(logging, "Tester");
  1109. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_01_put_text_msg, (void *) (intptr_t) 1);
  1110. logging = v18_get_logging_state(v18[TUT]);
  1111. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1112. span_log_set_tag(logging, "TUT");
  1113. if ((model = both_ways_line_model_init(line_model_no,
  1114. noise_level,
  1115. echo_level_cpe1,
  1116. echo_level_co1,
  1117. line_model_no,
  1118. noise_level,
  1119. echo_level_cpe2,
  1120. echo_level_co2,
  1121. channel_codec,
  1122. rbs_pattern)) == NULL)
  1123. {
  1124. fprintf(stderr, " Failed to create line model\n");
  1125. exit(2);
  1126. }
  1127. result[TESTER][0] =
  1128. result[TUT][0] = '\0';
  1129. for (i = 0; i < 10000; i++)
  1130. {
  1131. for (j = 0; j < 2; j++)
  1132. {
  1133. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1134. push = 10;
  1135. if (samples < SAMPLES_PER_CHUNK)
  1136. {
  1137. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1138. samples = SAMPLES_PER_CHUNK;
  1139. }
  1140. }
  1141. if (log_audio)
  1142. {
  1143. for (j = 0; j < samples; j++)
  1144. {
  1145. out_amp[2*j + 0] = amp[0][j];
  1146. out_amp[2*j + 1] = amp[1][j];
  1147. }
  1148. outframes = sf_writef_short(outhandle, out_amp, samples);
  1149. if (outframes != samples)
  1150. {
  1151. fprintf(stderr, " Error writing audio file\n");
  1152. exit(2);
  1153. }
  1154. }
  1155. #if 1
  1156. both_ways_line_model(model,
  1157. model_amp[0],
  1158. amp[0],
  1159. model_amp[1],
  1160. amp[1],
  1161. samples);
  1162. #else
  1163. vec_copyi16(model_amp[0], amp[0], samples);
  1164. vec_copyi16(model_amp[1], amp[1], samples);
  1165. #endif
  1166. v18_rx(v18[TESTER], model_amp[1], samples);
  1167. v18_rx(v18[TUT], model_amp[0], samples);
  1168. }
  1169. v18_free(v18[TESTER]);
  1170. v18_free(v18[TUT]);
  1171. printf("Test not yet implemented\n");
  1172. return 1;
  1173. }
  1174. /*- End of function --------------------------------------------------------*/
  1175. static void org_02_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1176. {
  1177. }
  1178. /*- End of function --------------------------------------------------------*/
  1179. static int test_org_02(void)
  1180. {
  1181. logging_state_t *logging;
  1182. int16_t amp[2][SAMPLES_PER_CHUNK];
  1183. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1184. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1185. int outframes;
  1186. int samples;
  1187. int push;
  1188. int i;
  1189. int j;
  1190. /*
  1191. III.5.4.2.2 ANS signal detection
  1192. Purpose: To verify that TUT correctly detects the ANS (2100Hz) signal during the
  1193. two-second interval (Toff) between transmission of CI sequences.
  1194. Preamble: Make a V.18 call from the TUT.
  1195. Method: The Test System waits for the TUT to stop transmitting a CI and responds with an
  1196. ANS signal. The V.21 demodulator is used to decode the TXP sequence and a timer
  1197. measures the silence intervals between them. ANS should be transmitted for 2s.
  1198. Pass criteria: 1) No signal should be transmitted by TUT for 0.5s from detection of ANS.
  1199. 2) The TUT should reply with transmission of TXP as defined in 5.1.2.
  1200. 3) Verify that TXP sequence has correct bit pattern.
  1201. */
  1202. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_02_put_text_msg, (void *) (intptr_t) 0);
  1203. logging = v18_get_logging_state(v18[TESTER]);
  1204. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1205. span_log_set_tag(logging, "Tester");
  1206. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_02_put_text_msg, (void *) (intptr_t) 1);
  1207. logging = v18_get_logging_state(v18[TUT]);
  1208. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1209. span_log_set_tag(logging, "TUT");
  1210. if ((model = both_ways_line_model_init(line_model_no,
  1211. noise_level,
  1212. echo_level_cpe1,
  1213. echo_level_co1,
  1214. line_model_no,
  1215. noise_level,
  1216. echo_level_cpe2,
  1217. echo_level_co2,
  1218. channel_codec,
  1219. rbs_pattern)) == NULL)
  1220. {
  1221. fprintf(stderr, " Failed to create line model\n");
  1222. exit(2);
  1223. }
  1224. result[TESTER][0] =
  1225. result[TUT][0] = '\0';
  1226. for (i = 0; i < 10000; i++)
  1227. {
  1228. for (j = 0; j < 2; j++)
  1229. {
  1230. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1231. push = 10;
  1232. if (samples < SAMPLES_PER_CHUNK)
  1233. {
  1234. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1235. samples = SAMPLES_PER_CHUNK;
  1236. }
  1237. }
  1238. if (log_audio)
  1239. {
  1240. for (j = 0; j < samples; j++)
  1241. {
  1242. out_amp[2*j + 0] = amp[0][j];
  1243. out_amp[2*j + 1] = amp[1][j];
  1244. }
  1245. outframes = sf_writef_short(outhandle, out_amp, samples);
  1246. if (outframes != samples)
  1247. {
  1248. fprintf(stderr, " Error writing audio file\n");
  1249. exit(2);
  1250. }
  1251. }
  1252. #if 1
  1253. both_ways_line_model(model,
  1254. model_amp[0],
  1255. amp[0],
  1256. model_amp[1],
  1257. amp[1],
  1258. samples);
  1259. #else
  1260. vec_copyi16(model_amp[0], amp[0], samples);
  1261. vec_copyi16(model_amp[1], amp[1], samples);
  1262. #endif
  1263. v18_rx(v18[TESTER], model_amp[1], samples);
  1264. v18_rx(v18[TUT], model_amp[0], samples);
  1265. }
  1266. v18_free(v18[TESTER]);
  1267. v18_free(v18[TUT]);
  1268. printf("Test not yet implemented\n");
  1269. return 1;
  1270. }
  1271. /*- End of function --------------------------------------------------------*/
  1272. static void org_03_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1273. {
  1274. }
  1275. /*- End of function --------------------------------------------------------*/
  1276. static int test_org_03(void)
  1277. {
  1278. logging_state_t *logging;
  1279. int16_t amp[2][SAMPLES_PER_CHUNK];
  1280. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1281. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1282. int outframes;
  1283. int samples;
  1284. int push;
  1285. int i;
  1286. int j;
  1287. /*
  1288. III.5.4.2.3 End of ANS signal detection
  1289. Purpose: The TUT should stop sending TXP at the end of the current sequence when the ANS
  1290. tone ceases.
  1291. Preamble: Test ORG-02 should be successfully completed immediately prior to this test.
  1292. Method: The tester sends ANS for 2s followed by silence. The tester will then
  1293. monitor for cessation of TXP at the end of the answer tone.
  1294. Pass criteria: The TUT should stop sending TXP at the end of the current sequence when ANS
  1295. tone ceases.
  1296. */
  1297. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_03_put_text_msg, (void *) (intptr_t) 0);
  1298. logging = v18_get_logging_state(v18[TESTER]);
  1299. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1300. span_log_set_tag(logging, "Tester");
  1301. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_03_put_text_msg, (void *) (intptr_t) 1);
  1302. logging = v18_get_logging_state(v18[TUT]);
  1303. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1304. span_log_set_tag(logging, "TUT");
  1305. if ((model = both_ways_line_model_init(line_model_no,
  1306. noise_level,
  1307. echo_level_cpe1,
  1308. echo_level_co1,
  1309. line_model_no,
  1310. noise_level,
  1311. echo_level_cpe2,
  1312. echo_level_co2,
  1313. channel_codec,
  1314. rbs_pattern)) == NULL)
  1315. {
  1316. fprintf(stderr, " Failed to create line model\n");
  1317. exit(2);
  1318. }
  1319. result[TESTER][0] =
  1320. result[TUT][0] = '\0';
  1321. for (i = 0; i < 10000; i++)
  1322. {
  1323. for (j = 0; j < 2; j++)
  1324. {
  1325. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1326. push = 10;
  1327. if (samples < SAMPLES_PER_CHUNK)
  1328. {
  1329. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1330. samples = SAMPLES_PER_CHUNK;
  1331. }
  1332. }
  1333. if (log_audio)
  1334. {
  1335. for (j = 0; j < samples; j++)
  1336. {
  1337. out_amp[2*j + 0] = amp[0][j];
  1338. out_amp[2*j + 1] = amp[1][j];
  1339. }
  1340. outframes = sf_writef_short(outhandle, out_amp, samples);
  1341. if (outframes != samples)
  1342. {
  1343. fprintf(stderr, " Error writing audio file\n");
  1344. exit(2);
  1345. }
  1346. }
  1347. #if 1
  1348. both_ways_line_model(model,
  1349. model_amp[0],
  1350. amp[0],
  1351. model_amp[1],
  1352. amp[1],
  1353. samples);
  1354. #else
  1355. vec_copyi16(model_amp[0], amp[0], samples);
  1356. vec_copyi16(model_amp[1], amp[1], samples);
  1357. #endif
  1358. v18_rx(v18[TESTER], model_amp[1], samples);
  1359. v18_rx(v18[TUT], model_amp[0], samples);
  1360. }
  1361. v18_free(v18[TESTER]);
  1362. v18_free(v18[TUT]);
  1363. printf("Test not yet implemented\n");
  1364. return 1;
  1365. }
  1366. /*- End of function --------------------------------------------------------*/
  1367. static void org_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1368. {
  1369. }
  1370. /*- End of function --------------------------------------------------------*/
  1371. static int test_org_04(void)
  1372. {
  1373. logging_state_t *logging;
  1374. int16_t amp[2][SAMPLES_PER_CHUNK];
  1375. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1376. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1377. int outframes;
  1378. int samples;
  1379. int push;
  1380. int i;
  1381. int j;
  1382. /*
  1383. III.5.4.2.4 ANS tone followed by TXP
  1384. Purpose: To check correct detection of V.18 modem.
  1385. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
  1386. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  1387. 3 TXP sequences using V.21 (2) and starts a 1s timer. It will then transmit 1650Hz
  1388. for 5s.
  1389. Pass criteria: 1) TUT should initially respond with TXP.
  1390. 2) TUT should stop sending TXP within 0.2s of end of ANS.
  1391. 3) TUT should respond with 980Hz carrier within 1s of end of 3 TXP sequences.
  1392. 4) Data should be transmitted and received according to ITU-T T.140 to comply
  1393. with the V.18 operational requirements.
  1394. Comments: The TUT should indicate that V.18 mode has been selected.
  1395. */
  1396. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_04_put_text_msg, (void *) (intptr_t) 0);
  1397. logging = v18_get_logging_state(v18[TESTER]);
  1398. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1399. span_log_set_tag(logging, "Tester");
  1400. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_04_put_text_msg, (void *) (intptr_t) 1);
  1401. logging = v18_get_logging_state(v18[TUT]);
  1402. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1403. span_log_set_tag(logging, "TUT");
  1404. if ((model = both_ways_line_model_init(line_model_no,
  1405. noise_level,
  1406. echo_level_cpe1,
  1407. echo_level_co1,
  1408. line_model_no,
  1409. noise_level,
  1410. echo_level_cpe2,
  1411. echo_level_co2,
  1412. channel_codec,
  1413. rbs_pattern)) == NULL)
  1414. {
  1415. fprintf(stderr, " Failed to create line model\n");
  1416. exit(2);
  1417. }
  1418. result[TESTER][0] =
  1419. result[TUT][0] = '\0';
  1420. for (i = 0; i < 10000; i++)
  1421. {
  1422. for (j = 0; j < 2; j++)
  1423. {
  1424. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1425. push = 10;
  1426. if (samples < SAMPLES_PER_CHUNK)
  1427. {
  1428. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1429. samples = SAMPLES_PER_CHUNK;
  1430. }
  1431. }
  1432. if (log_audio)
  1433. {
  1434. for (j = 0; j < samples; j++)
  1435. {
  1436. out_amp[2*j + 0] = amp[0][j];
  1437. out_amp[2*j + 1] = amp[1][j];
  1438. }
  1439. outframes = sf_writef_short(outhandle, out_amp, samples);
  1440. if (outframes != samples)
  1441. {
  1442. fprintf(stderr, " Error writing audio file\n");
  1443. exit(2);
  1444. }
  1445. }
  1446. #if 1
  1447. both_ways_line_model(model,
  1448. model_amp[0],
  1449. amp[0],
  1450. model_amp[1],
  1451. amp[1],
  1452. samples);
  1453. #else
  1454. vec_copyi16(model_amp[0], amp[0], samples);
  1455. vec_copyi16(model_amp[1], amp[1], samples);
  1456. #endif
  1457. v18_rx(v18[TESTER], model_amp[1], samples);
  1458. v18_rx(v18[TUT], model_amp[0], samples);
  1459. }
  1460. v18_free(v18[TESTER]);
  1461. v18_free(v18[TUT]);
  1462. printf("Test not yet implemented\n");
  1463. return 1;
  1464. }
  1465. /*- End of function --------------------------------------------------------*/
  1466. static void org_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1467. {
  1468. }
  1469. /*- End of function --------------------------------------------------------*/
  1470. static int test_org_05(void)
  1471. {
  1472. logging_state_t *logging;
  1473. int16_t amp[2][SAMPLES_PER_CHUNK];
  1474. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1475. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1476. int outframes;
  1477. int samples;
  1478. int push;
  1479. int i;
  1480. int j;
  1481. /*
  1482. III.5.4.2.5 ANS tone followed by 1650Hz
  1483. Purpose: To check correct detection of V.21 modem upper channel when preceded by answer
  1484. tone and to confirm discrimination between V.21 and V.18 modes.
  1485. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
  1486. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  1487. 1650Hz and starts a 0.7 second timer.
  1488. Pass criteria: 1) TUT should initially respond with TXP.
  1489. 2) TUT should stop sending TXP within 0.2s of end of ANS.
  1490. 3) TUT should respond with 980Hz at 0.5(+0.2-0.0)s of start of 1650Hz.
  1491. 4) Data should be transmitted and received at 300 bit/s complying with Annex F.
  1492. Comments: Selection of ITU-T V.21 as opposed to ITU-T V.18 should be confirmed by
  1493. examination of TUT. If there is no visual indication, verify by use of ITU-T T.50 for
  1494. ITU-T V.21 as opposed to UTF-8 coded ISO 10646 character set for ITU-T V.18.
  1495. */
  1496. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_05_put_text_msg, (void *) (intptr_t) 0);
  1497. logging = v18_get_logging_state(v18[TESTER]);
  1498. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1499. span_log_set_tag(logging, "Tester");
  1500. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_05_put_text_msg, (void *) (intptr_t) 1);
  1501. logging = v18_get_logging_state(v18[TUT]);
  1502. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1503. span_log_set_tag(logging, "TUT");
  1504. if ((model = both_ways_line_model_init(line_model_no,
  1505. noise_level,
  1506. echo_level_cpe1,
  1507. echo_level_co1,
  1508. line_model_no,
  1509. noise_level,
  1510. echo_level_cpe2,
  1511. echo_level_co2,
  1512. channel_codec,
  1513. rbs_pattern)) == NULL)
  1514. {
  1515. fprintf(stderr, " Failed to create line model\n");
  1516. exit(2);
  1517. }
  1518. result[TESTER][0] =
  1519. result[TUT][0] = '\0';
  1520. for (i = 0; i < 10000; i++)
  1521. {
  1522. for (j = 0; j < 2; j++)
  1523. {
  1524. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1525. push = 10;
  1526. if (samples < SAMPLES_PER_CHUNK)
  1527. {
  1528. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1529. samples = SAMPLES_PER_CHUNK;
  1530. }
  1531. }
  1532. if (log_audio)
  1533. {
  1534. for (j = 0; j < samples; j++)
  1535. {
  1536. out_amp[2*j + 0] = amp[0][j];
  1537. out_amp[2*j + 1] = amp[1][j];
  1538. }
  1539. outframes = sf_writef_short(outhandle, out_amp, samples);
  1540. if (outframes != samples)
  1541. {
  1542. fprintf(stderr, " Error writing audio file\n");
  1543. exit(2);
  1544. }
  1545. }
  1546. #if 1
  1547. both_ways_line_model(model,
  1548. model_amp[0],
  1549. amp[0],
  1550. model_amp[1],
  1551. amp[1],
  1552. samples);
  1553. #else
  1554. vec_copyi16(model_amp[0], amp[0], samples);
  1555. vec_copyi16(model_amp[1], amp[1], samples);
  1556. #endif
  1557. v18_rx(v18[TESTER], model_amp[1], samples);
  1558. v18_rx(v18[TUT], model_amp[0], samples);
  1559. }
  1560. v18_free(v18[TESTER]);
  1561. v18_free(v18[TUT]);
  1562. printf("Test not yet implemented\n");
  1563. return 1;
  1564. }
  1565. /*- End of function --------------------------------------------------------*/
  1566. static void org_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1567. {
  1568. }
  1569. /*- End of function --------------------------------------------------------*/
  1570. static int test_org_06(void)
  1571. {
  1572. logging_state_t *logging;
  1573. int16_t amp[2][SAMPLES_PER_CHUNK];
  1574. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1575. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1576. int outframes;
  1577. int samples;
  1578. int push;
  1579. int i;
  1580. int j;
  1581. /*
  1582. III.5.4.2.6 ANS tone followed by 1300Hz
  1583. Purpose: To check correct detection of V.23 modem upper channel when preceded by answer
  1584. tone.
  1585. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
  1586. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  1587. 1300Hz and starts a 2.7s timer.
  1588. Pass criteria: 1) TUT should initially respond with TXP.
  1589. 2) TUT should stop sending TXP within 0.2s of end of ANS.
  1590. 3) TUT should respond with 390Hz after 1.7(+0.2-0.0)s of start of 1300Hz.
  1591. 4) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively
  1592. by the TUT to comply with Annex E.
  1593. Comments: The TUT should indicate that V.23 mode has been selected.
  1594. */
  1595. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_06_put_text_msg, (void *) (intptr_t) 0);
  1596. logging = v18_get_logging_state(v18[TESTER]);
  1597. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1598. span_log_set_tag(logging, "Tester");
  1599. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_06_put_text_msg, (void *) (intptr_t) 1);
  1600. logging = v18_get_logging_state(v18[TUT]);
  1601. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1602. span_log_set_tag(logging, "TUT");
  1603. if ((model = both_ways_line_model_init(line_model_no,
  1604. noise_level,
  1605. echo_level_cpe1,
  1606. echo_level_co1,
  1607. line_model_no,
  1608. noise_level,
  1609. echo_level_cpe2,
  1610. echo_level_co2,
  1611. channel_codec,
  1612. rbs_pattern)) == NULL)
  1613. {
  1614. fprintf(stderr, " Failed to create line model\n");
  1615. exit(2);
  1616. }
  1617. result[TESTER][0] =
  1618. result[TUT][0] = '\0';
  1619. for (i = 0; i < 10000; i++)
  1620. {
  1621. for (j = 0; j < 2; j++)
  1622. {
  1623. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1624. push = 10;
  1625. if (samples < SAMPLES_PER_CHUNK)
  1626. {
  1627. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1628. samples = SAMPLES_PER_CHUNK;
  1629. }
  1630. }
  1631. if (log_audio)
  1632. {
  1633. for (j = 0; j < samples; j++)
  1634. {
  1635. out_amp[2*j + 0] = amp[0][j];
  1636. out_amp[2*j + 1] = amp[1][j];
  1637. }
  1638. outframes = sf_writef_short(outhandle, out_amp, samples);
  1639. if (outframes != samples)
  1640. {
  1641. fprintf(stderr, " Error writing audio file\n");
  1642. exit(2);
  1643. }
  1644. }
  1645. #if 1
  1646. both_ways_line_model(model,
  1647. model_amp[0],
  1648. amp[0],
  1649. model_amp[1],
  1650. amp[1],
  1651. samples);
  1652. #else
  1653. vec_copyi16(model_amp[0], amp[0], samples);
  1654. vec_copyi16(model_amp[1], amp[1], samples);
  1655. #endif
  1656. v18_rx(v18[TESTER], model_amp[1], samples);
  1657. v18_rx(v18[TUT], model_amp[0], samples);
  1658. }
  1659. v18_free(v18[TESTER]);
  1660. v18_free(v18[TUT]);
  1661. printf("Test not yet implemented\n");
  1662. return 1;
  1663. }
  1664. /*- End of function --------------------------------------------------------*/
  1665. static void org_07_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1666. {
  1667. }
  1668. /*- End of function --------------------------------------------------------*/
  1669. static int test_org_07(void)
  1670. {
  1671. logging_state_t *logging;
  1672. int16_t amp[2][SAMPLES_PER_CHUNK];
  1673. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1674. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1675. int outframes;
  1676. int samples;
  1677. int push;
  1678. int i;
  1679. int j;
  1680. /*
  1681. III.5.4.2.7 ANS tone followed by no tone
  1682. Purpose: To confirm that TUT does not lock up under this condition.
  1683. Preamble: Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
  1684. Method: Tester transmits ANS for 2.5s followed by no tone for 10 s. It then transmits
  1685. DTMF tones for 2s.
  1686. Pass criteria: 1) TUT should initially respond with TXP.
  1687. 2) TUT should stop sending TXP within 0.2s of end of ANS.
  1688. 3) TUT should return to Monitor 1 state and then connect in DTMF mode within
  1689. 12s of the end of ANS tone.
  1690. Comments: This condition would cause the terminal to lock up if the V.18 standard is followed
  1691. literally. It may however, occur when connected to certain Swedish textphones if the
  1692. handset is lifted just after the start of an automatically answered incoming call.
  1693. */
  1694. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_07_put_text_msg, (void *) (intptr_t) 0);
  1695. logging = v18_get_logging_state(v18[TESTER]);
  1696. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1697. span_log_set_tag(logging, "Tester");
  1698. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_07_put_text_msg, (void *) (intptr_t) 1);
  1699. logging = v18_get_logging_state(v18[TUT]);
  1700. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1701. span_log_set_tag(logging, "TUT");
  1702. if ((model = both_ways_line_model_init(line_model_no,
  1703. noise_level,
  1704. echo_level_cpe1,
  1705. echo_level_co1,
  1706. line_model_no,
  1707. noise_level,
  1708. echo_level_cpe2,
  1709. echo_level_co2,
  1710. channel_codec,
  1711. rbs_pattern)) == NULL)
  1712. {
  1713. fprintf(stderr, " Failed to create line model\n");
  1714. exit(2);
  1715. }
  1716. result[TESTER][0] =
  1717. result[TUT][0] = '\0';
  1718. for (i = 0; i < 10000; i++)
  1719. {
  1720. for (j = 0; j < 2; j++)
  1721. {
  1722. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1723. push = 10;
  1724. if (samples < SAMPLES_PER_CHUNK)
  1725. {
  1726. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1727. samples = SAMPLES_PER_CHUNK;
  1728. }
  1729. }
  1730. if (log_audio)
  1731. {
  1732. for (j = 0; j < samples; j++)
  1733. {
  1734. out_amp[2*j + 0] = amp[0][j];
  1735. out_amp[2*j + 1] = amp[1][j];
  1736. }
  1737. outframes = sf_writef_short(outhandle, out_amp, samples);
  1738. if (outframes != samples)
  1739. {
  1740. fprintf(stderr, " Error writing audio file\n");
  1741. exit(2);
  1742. }
  1743. }
  1744. #if 1
  1745. both_ways_line_model(model,
  1746. model_amp[0],
  1747. amp[0],
  1748. model_amp[1],
  1749. amp[1],
  1750. samples);
  1751. #else
  1752. vec_copyi16(model_amp[0], amp[0], samples);
  1753. vec_copyi16(model_amp[1], amp[1], samples);
  1754. #endif
  1755. v18_rx(v18[TESTER], model_amp[1], samples);
  1756. v18_rx(v18[TUT], model_amp[0], samples);
  1757. }
  1758. v18_free(v18[TESTER]);
  1759. v18_free(v18[TUT]);
  1760. printf("Test not yet implemented\n");
  1761. return 1;
  1762. }
  1763. /*- End of function --------------------------------------------------------*/
  1764. static void org_08_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1765. {
  1766. }
  1767. /*- End of function --------------------------------------------------------*/
  1768. static int test_org_08(void)
  1769. {
  1770. logging_state_t *logging;
  1771. int16_t amp[2][SAMPLES_PER_CHUNK];
  1772. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1773. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1774. int outframes;
  1775. int samples;
  1776. int push;
  1777. int i;
  1778. int j;
  1779. /*
  1780. III.5.4.2.8 Bell 103 (2225Hz signal) detection
  1781. Purpose: To verify that the TUT correctly detects the Bell 103 upper channel signal during
  1782. the 2-second interval between transmission of CI sequences.
  1783. Preamble: N/A
  1784. Method: The tester waits for a CI and then sends a 2225Hz signal for 5s.
  1785. Pass criteria: 1) The TUT should respond with a 1270Hz tone in 0.5+-0.1s.
  1786. 2) Data should be transmitted and received at 300 bit/s to comply with Annex D.
  1787. Comments: The TUT should indicate that Bell 103 mode has been selected.
  1788. */
  1789. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_08_put_text_msg, (void *) (intptr_t) 0);
  1790. logging = v18_get_logging_state(v18[TESTER]);
  1791. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1792. span_log_set_tag(logging, "Tester");
  1793. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_08_put_text_msg, (void *) (intptr_t) 1);
  1794. logging = v18_get_logging_state(v18[TUT]);
  1795. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1796. span_log_set_tag(logging, "TUT");
  1797. if ((model = both_ways_line_model_init(line_model_no,
  1798. noise_level,
  1799. echo_level_cpe1,
  1800. echo_level_co1,
  1801. line_model_no,
  1802. noise_level,
  1803. echo_level_cpe2,
  1804. echo_level_co2,
  1805. channel_codec,
  1806. rbs_pattern)) == NULL)
  1807. {
  1808. fprintf(stderr, " Failed to create line model\n");
  1809. exit(2);
  1810. }
  1811. result[TESTER][0] =
  1812. result[TUT][0] = '\0';
  1813. for (i = 0; i < 10000; i++)
  1814. {
  1815. for (j = 0; j < 2; j++)
  1816. {
  1817. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1818. push = 10;
  1819. if (samples < SAMPLES_PER_CHUNK)
  1820. {
  1821. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1822. samples = SAMPLES_PER_CHUNK;
  1823. }
  1824. }
  1825. if (log_audio)
  1826. {
  1827. for (j = 0; j < samples; j++)
  1828. {
  1829. out_amp[2*j + 0] = amp[0][j];
  1830. out_amp[2*j + 1] = amp[1][j];
  1831. }
  1832. outframes = sf_writef_short(outhandle, out_amp, samples);
  1833. if (outframes != samples)
  1834. {
  1835. fprintf(stderr, " Error writing audio file\n");
  1836. exit(2);
  1837. }
  1838. }
  1839. #if 1
  1840. both_ways_line_model(model,
  1841. model_amp[0],
  1842. amp[0],
  1843. model_amp[1],
  1844. amp[1],
  1845. samples);
  1846. #else
  1847. vec_copyi16(model_amp[0], amp[0], samples);
  1848. vec_copyi16(model_amp[1], amp[1], samples);
  1849. #endif
  1850. v18_rx(v18[TESTER], model_amp[1], samples);
  1851. v18_rx(v18[TUT], model_amp[0], samples);
  1852. }
  1853. v18_free(v18[TESTER]);
  1854. v18_free(v18[TUT]);
  1855. printf("Test not yet implemented\n");
  1856. return 1;
  1857. }
  1858. /*- End of function --------------------------------------------------------*/
  1859. static void org_09_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1860. {
  1861. }
  1862. /*- End of function --------------------------------------------------------*/
  1863. static int test_org_09(void)
  1864. {
  1865. logging_state_t *logging;
  1866. int16_t amp[2][SAMPLES_PER_CHUNK];
  1867. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1868. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1869. int outframes;
  1870. int samples;
  1871. int push;
  1872. int i;
  1873. int j;
  1874. /*
  1875. III.5.4.2.9 V.21 (1650Hz signal) detection
  1876. Purpose: To verify that the TUT correctly detects the V.21 upper channel signal during the
  1877. 2-second interval between transmission of CI sequences.
  1878. Preamble: N/A
  1879. Method: The tester waits for a CI and then sends a 1650Hz signal for 5s.
  1880. Pass criteria: 1) The TUT should respond with a 980Hz tone in 0.5+-0.1s.
  1881. 2) Data should be transmitted and received at 300 bit/s to comply with Annex F.
  1882. Comments: The TUT should indicate that V.21 mode has been selected.
  1883. */
  1884. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_09_put_text_msg, (void *) (intptr_t) 0);
  1885. logging = v18_get_logging_state(v18[TESTER]);
  1886. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1887. span_log_set_tag(logging, "Tester");
  1888. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_09_put_text_msg, (void *) (intptr_t) 1);
  1889. logging = v18_get_logging_state(v18[TUT]);
  1890. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1891. span_log_set_tag(logging, "TUT");
  1892. if ((model = both_ways_line_model_init(line_model_no,
  1893. noise_level,
  1894. echo_level_cpe1,
  1895. echo_level_co1,
  1896. line_model_no,
  1897. noise_level,
  1898. echo_level_cpe2,
  1899. echo_level_co2,
  1900. channel_codec,
  1901. rbs_pattern)) == NULL)
  1902. {
  1903. fprintf(stderr, " Failed to create line model\n");
  1904. exit(2);
  1905. }
  1906. result[TESTER][0] =
  1907. result[TUT][0] = '\0';
  1908. for (i = 0; i < 10000; i++)
  1909. {
  1910. for (j = 0; j < 2; j++)
  1911. {
  1912. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  1913. push = 10;
  1914. if (samples < SAMPLES_PER_CHUNK)
  1915. {
  1916. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  1917. samples = SAMPLES_PER_CHUNK;
  1918. }
  1919. }
  1920. if (log_audio)
  1921. {
  1922. for (j = 0; j < samples; j++)
  1923. {
  1924. out_amp[2*j + 0] = amp[0][j];
  1925. out_amp[2*j + 1] = amp[1][j];
  1926. }
  1927. outframes = sf_writef_short(outhandle, out_amp, samples);
  1928. if (outframes != samples)
  1929. {
  1930. fprintf(stderr, " Error writing audio file\n");
  1931. exit(2);
  1932. }
  1933. }
  1934. #if 1
  1935. both_ways_line_model(model,
  1936. model_amp[0],
  1937. amp[0],
  1938. model_amp[1],
  1939. amp[1],
  1940. samples);
  1941. #else
  1942. vec_copyi16(model_amp[0], amp[0], samples);
  1943. vec_copyi16(model_amp[1], amp[1], samples);
  1944. #endif
  1945. v18_rx(v18[TESTER], model_amp[1], samples);
  1946. v18_rx(v18[TUT], model_amp[0], samples);
  1947. }
  1948. v18_free(v18[TESTER]);
  1949. v18_free(v18[TUT]);
  1950. printf("Test not yet implemented\n");
  1951. return 1;
  1952. }
  1953. /*- End of function --------------------------------------------------------*/
  1954. static void org_10_put_text_msg(void *user_data, const uint8_t *msg, int len)
  1955. {
  1956. }
  1957. /*- End of function --------------------------------------------------------*/
  1958. static int test_org_10(void)
  1959. {
  1960. logging_state_t *logging;
  1961. int16_t amp[2][SAMPLES_PER_CHUNK];
  1962. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  1963. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  1964. int outframes;
  1965. int samples;
  1966. int push;
  1967. int i;
  1968. int j;
  1969. /*
  1970. III.5.4.2.10 V.23 (1300Hz signal) detection
  1971. Purpose: To verify that the TUT correctly detects the V.23 upper channel signal during the
  1972. 2-second interval between transmission of CI sequences.
  1973. Preamble: N/A
  1974. Method: The tester waits for a CI and then sends a 1300Hz signal for 5s.
  1975. Pass criteria: 1) The TUT should respond with a 390Hz tone in 1.7+-0.1s.
  1976. 2) Data should be transmitted and received at 75 bit/s and 1200 bit/s respectively
  1977. by the TUT to comply with Annex E.
  1978. Comments: The TUT should indicate that V.23 mode has been selected.
  1979. */
  1980. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_10_put_text_msg, (void *) (intptr_t) 0);
  1981. logging = v18_get_logging_state(v18[TESTER]);
  1982. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1983. span_log_set_tag(logging, "Tester");
  1984. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_10_put_text_msg, (void *) (intptr_t) 1);
  1985. logging = v18_get_logging_state(v18[TUT]);
  1986. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  1987. span_log_set_tag(logging, "TUT");
  1988. if ((model = both_ways_line_model_init(line_model_no,
  1989. noise_level,
  1990. echo_level_cpe1,
  1991. echo_level_co1,
  1992. line_model_no,
  1993. noise_level,
  1994. echo_level_cpe2,
  1995. echo_level_co2,
  1996. channel_codec,
  1997. rbs_pattern)) == NULL)
  1998. {
  1999. fprintf(stderr, " Failed to create line model\n");
  2000. exit(2);
  2001. }
  2002. result[TESTER][0] =
  2003. result[TUT][0] = '\0';
  2004. for (i = 0; i < 10000; i++)
  2005. {
  2006. for (j = 0; j < 2; j++)
  2007. {
  2008. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2009. push = 10;
  2010. if (samples < SAMPLES_PER_CHUNK)
  2011. {
  2012. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2013. samples = SAMPLES_PER_CHUNK;
  2014. }
  2015. }
  2016. if (log_audio)
  2017. {
  2018. for (j = 0; j < samples; j++)
  2019. {
  2020. out_amp[2*j + 0] = amp[0][j];
  2021. out_amp[2*j + 1] = amp[1][j];
  2022. }
  2023. outframes = sf_writef_short(outhandle, out_amp, samples);
  2024. if (outframes != samples)
  2025. {
  2026. fprintf(stderr, " Error writing audio file\n");
  2027. exit(2);
  2028. }
  2029. }
  2030. #if 1
  2031. both_ways_line_model(model,
  2032. model_amp[0],
  2033. amp[0],
  2034. model_amp[1],
  2035. amp[1],
  2036. samples);
  2037. #else
  2038. vec_copyi16(model_amp[0], amp[0], samples);
  2039. vec_copyi16(model_amp[1], amp[1], samples);
  2040. #endif
  2041. v18_rx(v18[TESTER], model_amp[1], samples);
  2042. v18_rx(v18[TUT], model_amp[0], samples);
  2043. }
  2044. v18_free(v18[TESTER]);
  2045. v18_free(v18[TUT]);
  2046. printf("Test not yet implemented\n");
  2047. return 1;
  2048. }
  2049. /*- End of function --------------------------------------------------------*/
  2050. static void org_11_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2051. {
  2052. }
  2053. /*- End of function --------------------------------------------------------*/
  2054. static int test_org_11(void)
  2055. {
  2056. logging_state_t *logging;
  2057. int16_t amp[2][SAMPLES_PER_CHUNK];
  2058. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2059. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2060. int outframes;
  2061. int samples;
  2062. int push;
  2063. int i;
  2064. int j;
  2065. /*
  2066. III.5.4.2.11 V.23 (390Hz signal) detection
  2067. Purpose: To confirm correct selection of V.23 reverse mode during sending of XCI.
  2068. Preamble: N/A
  2069. Method: The tester should wait for the start of the XCI signal and then send 390Hz to TUT
  2070. for 5s.
  2071. Pass criteria: 1) The TUT should complete the XCI as normal.
  2072. 2) The TUT should then maintain the 1300Hz tone while the 390Hz test tone is
  2073. present.
  2074. 3) Data should be transmitted and received at 1200 bit/s and 75 bit/s respectively
  2075. by the TUT to comply with Annex E when connection is indicated.
  2076. Comments: The TUT should indicate that V.23 mode has been selected at least 3s after
  2077. the start of the 390Hz tone.
  2078. */
  2079. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_11_put_text_msg, (void *) (intptr_t) 0);
  2080. logging = v18_get_logging_state(v18[TESTER]);
  2081. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2082. span_log_set_tag(logging, "Tester");
  2083. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_11_put_text_msg, (void *) (intptr_t) 1);
  2084. logging = v18_get_logging_state(v18[TUT]);
  2085. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2086. span_log_set_tag(logging, "TUT");
  2087. if ((model = both_ways_line_model_init(line_model_no,
  2088. noise_level,
  2089. echo_level_cpe1,
  2090. echo_level_co1,
  2091. line_model_no,
  2092. noise_level,
  2093. echo_level_cpe2,
  2094. echo_level_co2,
  2095. channel_codec,
  2096. rbs_pattern)) == NULL)
  2097. {
  2098. fprintf(stderr, " Failed to create line model\n");
  2099. exit(2);
  2100. }
  2101. result[TESTER][0] =
  2102. result[TUT][0] = '\0';
  2103. for (i = 0; i < 10000; i++)
  2104. {
  2105. for (j = 0; j < 2; j++)
  2106. {
  2107. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2108. push = 10;
  2109. if (samples < SAMPLES_PER_CHUNK)
  2110. {
  2111. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2112. samples = SAMPLES_PER_CHUNK;
  2113. }
  2114. }
  2115. if (log_audio)
  2116. {
  2117. for (j = 0; j < samples; j++)
  2118. {
  2119. out_amp[2*j + 0] = amp[0][j];
  2120. out_amp[2*j + 1] = amp[1][j];
  2121. }
  2122. outframes = sf_writef_short(outhandle, out_amp, samples);
  2123. if (outframes != samples)
  2124. {
  2125. fprintf(stderr, " Error writing audio file\n");
  2126. exit(2);
  2127. }
  2128. }
  2129. #if 1
  2130. both_ways_line_model(model,
  2131. model_amp[0],
  2132. amp[0],
  2133. model_amp[1],
  2134. amp[1],
  2135. samples);
  2136. #else
  2137. vec_copyi16(model_amp[0], amp[0], samples);
  2138. vec_copyi16(model_amp[1], amp[1], samples);
  2139. #endif
  2140. v18_rx(v18[TESTER], model_amp[1], samples);
  2141. v18_rx(v18[TUT], model_amp[0], samples);
  2142. }
  2143. v18_free(v18[TESTER]);
  2144. v18_free(v18[TUT]);
  2145. printf("Test not yet implemented\n");
  2146. return 1;
  2147. }
  2148. /*- End of function --------------------------------------------------------*/
  2149. static void org_12_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2150. {
  2151. }
  2152. /*- End of function --------------------------------------------------------*/
  2153. static int test_org_12(void)
  2154. {
  2155. logging_state_t *logging;
  2156. int16_t amp[2][SAMPLES_PER_CHUNK];
  2157. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2158. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2159. int outframes;
  2160. int samples;
  2161. int push;
  2162. int i;
  2163. int j;
  2164. /*
  2165. III.5.4.2.12 5 bit mode (Baudot) detection tests
  2166. Purpose: To confirm detection of Baudot modulation at various bit rates that may be
  2167. encountered.
  2168. Preamble: N/A
  2169. Method: The tester transmits the 5-bit coded characters "0" to "9" followed by "abcdef" at
  2170. (a) 45.45, (b) 47.6, (c) 50 and (d) 100 bits per second. When TUT indicates a
  2171. connection, type at least 5 characters back to the tester so that correct selection
  2172. of bit rate can be confirmed.
  2173. Pass criteria: 1) TUT should select Baudot mode and the appropriate bit rate.
  2174. 2) The tester will analyse the bit rate of received characters, which should be at
  2175. either 45.45 or 50 bits per second as appropriate.
  2176. Comments: 45.45 and 50 bit/s are the commonly used Baudot bit rates. However, certain
  2177. textphones can operate at higher rates (e.g. 100 bit/s). Responding at either 45.45 or
  2178. 50 bit/s is acceptable to these devices which normally fall back to the selected rate.
  2179. 47.6 bit/s may possibly be encountered from another V.18 textphone in the
  2180. automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
  2181. transmission.
  2182. */
  2183. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_12_put_text_msg, (void *) (intptr_t) 0);
  2184. logging = v18_get_logging_state(v18[TESTER]);
  2185. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2186. span_log_set_tag(logging, "Tester");
  2187. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_12_put_text_msg, (void *) (intptr_t) 1);
  2188. logging = v18_get_logging_state(v18[TUT]);
  2189. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2190. span_log_set_tag(logging, "TUT");
  2191. if ((model = both_ways_line_model_init(line_model_no,
  2192. noise_level,
  2193. echo_level_cpe1,
  2194. echo_level_co1,
  2195. line_model_no,
  2196. noise_level,
  2197. echo_level_cpe2,
  2198. echo_level_co2,
  2199. channel_codec,
  2200. rbs_pattern)) == NULL)
  2201. {
  2202. fprintf(stderr, " Failed to create line model\n");
  2203. exit(2);
  2204. }
  2205. result[TESTER][0] =
  2206. result[TUT][0] = '\0';
  2207. for (i = 0; i < 10000; i++)
  2208. {
  2209. for (j = 0; j < 2; j++)
  2210. {
  2211. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2212. push = 10;
  2213. if (samples < SAMPLES_PER_CHUNK)
  2214. {
  2215. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2216. samples = SAMPLES_PER_CHUNK;
  2217. }
  2218. }
  2219. if (log_audio)
  2220. {
  2221. for (j = 0; j < samples; j++)
  2222. {
  2223. out_amp[2*j + 0] = amp[0][j];
  2224. out_amp[2*j + 1] = amp[1][j];
  2225. }
  2226. outframes = sf_writef_short(outhandle, out_amp, samples);
  2227. if (outframes != samples)
  2228. {
  2229. fprintf(stderr, " Error writing audio file\n");
  2230. exit(2);
  2231. }
  2232. }
  2233. #if 1
  2234. both_ways_line_model(model,
  2235. model_amp[0],
  2236. amp[0],
  2237. model_amp[1],
  2238. amp[1],
  2239. samples);
  2240. #else
  2241. vec_copyi16(model_amp[0], amp[0], samples);
  2242. vec_copyi16(model_amp[1], amp[1], samples);
  2243. #endif
  2244. v18_rx(v18[TESTER], model_amp[1], samples);
  2245. v18_rx(v18[TUT], model_amp[0], samples);
  2246. }
  2247. v18_free(v18[TESTER]);
  2248. v18_free(v18[TUT]);
  2249. printf("Test not yet implemented\n");
  2250. return 1;
  2251. }
  2252. /*- End of function --------------------------------------------------------*/
  2253. static void org_13_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2254. {
  2255. }
  2256. /*- End of function --------------------------------------------------------*/
  2257. static int test_org_13(void)
  2258. {
  2259. logging_state_t *logging;
  2260. int16_t amp[2][SAMPLES_PER_CHUNK];
  2261. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2262. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2263. int outframes;
  2264. int samples;
  2265. int push;
  2266. int i;
  2267. int j;
  2268. /*
  2269. III.5.4.2.13 DTMF signal detection
  2270. Purpose: To verify whether the TUT correctly recognizes DTMF signals during the 2-second
  2271. interval between transmission of CI.
  2272. Preamble: N/A
  2273. Method: The tester will send a single DTMF tone of 40ms duration to TUT. When TUT
  2274. indicates a connection, type at least 5 characters back to the tester so that correct
  2275. selection of mode can be confirmed.
  2276. Pass criteria: The tester will analyse the received characters to confirm DTMF mode selection.
  2277. Comments: TUT should indicate that it has selected DTMF mode. The DTMF capabilities of the
  2278. TUT should comply with ITU-T Q.24 for the Danish Administration while
  2279. receiving for best possible performance.
  2280. */
  2281. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_13_put_text_msg, (void *) (intptr_t) 0);
  2282. logging = v18_get_logging_state(v18[TESTER]);
  2283. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2284. span_log_set_tag(logging, "Tester");
  2285. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_13_put_text_msg, (void *) (intptr_t) 1);
  2286. logging = v18_get_logging_state(v18[TUT]);
  2287. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2288. span_log_set_tag(logging, "TUT");
  2289. if ((model = both_ways_line_model_init(line_model_no,
  2290. noise_level,
  2291. echo_level_cpe1,
  2292. echo_level_co1,
  2293. line_model_no,
  2294. noise_level,
  2295. echo_level_cpe2,
  2296. echo_level_co2,
  2297. channel_codec,
  2298. rbs_pattern)) == NULL)
  2299. {
  2300. fprintf(stderr, " Failed to create line model\n");
  2301. exit(2);
  2302. }
  2303. result[TESTER][0] =
  2304. result[TUT][0] = '\0';
  2305. for (i = 0; i < 10000; i++)
  2306. {
  2307. for (j = 0; j < 2; j++)
  2308. {
  2309. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2310. push = 10;
  2311. if (samples < SAMPLES_PER_CHUNK)
  2312. {
  2313. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2314. samples = SAMPLES_PER_CHUNK;
  2315. }
  2316. }
  2317. if (log_audio)
  2318. {
  2319. for (j = 0; j < samples; j++)
  2320. {
  2321. out_amp[2*j + 0] = amp[0][j];
  2322. out_amp[2*j + 1] = amp[1][j];
  2323. }
  2324. outframes = sf_writef_short(outhandle, out_amp, samples);
  2325. if (outframes != samples)
  2326. {
  2327. fprintf(stderr, " Error writing audio file\n");
  2328. exit(2);
  2329. }
  2330. }
  2331. #if 1
  2332. both_ways_line_model(model,
  2333. model_amp[0],
  2334. amp[0],
  2335. model_amp[1],
  2336. amp[1],
  2337. samples);
  2338. #else
  2339. vec_copyi16(model_amp[0], amp[0], samples);
  2340. vec_copyi16(model_amp[1], amp[1], samples);
  2341. #endif
  2342. v18_rx(v18[TESTER], model_amp[1], samples);
  2343. v18_rx(v18[TUT], model_amp[0], samples);
  2344. }
  2345. v18_free(v18[TESTER]);
  2346. v18_free(v18[TUT]);
  2347. printf("Test not yet implemented\n");
  2348. return 1;
  2349. }
  2350. /*- End of function --------------------------------------------------------*/
  2351. static void org_14_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2352. {
  2353. }
  2354. /*- End of function --------------------------------------------------------*/
  2355. static int test_org_14(void)
  2356. {
  2357. logging_state_t *logging;
  2358. int16_t amp[2][SAMPLES_PER_CHUNK];
  2359. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2360. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2361. int outframes;
  2362. int samples;
  2363. int push;
  2364. int i;
  2365. int j;
  2366. /*
  2367. III.5.4.2.14 EDT rate detection
  2368. Purpose: To confirm detection of EDT modems by detecting the transmission rate of received
  2369. characters.
  2370. Preamble: N/A
  2371. Method: The tester transmits EDT characters "abcdef" to TUT at 110 bit/s. When TUT
  2372. indicates that the connection is established, type characters "abcdef<CR>" back to
  2373. the tester. The same characters will then be transmitted back to the TUT.
  2374. Pass criteria: Ensure correct reception of characters by tester and TUT.
  2375. Comments: The TUT should be able to determine the rate on the six characters given. If it takes
  2376. more than this then performance is probably inadequate as too many characters
  2377. would be lost. Some characters may be lost during the detection process. However,
  2378. the number lost should be minimal. The data bits and parity are specified in
  2379. Annex C.
  2380. */
  2381. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_14_put_text_msg, (void *) (intptr_t) 0);
  2382. logging = v18_get_logging_state(v18[TESTER]);
  2383. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2384. span_log_set_tag(logging, "Tester");
  2385. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_14_put_text_msg, (void *) (intptr_t) 1);
  2386. logging = v18_get_logging_state(v18[TUT]);
  2387. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2388. span_log_set_tag(logging, "TUT");
  2389. if ((model = both_ways_line_model_init(line_model_no,
  2390. noise_level,
  2391. echo_level_cpe1,
  2392. echo_level_co1,
  2393. line_model_no,
  2394. noise_level,
  2395. echo_level_cpe2,
  2396. echo_level_co2,
  2397. channel_codec,
  2398. rbs_pattern)) == NULL)
  2399. {
  2400. fprintf(stderr, " Failed to create line model\n");
  2401. exit(2);
  2402. }
  2403. result[TESTER][0] =
  2404. result[TUT][0] = '\0';
  2405. for (i = 0; i < 10000; i++)
  2406. {
  2407. for (j = 0; j < 2; j++)
  2408. {
  2409. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2410. push = 10;
  2411. if (samples < SAMPLES_PER_CHUNK)
  2412. {
  2413. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2414. samples = SAMPLES_PER_CHUNK;
  2415. }
  2416. }
  2417. if (log_audio)
  2418. {
  2419. for (j = 0; j < samples; j++)
  2420. {
  2421. out_amp[2*j + 0] = amp[0][j];
  2422. out_amp[2*j + 1] = amp[1][j];
  2423. }
  2424. outframes = sf_writef_short(outhandle, out_amp, samples);
  2425. if (outframes != samples)
  2426. {
  2427. fprintf(stderr, " Error writing audio file\n");
  2428. exit(2);
  2429. }
  2430. }
  2431. #if 1
  2432. both_ways_line_model(model,
  2433. model_amp[0],
  2434. amp[0],
  2435. model_amp[1],
  2436. amp[1],
  2437. samples);
  2438. #else
  2439. vec_copyi16(model_amp[0], amp[0], samples);
  2440. vec_copyi16(model_amp[1], amp[1], samples);
  2441. #endif
  2442. v18_rx(v18[TESTER], model_amp[1], samples);
  2443. v18_rx(v18[TUT], model_amp[0], samples);
  2444. }
  2445. v18_free(v18[TESTER]);
  2446. v18_free(v18[TUT]);
  2447. printf("Test not yet implemented\n");
  2448. return 1;
  2449. }
  2450. /*- End of function --------------------------------------------------------*/
  2451. static void org_15_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2452. {
  2453. }
  2454. /*- End of function --------------------------------------------------------*/
  2455. static int test_org_15(void)
  2456. {
  2457. logging_state_t *logging;
  2458. int16_t amp[2][SAMPLES_PER_CHUNK];
  2459. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2460. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2461. int outframes;
  2462. int samples;
  2463. int push;
  2464. int i;
  2465. int j;
  2466. /*
  2467. III.5.4.2.15 Rate detection test
  2468. Purpose: To verify the presence of 980/1180Hz at a different signalling rate than 110 bit/s
  2469. returns the TUT modem to the "monitor A" state.
  2470. Preamble: N/A
  2471. Method: The tester transmits 980/1180Hz signals at 300 bit/s for 2s.
  2472. Pass criteria: The TUT should not select EDT or any other mode and should continue to transmit
  2473. the CI signal.
  2474. Comments: Echoes of the CI sequences may be detected at 300 bit/s.
  2475. */
  2476. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_15_put_text_msg, (void *) (intptr_t) 0);
  2477. logging = v18_get_logging_state(v18[TESTER]);
  2478. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2479. span_log_set_tag(logging, "Tester");
  2480. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_15_put_text_msg, (void *) (intptr_t) 1);
  2481. logging = v18_get_logging_state(v18[TUT]);
  2482. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2483. span_log_set_tag(logging, "TUT");
  2484. if ((model = both_ways_line_model_init(line_model_no,
  2485. noise_level,
  2486. echo_level_cpe1,
  2487. echo_level_co1,
  2488. line_model_no,
  2489. noise_level,
  2490. echo_level_cpe2,
  2491. echo_level_co2,
  2492. channel_codec,
  2493. rbs_pattern)) == NULL)
  2494. {
  2495. fprintf(stderr, " Failed to create line model\n");
  2496. exit(2);
  2497. }
  2498. result[TESTER][0] =
  2499. result[TUT][0] = '\0';
  2500. for (i = 0; i < 10000; i++)
  2501. {
  2502. for (j = 0; j < 2; j++)
  2503. {
  2504. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2505. push = 10;
  2506. if (samples < SAMPLES_PER_CHUNK)
  2507. {
  2508. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2509. samples = SAMPLES_PER_CHUNK;
  2510. }
  2511. }
  2512. if (log_audio)
  2513. {
  2514. for (j = 0; j < samples; j++)
  2515. {
  2516. out_amp[2*j + 0] = amp[0][j];
  2517. out_amp[2*j + 1] = amp[1][j];
  2518. }
  2519. outframes = sf_writef_short(outhandle, out_amp, samples);
  2520. if (outframes != samples)
  2521. {
  2522. fprintf(stderr, " Error writing audio file\n");
  2523. exit(2);
  2524. }
  2525. }
  2526. #if 1
  2527. both_ways_line_model(model,
  2528. model_amp[0],
  2529. amp[0],
  2530. model_amp[1],
  2531. amp[1],
  2532. samples);
  2533. #else
  2534. vec_copyi16(model_amp[0], amp[0], samples);
  2535. vec_copyi16(model_amp[1], amp[1], samples);
  2536. #endif
  2537. v18_rx(v18[TESTER], model_amp[1], samples);
  2538. v18_rx(v18[TUT], model_amp[0], samples);
  2539. }
  2540. v18_free(v18[TESTER]);
  2541. v18_free(v18[TUT]);
  2542. printf("Test not yet implemented\n");
  2543. return 1;
  2544. }
  2545. /*- End of function --------------------------------------------------------*/
  2546. static void org_16_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2547. {
  2548. }
  2549. /*- End of function --------------------------------------------------------*/
  2550. static int test_org_16(void)
  2551. {
  2552. logging_state_t *logging;
  2553. int16_t amp[2][SAMPLES_PER_CHUNK];
  2554. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2555. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2556. int outframes;
  2557. int samples;
  2558. int push;
  2559. int i;
  2560. int j;
  2561. /*
  2562. III.5.4.2.16 980Hz detection
  2563. Purpose: To confirm correct selection of V.21 reverse mode.
  2564. Preamble: N/A
  2565. Method: The tester sends 980Hz to TUT for 5s.
  2566. Pass criteria: 1) TUT should respond with 1650Hz tone after 1.5+-0.1s after start of
  2567. 980Hz tone.
  2568. 2) Data should be transmitted and received at 300 bit/s complying with Annex F.
  2569. Comments: The TUT should indicate that V.21 mode has been selected.
  2570. */
  2571. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_16_put_text_msg, (void *) (intptr_t) 0);
  2572. logging = v18_get_logging_state(v18[TESTER]);
  2573. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2574. span_log_set_tag(logging, "Tester");
  2575. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_16_put_text_msg, (void *) (intptr_t) 1);
  2576. logging = v18_get_logging_state(v18[TUT]);
  2577. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2578. span_log_set_tag(logging, "TUT");
  2579. if ((model = both_ways_line_model_init(line_model_no,
  2580. noise_level,
  2581. echo_level_cpe1,
  2582. echo_level_co1,
  2583. line_model_no,
  2584. noise_level,
  2585. echo_level_cpe2,
  2586. echo_level_co2,
  2587. channel_codec,
  2588. rbs_pattern)) == NULL)
  2589. {
  2590. fprintf(stderr, " Failed to create line model\n");
  2591. exit(2);
  2592. }
  2593. result[TESTER][0] =
  2594. result[TUT][0] = '\0';
  2595. for (i = 0; i < 10000; i++)
  2596. {
  2597. for (j = 0; j < 2; j++)
  2598. {
  2599. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2600. push = 10;
  2601. if (samples < SAMPLES_PER_CHUNK)
  2602. {
  2603. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2604. samples = SAMPLES_PER_CHUNK;
  2605. }
  2606. }
  2607. if (log_audio)
  2608. {
  2609. for (j = 0; j < samples; j++)
  2610. {
  2611. out_amp[2*j + 0] = amp[0][j];
  2612. out_amp[2*j + 1] = amp[1][j];
  2613. }
  2614. outframes = sf_writef_short(outhandle, out_amp, samples);
  2615. if (outframes != samples)
  2616. {
  2617. fprintf(stderr, " Error writing audio file\n");
  2618. exit(2);
  2619. }
  2620. }
  2621. #if 1
  2622. both_ways_line_model(model,
  2623. model_amp[0],
  2624. amp[0],
  2625. model_amp[1],
  2626. amp[1],
  2627. samples);
  2628. #else
  2629. vec_copyi16(model_amp[0], amp[0], samples);
  2630. vec_copyi16(model_amp[1], amp[1], samples);
  2631. #endif
  2632. v18_rx(v18[TESTER], model_amp[1], samples);
  2633. v18_rx(v18[TUT], model_amp[0], samples);
  2634. }
  2635. v18_free(v18[TESTER]);
  2636. v18_free(v18[TUT]);
  2637. printf("Test not yet implemented\n");
  2638. return 1;
  2639. }
  2640. /*- End of function --------------------------------------------------------*/
  2641. static void org_17_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2642. {
  2643. }
  2644. /*- End of function --------------------------------------------------------*/
  2645. static int test_org_17(void)
  2646. {
  2647. logging_state_t *logging;
  2648. int16_t amp[2][SAMPLES_PER_CHUNK];
  2649. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2650. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2651. int outframes;
  2652. int samples;
  2653. int push;
  2654. int i;
  2655. int j;
  2656. /*
  2657. III.5.4.2.17 Loss of signal after 980Hz
  2658. Purpose: To confirm that TUT returns to the Monitor 1 state if 980Hz signal disappears.
  2659. Preamble: N/A
  2660. Method: The tester sends 980Hz to TUT for 1.2s followed by silence for 5s.
  2661. Pass criteria: TUT should not respond to the 980Hz tone and resume sending CI signals after a
  2662. maximum of 2.4s from the end of the 980Hz tone.
  2663. */
  2664. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_17_put_text_msg, (void *) (intptr_t) 0);
  2665. logging = v18_get_logging_state(v18[TESTER]);
  2666. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2667. span_log_set_tag(logging, "Tester");
  2668. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_17_put_text_msg, (void *) (intptr_t) 1);
  2669. logging = v18_get_logging_state(v18[TUT]);
  2670. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2671. span_log_set_tag(logging, "TUT");
  2672. if ((model = both_ways_line_model_init(line_model_no,
  2673. noise_level,
  2674. echo_level_cpe1,
  2675. echo_level_co1,
  2676. line_model_no,
  2677. noise_level,
  2678. echo_level_cpe2,
  2679. echo_level_co2,
  2680. channel_codec,
  2681. rbs_pattern)) == NULL)
  2682. {
  2683. fprintf(stderr, " Failed to create line model\n");
  2684. exit(2);
  2685. }
  2686. result[TESTER][0] =
  2687. result[TUT][0] = '\0';
  2688. for (i = 0; i < 10000; i++)
  2689. {
  2690. for (j = 0; j < 2; j++)
  2691. {
  2692. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2693. push = 10;
  2694. if (samples < SAMPLES_PER_CHUNK)
  2695. {
  2696. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2697. samples = SAMPLES_PER_CHUNK;
  2698. }
  2699. }
  2700. if (log_audio)
  2701. {
  2702. for (j = 0; j < samples; j++)
  2703. {
  2704. out_amp[2*j + 0] = amp[0][j];
  2705. out_amp[2*j + 1] = amp[1][j];
  2706. }
  2707. outframes = sf_writef_short(outhandle, out_amp, samples);
  2708. if (outframes != samples)
  2709. {
  2710. fprintf(stderr, " Error writing audio file\n");
  2711. exit(2);
  2712. }
  2713. }
  2714. #if 1
  2715. both_ways_line_model(model,
  2716. model_amp[0],
  2717. amp[0],
  2718. model_amp[1],
  2719. amp[1],
  2720. samples);
  2721. #else
  2722. vec_copyi16(model_amp[0], amp[0], samples);
  2723. vec_copyi16(model_amp[1], amp[1], samples);
  2724. #endif
  2725. v18_rx(v18[TESTER], model_amp[1], samples);
  2726. v18_rx(v18[TUT], model_amp[0], samples);
  2727. }
  2728. v18_free(v18[TESTER]);
  2729. v18_free(v18[TUT]);
  2730. printf("Test not yet implemented\n");
  2731. return 1;
  2732. }
  2733. /*- End of function --------------------------------------------------------*/
  2734. static void org_18_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2735. {
  2736. }
  2737. /*- End of function --------------------------------------------------------*/
  2738. static int test_org_18(void)
  2739. {
  2740. logging_state_t *logging;
  2741. int16_t amp[2][SAMPLES_PER_CHUNK];
  2742. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2743. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2744. int outframes;
  2745. int samples;
  2746. int push;
  2747. int i;
  2748. int j;
  2749. /*
  2750. III.5.4.2.18 Tr timer
  2751. Purpose: To confirm that TUT returns to the Monitor 1 state if Timer Tr expires.
  2752. Preamble: N/A
  2753. Method: The tester sends 980Hz to TUT for 1.2s followed by 1650Hz for 5s
  2754. with no pause.
  2755. Pass criteria: TUT should respond with 980Hz after 1.3+-0.1s of 1650Hz.
  2756. Comments: This implies timer Tr has expired 2s after the start of the 980Hz tone and
  2757. then 1650Hz has been detected for 0.5s.
  2758. */
  2759. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_18_put_text_msg, (void *) (intptr_t) 0);
  2760. logging = v18_get_logging_state(v18[TESTER]);
  2761. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2762. span_log_set_tag(logging, "Tester");
  2763. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_18_put_text_msg, (void *) (intptr_t) 1);
  2764. logging = v18_get_logging_state(v18[TUT]);
  2765. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2766. span_log_set_tag(logging, "TUT");
  2767. if ((model = both_ways_line_model_init(line_model_no,
  2768. noise_level,
  2769. echo_level_cpe1,
  2770. echo_level_co1,
  2771. line_model_no,
  2772. noise_level,
  2773. echo_level_cpe2,
  2774. echo_level_co2,
  2775. channel_codec,
  2776. rbs_pattern)) == NULL)
  2777. {
  2778. fprintf(stderr, " Failed to create line model\n");
  2779. exit(2);
  2780. }
  2781. result[TESTER][0] =
  2782. result[TUT][0] = '\0';
  2783. for (i = 0; i < 10000; i++)
  2784. {
  2785. for (j = 0; j < 2; j++)
  2786. {
  2787. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2788. push = 10;
  2789. if (samples < SAMPLES_PER_CHUNK)
  2790. {
  2791. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2792. samples = SAMPLES_PER_CHUNK;
  2793. }
  2794. }
  2795. if (log_audio)
  2796. {
  2797. for (j = 0; j < samples; j++)
  2798. {
  2799. out_amp[2*j + 0] = amp[0][j];
  2800. out_amp[2*j + 1] = amp[1][j];
  2801. }
  2802. outframes = sf_writef_short(outhandle, out_amp, samples);
  2803. if (outframes != samples)
  2804. {
  2805. fprintf(stderr, " Error writing audio file\n");
  2806. exit(2);
  2807. }
  2808. }
  2809. #if 1
  2810. both_ways_line_model(model,
  2811. model_amp[0],
  2812. amp[0],
  2813. model_amp[1],
  2814. amp[1],
  2815. samples);
  2816. #else
  2817. vec_copyi16(model_amp[0], amp[0], samples);
  2818. vec_copyi16(model_amp[1], amp[1], samples);
  2819. #endif
  2820. v18_rx(v18[TESTER], model_amp[1], samples);
  2821. v18_rx(v18[TUT], model_amp[0], samples);
  2822. }
  2823. v18_free(v18[TESTER]);
  2824. v18_free(v18[TUT]);
  2825. printf("Test not yet implemented\n");
  2826. return 1;
  2827. }
  2828. /*- End of function --------------------------------------------------------*/
  2829. static void org_19_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2830. {
  2831. }
  2832. /*- End of function --------------------------------------------------------*/
  2833. static int test_org_19(void)
  2834. {
  2835. logging_state_t *logging;
  2836. int16_t amp[2][SAMPLES_PER_CHUNK];
  2837. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2838. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2839. int outframes;
  2840. int samples;
  2841. int push;
  2842. int i;
  2843. int j;
  2844. /*
  2845. III.5.4.2.19 Bell 103 (1270Hz signal) detection
  2846. Purpose: To confirm correct selection of Bell 103 reverse mode.
  2847. Preamble: N/A
  2848. Method: The tester sends 1270Hz to TUT for 5s.
  2849. Pass criteria: 1) TUT should respond with 2225Hz tone after 0.7+-0.1 s.
  2850. 2) Data should be transmitted and received at 300 bit/s complying with Annex D.
  2851. Comments: The TUT should indicate that Bell 103 mode has been selected.
  2852. */
  2853. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_19_put_text_msg, (void *) (intptr_t) 0);
  2854. logging = v18_get_logging_state(v18[TESTER]);
  2855. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2856. span_log_set_tag(logging, "Tester");
  2857. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_19_put_text_msg, (void *) (intptr_t) 1);
  2858. logging = v18_get_logging_state(v18[TUT]);
  2859. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2860. span_log_set_tag(logging, "TUT");
  2861. if ((model = both_ways_line_model_init(line_model_no,
  2862. noise_level,
  2863. echo_level_cpe1,
  2864. echo_level_co1,
  2865. line_model_no,
  2866. noise_level,
  2867. echo_level_cpe2,
  2868. echo_level_co2,
  2869. channel_codec,
  2870. rbs_pattern)) == NULL)
  2871. {
  2872. fprintf(stderr, " Failed to create line model\n");
  2873. exit(2);
  2874. }
  2875. result[TESTER][0] =
  2876. result[TUT][0] = '\0';
  2877. for (i = 0; i < 10000; i++)
  2878. {
  2879. for (j = 0; j < 2; j++)
  2880. {
  2881. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2882. push = 10;
  2883. if (samples < SAMPLES_PER_CHUNK)
  2884. {
  2885. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2886. samples = SAMPLES_PER_CHUNK;
  2887. }
  2888. }
  2889. if (log_audio)
  2890. {
  2891. for (j = 0; j < samples; j++)
  2892. {
  2893. out_amp[2*j + 0] = amp[0][j];
  2894. out_amp[2*j + 1] = amp[1][j];
  2895. }
  2896. outframes = sf_writef_short(outhandle, out_amp, samples);
  2897. if (outframes != samples)
  2898. {
  2899. fprintf(stderr, " Error writing audio file\n");
  2900. exit(2);
  2901. }
  2902. }
  2903. #if 1
  2904. both_ways_line_model(model,
  2905. model_amp[0],
  2906. amp[0],
  2907. model_amp[1],
  2908. amp[1],
  2909. samples);
  2910. #else
  2911. vec_copyi16(model_amp[0], amp[0], samples);
  2912. vec_copyi16(model_amp[1], amp[1], samples);
  2913. #endif
  2914. v18_rx(v18[TESTER], model_amp[1], samples);
  2915. v18_rx(v18[TUT], model_amp[0], samples);
  2916. }
  2917. v18_free(v18[TESTER]);
  2918. v18_free(v18[TUT]);
  2919. printf("Test not yet implemented\n");
  2920. return 1;
  2921. }
  2922. /*- End of function --------------------------------------------------------*/
  2923. static void org_20_put_text_msg(void *user_data, const uint8_t *msg, int len)
  2924. {
  2925. }
  2926. /*- End of function --------------------------------------------------------*/
  2927. static int test_org_20(void)
  2928. {
  2929. logging_state_t *logging;
  2930. int16_t amp[2][SAMPLES_PER_CHUNK];
  2931. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  2932. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  2933. int outframes;
  2934. int samples;
  2935. int push;
  2936. int i;
  2937. int j;
  2938. /*
  2939. III.5.4.2.20 Immunity to network tones
  2940. Purpose: To ensure that the TUT does not interpret network tones as valid signals.
  2941. Preamble: N/A
  2942. Method: The tester will first send a dial tone to the TUT, this will be followed by a ringing
  2943. tone and a network congestion tone. The frequencies and cadences of the tones will
  2944. vary according to the country setting. The tester must be configured for the same
  2945. country as the TUT.
  2946. Pass criteria: The countries supported by the TUT should be noted along with the response to
  2947. each tone. The tones should either be ignored or reported as the relevant network
  2948. tone to the user.
  2949. Comments: V.18 is required to recognize and report RINGING and BUSY tones. Other network
  2950. tones may be ignored. Some devices may only provide a visual indication of the
  2951. presence and cadence of the tones for instance by a flashing light. The TUT may
  2952. disconnect on reception of tones indicating a failed call attempt.
  2953. */
  2954. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_20_put_text_msg, (void *) (intptr_t) 0);
  2955. logging = v18_get_logging_state(v18[TESTER]);
  2956. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2957. span_log_set_tag(logging, "Tester");
  2958. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_20_put_text_msg, (void *) (intptr_t) 1);
  2959. logging = v18_get_logging_state(v18[TUT]);
  2960. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  2961. span_log_set_tag(logging, "TUT");
  2962. if ((model = both_ways_line_model_init(line_model_no,
  2963. noise_level,
  2964. echo_level_cpe1,
  2965. echo_level_co1,
  2966. line_model_no,
  2967. noise_level,
  2968. echo_level_cpe2,
  2969. echo_level_co2,
  2970. channel_codec,
  2971. rbs_pattern)) == NULL)
  2972. {
  2973. fprintf(stderr, " Failed to create line model\n");
  2974. exit(2);
  2975. }
  2976. result[TESTER][0] =
  2977. result[TUT][0] = '\0';
  2978. for (i = 0; i < 10000; i++)
  2979. {
  2980. for (j = 0; j < 2; j++)
  2981. {
  2982. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  2983. push = 10;
  2984. if (samples < SAMPLES_PER_CHUNK)
  2985. {
  2986. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  2987. samples = SAMPLES_PER_CHUNK;
  2988. }
  2989. }
  2990. if (log_audio)
  2991. {
  2992. for (j = 0; j < samples; j++)
  2993. {
  2994. out_amp[2*j + 0] = amp[0][j];
  2995. out_amp[2*j + 1] = amp[1][j];
  2996. }
  2997. outframes = sf_writef_short(outhandle, out_amp, samples);
  2998. if (outframes != samples)
  2999. {
  3000. fprintf(stderr, " Error writing audio file\n");
  3001. exit(2);
  3002. }
  3003. }
  3004. #if 1
  3005. both_ways_line_model(model,
  3006. model_amp[0],
  3007. amp[0],
  3008. model_amp[1],
  3009. amp[1],
  3010. samples);
  3011. #else
  3012. vec_copyi16(model_amp[0], amp[0], samples);
  3013. vec_copyi16(model_amp[1], amp[1], samples);
  3014. #endif
  3015. v18_rx(v18[TESTER], model_amp[1], samples);
  3016. v18_rx(v18[TUT], model_amp[0], samples);
  3017. }
  3018. v18_free(v18[TESTER]);
  3019. v18_free(v18[TUT]);
  3020. printf("Test not yet implemented\n");
  3021. return 1;
  3022. }
  3023. /*- End of function --------------------------------------------------------*/
  3024. static void org_21_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3025. {
  3026. }
  3027. /*- End of function --------------------------------------------------------*/
  3028. static int test_org_21(void)
  3029. {
  3030. logging_state_t *logging;
  3031. int16_t amp[2][SAMPLES_PER_CHUNK];
  3032. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3033. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3034. int outframes;
  3035. int samples;
  3036. int push;
  3037. int i;
  3038. int j;
  3039. /*
  3040. III.5.4.2.21 Immunity to non-textphone modems
  3041. Purpose: To ensure that the TUT does not interpret modem tones not supported by V.18 as
  3042. valid text telephone tones.
  3043. Preamble: N/A
  3044. Method: The tester will respond with an ANS tone (2100Hz) followed by simulated (a)
  3045. V.32 bis and (b) V.34 modem training sequences.
  3046. Pass criteria: The tones should either be ignored or reported back to the user. No textphone
  3047. modem should be selected.
  3048. Comments: Some high speed modems may fall back to a compatibility mode, e.g. V.21 or V.23
  3049. that should be correctly detected by the TUT.
  3050. */
  3051. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_21_put_text_msg, (void *) (intptr_t) 0);
  3052. logging = v18_get_logging_state(v18[TESTER]);
  3053. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3054. span_log_set_tag(logging, "Tester");
  3055. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_21_put_text_msg, (void *) (intptr_t) 1);
  3056. logging = v18_get_logging_state(v18[TUT]);
  3057. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3058. span_log_set_tag(logging, "TUT");
  3059. if ((model = both_ways_line_model_init(line_model_no,
  3060. noise_level,
  3061. echo_level_cpe1,
  3062. echo_level_co1,
  3063. line_model_no,
  3064. noise_level,
  3065. echo_level_cpe2,
  3066. echo_level_co2,
  3067. channel_codec,
  3068. rbs_pattern)) == NULL)
  3069. {
  3070. fprintf(stderr, " Failed to create line model\n");
  3071. exit(2);
  3072. }
  3073. result[TESTER][0] =
  3074. result[TUT][0] = '\0';
  3075. for (i = 0; i < 10000; i++)
  3076. {
  3077. for (j = 0; j < 2; j++)
  3078. {
  3079. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3080. push = 10;
  3081. if (samples < SAMPLES_PER_CHUNK)
  3082. {
  3083. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3084. samples = SAMPLES_PER_CHUNK;
  3085. }
  3086. }
  3087. if (log_audio)
  3088. {
  3089. for (j = 0; j < samples; j++)
  3090. {
  3091. out_amp[2*j + 0] = amp[0][j];
  3092. out_amp[2*j + 1] = amp[1][j];
  3093. }
  3094. outframes = sf_writef_short(outhandle, out_amp, samples);
  3095. if (outframes != samples)
  3096. {
  3097. fprintf(stderr, " Error writing audio file\n");
  3098. exit(2);
  3099. }
  3100. }
  3101. #if 1
  3102. both_ways_line_model(model,
  3103. model_amp[0],
  3104. amp[0],
  3105. model_amp[1],
  3106. amp[1],
  3107. samples);
  3108. #else
  3109. vec_copyi16(model_amp[0], amp[0], samples);
  3110. vec_copyi16(model_amp[1], amp[1], samples);
  3111. #endif
  3112. v18_rx(v18[TESTER], model_amp[1], samples);
  3113. v18_rx(v18[TUT], model_amp[0], samples);
  3114. }
  3115. v18_free(v18[TESTER]);
  3116. v18_free(v18[TUT]);
  3117. printf("Test not yet implemented\n");
  3118. return 1;
  3119. }
  3120. /*- End of function --------------------------------------------------------*/
  3121. static void org_22_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3122. {
  3123. }
  3124. /*- End of function --------------------------------------------------------*/
  3125. static int test_org_22(void)
  3126. {
  3127. logging_state_t *logging;
  3128. int16_t amp[2][SAMPLES_PER_CHUNK];
  3129. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3130. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3131. int outframes;
  3132. int samples;
  3133. int push;
  3134. int i;
  3135. int j;
  3136. /*
  3137. III.5.4.2.22 Immunity to fax tones
  3138. Purpose: To ensure that the TUT will not interpret a called fax machine as being a textphone.
  3139. Preamble: N/A
  3140. Method: The tester will respond as if it were a typical group 3 fax machine in automatic
  3141. answer mode. It should send a CED tone (2100Hz) plus Digital Identification
  3142. Signal (DIS) as defined in ITU-T T.30.
  3143. Pass criteria: The TUT should ignore the received tones.
  3144. Comments: Ideally the TUT should detect the presence of a fax machine and report it back to
  3145. the user.
  3146. */
  3147. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_22_put_text_msg, (void *) (intptr_t) 0);
  3148. logging = v18_get_logging_state(v18[TESTER]);
  3149. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3150. span_log_set_tag(logging, "Tester");
  3151. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_22_put_text_msg, (void *) (intptr_t) 1);
  3152. logging = v18_get_logging_state(v18[TUT]);
  3153. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3154. span_log_set_tag(logging, "TUT");
  3155. if ((model = both_ways_line_model_init(line_model_no,
  3156. noise_level,
  3157. echo_level_cpe1,
  3158. echo_level_co1,
  3159. line_model_no,
  3160. noise_level,
  3161. echo_level_cpe2,
  3162. echo_level_co2,
  3163. channel_codec,
  3164. rbs_pattern)) == NULL)
  3165. {
  3166. fprintf(stderr, " Failed to create line model\n");
  3167. exit(2);
  3168. }
  3169. result[TESTER][0] =
  3170. result[TUT][0] = '\0';
  3171. for (i = 0; i < 10000; i++)
  3172. {
  3173. for (j = 0; j < 2; j++)
  3174. {
  3175. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3176. push = 10;
  3177. if (samples < SAMPLES_PER_CHUNK)
  3178. {
  3179. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3180. samples = SAMPLES_PER_CHUNK;
  3181. }
  3182. }
  3183. if (log_audio)
  3184. {
  3185. for (j = 0; j < samples; j++)
  3186. {
  3187. out_amp[2*j + 0] = amp[0][j];
  3188. out_amp[2*j + 1] = amp[1][j];
  3189. }
  3190. outframes = sf_writef_short(outhandle, out_amp, samples);
  3191. if (outframes != samples)
  3192. {
  3193. fprintf(stderr, " Error writing audio file\n");
  3194. exit(2);
  3195. }
  3196. }
  3197. #if 1
  3198. both_ways_line_model(model,
  3199. model_amp[0],
  3200. amp[0],
  3201. model_amp[1],
  3202. amp[1],
  3203. samples);
  3204. #else
  3205. vec_copyi16(model_amp[0], amp[0], samples);
  3206. vec_copyi16(model_amp[1], amp[1], samples);
  3207. #endif
  3208. v18_rx(v18[TESTER], model_amp[1], samples);
  3209. v18_rx(v18[TUT], model_amp[0], samples);
  3210. }
  3211. v18_free(v18[TESTER]);
  3212. v18_free(v18[TUT]);
  3213. printf("Test not yet implemented\n");
  3214. return 1;
  3215. }
  3216. /*- End of function --------------------------------------------------------*/
  3217. static void org_23_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3218. {
  3219. }
  3220. /*- End of function --------------------------------------------------------*/
  3221. static int test_org_23(void)
  3222. {
  3223. logging_state_t *logging;
  3224. int16_t amp[2][SAMPLES_PER_CHUNK];
  3225. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3226. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3227. int outframes;
  3228. int samples;
  3229. int push;
  3230. int i;
  3231. int j;
  3232. /*
  3233. III.5.4.2.23 Immunity to voice
  3234. Purpose: To ensure that the TUT does not misinterpret speech as a valid textphone signal.
  3235. Preamble: N/A
  3236. Method: The tester will respond with sampled speech. A number of phrases recorded from
  3237. typical male and female speakers will be transmitted. This will include a typical
  3238. network announcement.
  3239. Pass criteria: The TUT should ignore the speech.
  3240. Comments: Ideally the TUT should report the presence of speech back to the user, e.g. via
  3241. circuit 135.
  3242. */
  3243. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_23_put_text_msg, (void *) (intptr_t) 0);
  3244. logging = v18_get_logging_state(v18[TESTER]);
  3245. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3246. span_log_set_tag(logging, "Tester");
  3247. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_23_put_text_msg, (void *) (intptr_t) 1);
  3248. logging = v18_get_logging_state(v18[TUT]);
  3249. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3250. span_log_set_tag(logging, "TUT");
  3251. if ((model = both_ways_line_model_init(line_model_no,
  3252. noise_level,
  3253. echo_level_cpe1,
  3254. echo_level_co1,
  3255. line_model_no,
  3256. noise_level,
  3257. echo_level_cpe2,
  3258. echo_level_co2,
  3259. channel_codec,
  3260. rbs_pattern)) == NULL)
  3261. {
  3262. fprintf(stderr, " Failed to create line model\n");
  3263. exit(2);
  3264. }
  3265. result[TESTER][0] =
  3266. result[TUT][0] = '\0';
  3267. for (i = 0; i < 10000; i++)
  3268. {
  3269. for (j = 0; j < 2; j++)
  3270. {
  3271. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3272. push = 10;
  3273. if (samples < SAMPLES_PER_CHUNK)
  3274. {
  3275. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3276. samples = SAMPLES_PER_CHUNK;
  3277. }
  3278. }
  3279. if (log_audio)
  3280. {
  3281. for (j = 0; j < samples; j++)
  3282. {
  3283. out_amp[2*j + 0] = amp[0][j];
  3284. out_amp[2*j + 1] = amp[1][j];
  3285. }
  3286. outframes = sf_writef_short(outhandle, out_amp, samples);
  3287. if (outframes != samples)
  3288. {
  3289. fprintf(stderr, " Error writing audio file\n");
  3290. exit(2);
  3291. }
  3292. }
  3293. #if 1
  3294. both_ways_line_model(model,
  3295. model_amp[0],
  3296. amp[0],
  3297. model_amp[1],
  3298. amp[1],
  3299. samples);
  3300. #else
  3301. vec_copyi16(model_amp[0], amp[0], samples);
  3302. vec_copyi16(model_amp[1], amp[1], samples);
  3303. #endif
  3304. v18_rx(v18[TESTER], model_amp[1], samples);
  3305. v18_rx(v18[TUT], model_amp[0], samples);
  3306. }
  3307. v18_free(v18[TESTER]);
  3308. v18_free(v18[TUT]);
  3309. printf("Test not yet implemented\n");
  3310. return 1;
  3311. }
  3312. /*- End of function --------------------------------------------------------*/
  3313. static void org_24_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3314. {
  3315. }
  3316. /*- End of function --------------------------------------------------------*/
  3317. static int test_org_24(void)
  3318. {
  3319. logging_state_t *logging;
  3320. int16_t amp[2][SAMPLES_PER_CHUNK];
  3321. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3322. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3323. int outframes;
  3324. int samples;
  3325. int push;
  3326. int i;
  3327. int j;
  3328. /*
  3329. III.5.4.2.24 ANSam signal detection
  3330. Purpose: To verify that TUT correctly detects the ANSam (2100Hz modulated) signal during
  3331. the two-second interval (Toff) between transmission of CI sequences.
  3332. Preamble: Make a V.18 call from the TUT.
  3333. Method: The Test System waits for the TUT to stop transmitting a CI and responds with an
  3334. ANSam signal. The V.21 demodulator is used to decode the CM sequence. ANSam
  3335. should be transmitted for 2s.
  3336. Pass criteria: 1) No signal should be transmitted by TUT for 0.5s from detection of
  3337. ANSam.
  3338. 2) The TUT should reply with transmission of CM as defined in 5.2.13.
  3339. 3) Verify that CM sequence has correct bit pattern.
  3340. */
  3341. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_24_put_text_msg, (void *) (intptr_t) 0);
  3342. logging = v18_get_logging_state(v18[TESTER]);
  3343. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3344. span_log_set_tag(logging, "Tester");
  3345. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_24_put_text_msg, (void *) (intptr_t) 1);
  3346. logging = v18_get_logging_state(v18[TUT]);
  3347. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3348. span_log_set_tag(logging, "TUT");
  3349. if ((model = both_ways_line_model_init(line_model_no,
  3350. noise_level,
  3351. echo_level_cpe1,
  3352. echo_level_co1,
  3353. line_model_no,
  3354. noise_level,
  3355. echo_level_cpe2,
  3356. echo_level_co2,
  3357. channel_codec,
  3358. rbs_pattern)) == NULL)
  3359. {
  3360. fprintf(stderr, " Failed to create line model\n");
  3361. exit(2);
  3362. }
  3363. result[TESTER][0] =
  3364. result[TUT][0] = '\0';
  3365. for (i = 0; i < 10000; i++)
  3366. {
  3367. for (j = 0; j < 2; j++)
  3368. {
  3369. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3370. push = 10;
  3371. if (samples < SAMPLES_PER_CHUNK)
  3372. {
  3373. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3374. samples = SAMPLES_PER_CHUNK;
  3375. }
  3376. }
  3377. if (log_audio)
  3378. {
  3379. for (j = 0; j < samples; j++)
  3380. {
  3381. out_amp[2*j + 0] = amp[0][j];
  3382. out_amp[2*j + 1] = amp[1][j];
  3383. }
  3384. outframes = sf_writef_short(outhandle, out_amp, samples);
  3385. if (outframes != samples)
  3386. {
  3387. fprintf(stderr, " Error writing audio file\n");
  3388. exit(2);
  3389. }
  3390. }
  3391. #if 1
  3392. both_ways_line_model(model,
  3393. model_amp[0],
  3394. amp[0],
  3395. model_amp[1],
  3396. amp[1],
  3397. samples);
  3398. #else
  3399. vec_copyi16(model_amp[0], amp[0], samples);
  3400. vec_copyi16(model_amp[1], amp[1], samples);
  3401. #endif
  3402. v18_rx(v18[TESTER], model_amp[1], samples);
  3403. v18_rx(v18[TUT], model_amp[0], samples);
  3404. }
  3405. v18_free(v18[TESTER]);
  3406. v18_free(v18[TUT]);
  3407. printf("Test not yet implemented\n");
  3408. return 1;
  3409. }
  3410. /*- End of function --------------------------------------------------------*/
  3411. static void org_25_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3412. {
  3413. }
  3414. /*- End of function --------------------------------------------------------*/
  3415. static int test_org_25(void)
  3416. {
  3417. logging_state_t *logging;
  3418. int16_t amp[2][SAMPLES_PER_CHUNK];
  3419. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3420. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3421. int outframes;
  3422. int samples;
  3423. int push;
  3424. int i;
  3425. int j;
  3426. /*
  3427. III.5.4.2.25 V.8 calling procedure
  3428. Purpose: To verify that TUT correctly performs a V.8 call negotiation.
  3429. Preamble: Make a V.18 call from the TUT. Answer with ANSam from the Tester and with JM
  3430. for V.21 on the CM.
  3431. Method: The Test System waits for the TUT to start transmitting V.21 carrier (1).
  3432. Pass criteria: The TUT should connect by sending V.21 carrier (1).
  3433. */
  3434. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_25_put_text_msg, (void *) (intptr_t) 0);
  3435. logging = v18_get_logging_state(v18[TESTER]);
  3436. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3437. span_log_set_tag(logging, "Tester");
  3438. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, org_25_put_text_msg, (void *) (intptr_t) 1);
  3439. logging = v18_get_logging_state(v18[TUT]);
  3440. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3441. span_log_set_tag(logging, "TUT");
  3442. if ((model = both_ways_line_model_init(line_model_no,
  3443. noise_level,
  3444. echo_level_cpe1,
  3445. echo_level_co1,
  3446. line_model_no,
  3447. noise_level,
  3448. echo_level_cpe2,
  3449. echo_level_co2,
  3450. channel_codec,
  3451. rbs_pattern)) == NULL)
  3452. {
  3453. fprintf(stderr, " Failed to create line model\n");
  3454. exit(2);
  3455. }
  3456. result[TESTER][0] =
  3457. result[TUT][0] = '\0';
  3458. for (i = 0; i < 10000; i++)
  3459. {
  3460. for (j = 0; j < 2; j++)
  3461. {
  3462. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3463. push = 10;
  3464. if (samples < SAMPLES_PER_CHUNK)
  3465. {
  3466. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3467. samples = SAMPLES_PER_CHUNK;
  3468. }
  3469. }
  3470. if (log_audio)
  3471. {
  3472. for (j = 0; j < samples; j++)
  3473. {
  3474. out_amp[2*j + 0] = amp[0][j];
  3475. out_amp[2*j + 1] = amp[1][j];
  3476. }
  3477. outframes = sf_writef_short(outhandle, out_amp, samples);
  3478. if (outframes != samples)
  3479. {
  3480. fprintf(stderr, " Error writing audio file\n");
  3481. exit(2);
  3482. }
  3483. }
  3484. #if 1
  3485. both_ways_line_model(model,
  3486. model_amp[0],
  3487. amp[0],
  3488. model_amp[1],
  3489. amp[1],
  3490. samples);
  3491. #else
  3492. vec_copyi16(model_amp[0], amp[0], samples);
  3493. vec_copyi16(model_amp[1], amp[1], samples);
  3494. #endif
  3495. v18_rx(v18[TESTER], model_amp[1], samples);
  3496. v18_rx(v18[TUT], model_amp[0], samples);
  3497. }
  3498. v18_free(v18[TESTER]);
  3499. v18_free(v18[TUT]);
  3500. printf("Test not yet implemented\n");
  3501. return 1;
  3502. }
  3503. /*- End of function --------------------------------------------------------*/
  3504. static void ans_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3505. {
  3506. }
  3507. /*- End of function --------------------------------------------------------*/
  3508. static int test_ans_01(void)
  3509. {
  3510. logging_state_t *logging;
  3511. int16_t amp[2][SAMPLES_PER_CHUNK];
  3512. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3513. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3514. int outframes;
  3515. int samples;
  3516. int push;
  3517. int i;
  3518. int j;
  3519. /*
  3520. III.5.4.3.1 Ta timer
  3521. Purpose: To ensure that on connecting the call, the DCE starts timer Ta (3s) and on
  3522. expiry begins probing.
  3523. Preamble: N/A
  3524. Method: The tester makes a call to the TUT and attempts to determine when the TUT
  3525. answers the call. It will then monitor for any signal.
  3526. Pass criteria: The TUT should start probing 3s after answering the call.
  3527. */
  3528. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_01_put_text_msg, (void *) (intptr_t) 0);
  3529. logging = v18_get_logging_state(v18[TESTER]);
  3530. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3531. span_log_set_tag(logging, "Tester");
  3532. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_01_put_text_msg, (void *) (intptr_t) 1);
  3533. logging = v18_get_logging_state(v18[TUT]);
  3534. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3535. span_log_set_tag(logging, "TUT");
  3536. if ((model = both_ways_line_model_init(line_model_no,
  3537. noise_level,
  3538. echo_level_cpe1,
  3539. echo_level_co1,
  3540. line_model_no,
  3541. noise_level,
  3542. echo_level_cpe2,
  3543. echo_level_co2,
  3544. channel_codec,
  3545. rbs_pattern)) == NULL)
  3546. {
  3547. fprintf(stderr, " Failed to create line model\n");
  3548. exit(2);
  3549. }
  3550. result[TESTER][0] =
  3551. result[TUT][0] = '\0';
  3552. for (i = 0; i < 10000; i++)
  3553. {
  3554. for (j = 0; j < 2; j++)
  3555. {
  3556. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3557. push = 10;
  3558. if (samples < SAMPLES_PER_CHUNK)
  3559. {
  3560. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3561. samples = SAMPLES_PER_CHUNK;
  3562. }
  3563. }
  3564. if (log_audio)
  3565. {
  3566. for (j = 0; j < samples; j++)
  3567. {
  3568. out_amp[2*j + 0] = amp[0][j];
  3569. out_amp[2*j + 1] = amp[1][j];
  3570. }
  3571. outframes = sf_writef_short(outhandle, out_amp, samples);
  3572. if (outframes != samples)
  3573. {
  3574. fprintf(stderr, " Error writing audio file\n");
  3575. exit(2);
  3576. }
  3577. }
  3578. #if 1
  3579. both_ways_line_model(model,
  3580. model_amp[0],
  3581. amp[0],
  3582. model_amp[1],
  3583. amp[1],
  3584. samples);
  3585. #else
  3586. vec_copyi16(model_amp[0], amp[0], samples);
  3587. vec_copyi16(model_amp[1], amp[1], samples);
  3588. #endif
  3589. v18_rx(v18[TESTER], model_amp[1], samples);
  3590. v18_rx(v18[TUT], model_amp[0], samples);
  3591. }
  3592. v18_free(v18[TESTER]);
  3593. v18_free(v18[TUT]);
  3594. printf("Test not yet implemented\n");
  3595. return 1;
  3596. }
  3597. /*- End of function --------------------------------------------------------*/
  3598. static void ans_02_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3599. {
  3600. }
  3601. /*- End of function --------------------------------------------------------*/
  3602. static int test_ans_02(void)
  3603. {
  3604. logging_state_t *logging;
  3605. int16_t amp[2][SAMPLES_PER_CHUNK];
  3606. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3607. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3608. int outframes;
  3609. int samples;
  3610. int push;
  3611. int i;
  3612. int j;
  3613. /*
  3614. III.5.4.3.2 CI signal detection
  3615. Purpose: To confirm the correct detection and response to the V.18 CI signal.
  3616. Preamble: N/A
  3617. Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. It will
  3618. monitor for ANS and measure duration.
  3619. Pass criteria: 1) The TUT should respond after either the first or second CI with ANSam tone.
  3620. 2) ANSam tone should remain for 3s+-0.5s followed by silence.
  3621. Comments: The ANSam tone is a modulated 2100Hz tone. It may have phase reversals. The
  3622. XCI signal is tested in a separate test.
  3623. */
  3624. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_02_put_text_msg, (void *) (intptr_t) 0);
  3625. logging = v18_get_logging_state(v18[TESTER]);
  3626. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3627. span_log_set_tag(logging, "Tester");
  3628. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_02_put_text_msg, (void *) (intptr_t) 1);
  3629. logging = v18_get_logging_state(v18[TUT]);
  3630. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3631. span_log_set_tag(logging, "TUT");
  3632. if ((model = both_ways_line_model_init(line_model_no,
  3633. noise_level,
  3634. echo_level_cpe1,
  3635. echo_level_co1,
  3636. line_model_no,
  3637. noise_level,
  3638. echo_level_cpe2,
  3639. echo_level_co2,
  3640. channel_codec,
  3641. rbs_pattern)) == NULL)
  3642. {
  3643. fprintf(stderr, " Failed to create line model\n");
  3644. exit(2);
  3645. }
  3646. result[TESTER][0] =
  3647. result[TUT][0] = '\0';
  3648. for (i = 0; i < 10000; i++)
  3649. {
  3650. for (j = 0; j < 2; j++)
  3651. {
  3652. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3653. push = 10;
  3654. if (samples < SAMPLES_PER_CHUNK)
  3655. {
  3656. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3657. samples = SAMPLES_PER_CHUNK;
  3658. }
  3659. }
  3660. if (log_audio)
  3661. {
  3662. for (j = 0; j < samples; j++)
  3663. {
  3664. out_amp[2*j + 0] = amp[0][j];
  3665. out_amp[2*j + 1] = amp[1][j];
  3666. }
  3667. outframes = sf_writef_short(outhandle, out_amp, samples);
  3668. if (outframes != samples)
  3669. {
  3670. fprintf(stderr, " Error writing audio file\n");
  3671. exit(2);
  3672. }
  3673. }
  3674. #if 1
  3675. both_ways_line_model(model,
  3676. model_amp[0],
  3677. amp[0],
  3678. model_amp[1],
  3679. amp[1],
  3680. samples);
  3681. #else
  3682. vec_copyi16(model_amp[0], amp[0], samples);
  3683. vec_copyi16(model_amp[1], amp[1], samples);
  3684. #endif
  3685. v18_rx(v18[TESTER], model_amp[1], samples);
  3686. v18_rx(v18[TUT], model_amp[0], samples);
  3687. }
  3688. v18_free(v18[TESTER]);
  3689. v18_free(v18[TUT]);
  3690. printf("Test not yet implemented\n");
  3691. return 1;
  3692. }
  3693. /*- End of function --------------------------------------------------------*/
  3694. static void ans_03_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3695. {
  3696. }
  3697. /*- End of function --------------------------------------------------------*/
  3698. static int test_ans_03(void)
  3699. {
  3700. logging_state_t *logging;
  3701. int16_t amp[2][SAMPLES_PER_CHUNK];
  3702. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3703. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3704. int outframes;
  3705. int samples;
  3706. int push;
  3707. int i;
  3708. int j;
  3709. /*
  3710. III.5.4.3.3 Early termination of ANSam tone
  3711. Purpose: To confirm that the TUT will respond correctly to TXP signals, i.e. by stopping
  3712. ANSam tone on reception of TXP signal.
  3713. Preamble: N/A
  3714. Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. On
  3715. reception of the ANSam tone the tester will wait 0.5s and then begin
  3716. transmitting the TXP signal in V.21 (1) mode.
  3717. Pass criteria: 1) On reception of the TXP signal, the TUT should remain silent for 75+-5ms.
  3718. 2) The TUT should then transmit 3 TXP sequences in V.21(2) mode.
  3719. 3) The 3 TXPs should be followed by continuous 1650Hz.
  3720. 4) Correct transmission and reception of T.140 data should be verified after the
  3721. V.18 mode connection is completed.
  3722. Comments: The TUT should indicate V.18 mode.
  3723. */
  3724. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_03_put_text_msg, (void *) (intptr_t) 0);
  3725. logging = v18_get_logging_state(v18[TESTER]);
  3726. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3727. span_log_set_tag(logging, "Tester");
  3728. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_03_put_text_msg, (void *) (intptr_t) 1);
  3729. logging = v18_get_logging_state(v18[TUT]);
  3730. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3731. span_log_set_tag(logging, "TUT");
  3732. if ((model = both_ways_line_model_init(line_model_no,
  3733. noise_level,
  3734. echo_level_cpe1,
  3735. echo_level_co1,
  3736. line_model_no,
  3737. noise_level,
  3738. echo_level_cpe2,
  3739. echo_level_co2,
  3740. channel_codec,
  3741. rbs_pattern)) == NULL)
  3742. {
  3743. fprintf(stderr, " Failed to create line model\n");
  3744. exit(2);
  3745. }
  3746. result[TESTER][0] =
  3747. result[TUT][0] = '\0';
  3748. for (i = 0; i < 10000; i++)
  3749. {
  3750. for (j = 0; j < 2; j++)
  3751. {
  3752. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3753. push = 10;
  3754. if (samples < SAMPLES_PER_CHUNK)
  3755. {
  3756. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3757. samples = SAMPLES_PER_CHUNK;
  3758. }
  3759. }
  3760. if (log_audio)
  3761. {
  3762. for (j = 0; j < samples; j++)
  3763. {
  3764. out_amp[2*j + 0] = amp[0][j];
  3765. out_amp[2*j + 1] = amp[1][j];
  3766. }
  3767. outframes = sf_writef_short(outhandle, out_amp, samples);
  3768. if (outframes != samples)
  3769. {
  3770. fprintf(stderr, " Error writing audio file\n");
  3771. exit(2);
  3772. }
  3773. }
  3774. #if 1
  3775. both_ways_line_model(model,
  3776. model_amp[0],
  3777. amp[0],
  3778. model_amp[1],
  3779. amp[1],
  3780. samples);
  3781. #else
  3782. vec_copyi16(model_amp[0], amp[0], samples);
  3783. vec_copyi16(model_amp[1], amp[1], samples);
  3784. #endif
  3785. v18_rx(v18[TESTER], model_amp[1], samples);
  3786. v18_rx(v18[TUT], model_amp[0], samples);
  3787. }
  3788. v18_free(v18[TESTER]);
  3789. v18_free(v18[TUT]);
  3790. printf("Test not yet implemented\n");
  3791. return 1;
  3792. }
  3793. /*- End of function --------------------------------------------------------*/
  3794. static void ans_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3795. {
  3796. }
  3797. /*- End of function --------------------------------------------------------*/
  3798. static int test_ans_04(void)
  3799. {
  3800. logging_state_t *logging;
  3801. int16_t amp[2][SAMPLES_PER_CHUNK];
  3802. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3803. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3804. int outframes;
  3805. int samples;
  3806. int push;
  3807. int i;
  3808. int j;
  3809. /*
  3810. III.5.4.3.4 Tt timer
  3811. Purpose: To ensure that after detection of ANSam the TUT will return to Monitor A after
  3812. timer Tt expires.
  3813. Preamble: Successful completion of test ANS-03.
  3814. Method: After completion of test ANS-03 the tester will continue to monitor for signals.
  3815. Pass criteria: The TUT should start probing 3s after ANSam disappears.
  3816. Comments: It is assumed that timer Ta is restarted on return to Monitor A.
  3817. */
  3818. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_04_put_text_msg, (void *) (intptr_t) 0);
  3819. logging = v18_get_logging_state(v18[TESTER]);
  3820. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3821. span_log_set_tag(logging, "Tester");
  3822. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_04_put_text_msg, (void *) (intptr_t) 1);
  3823. logging = v18_get_logging_state(v18[TUT]);
  3824. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3825. span_log_set_tag(logging, "TUT");
  3826. if ((model = both_ways_line_model_init(line_model_no,
  3827. noise_level,
  3828. echo_level_cpe1,
  3829. echo_level_co1,
  3830. line_model_no,
  3831. noise_level,
  3832. echo_level_cpe2,
  3833. echo_level_co2,
  3834. channel_codec,
  3835. rbs_pattern)) == NULL)
  3836. {
  3837. fprintf(stderr, " Failed to create line model\n");
  3838. exit(2);
  3839. }
  3840. result[TESTER][0] =
  3841. result[TUT][0] = '\0';
  3842. for (i = 0; i < 10000; i++)
  3843. {
  3844. for (j = 0; j < 2; j++)
  3845. {
  3846. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3847. push = 10;
  3848. if (samples < SAMPLES_PER_CHUNK)
  3849. {
  3850. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3851. samples = SAMPLES_PER_CHUNK;
  3852. }
  3853. }
  3854. if (log_audio)
  3855. {
  3856. for (j = 0; j < samples; j++)
  3857. {
  3858. out_amp[2*j + 0] = amp[0][j];
  3859. out_amp[2*j + 1] = amp[1][j];
  3860. }
  3861. outframes = sf_writef_short(outhandle, out_amp, samples);
  3862. if (outframes != samples)
  3863. {
  3864. fprintf(stderr, " Error writing audio file\n");
  3865. exit(2);
  3866. }
  3867. }
  3868. #if 1
  3869. both_ways_line_model(model,
  3870. model_amp[0],
  3871. amp[0],
  3872. model_amp[1],
  3873. amp[1],
  3874. samples);
  3875. #else
  3876. vec_copyi16(model_amp[0], amp[0], samples);
  3877. vec_copyi16(model_amp[1], amp[1], samples);
  3878. #endif
  3879. v18_rx(v18[TESTER], model_amp[1], samples);
  3880. v18_rx(v18[TUT], model_amp[0], samples);
  3881. }
  3882. v18_free(v18[TESTER]);
  3883. v18_free(v18[TUT]);
  3884. printf("Test not yet implemented\n");
  3885. return 1;
  3886. }
  3887. /*- End of function --------------------------------------------------------*/
  3888. static void ans_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3889. {
  3890. }
  3891. /*- End of function --------------------------------------------------------*/
  3892. static int test_ans_05(void)
  3893. {
  3894. logging_state_t *logging;
  3895. int16_t amp[2][SAMPLES_PER_CHUNK];
  3896. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3897. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3898. int outframes;
  3899. int samples;
  3900. int push;
  3901. int i;
  3902. int j;
  3903. /*
  3904. III.5.4.3.5 ANS tone followed by 980Hz
  3905. Purpose: To check correct detection of V.21 modem lower channel when preceded by answer
  3906. tone.
  3907. Preamble: N/A
  3908. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  3909. 980Hz and starts a 1s timer.
  3910. Pass criteria: TUT should respond with 1650Hz within 400+-100ms of start of 980Hz.
  3911. Comments: The TUT should indicate that V.21 mode has been selected.
  3912. */
  3913. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_05_put_text_msg, (void *) (intptr_t) 0);
  3914. logging = v18_get_logging_state(v18[TESTER]);
  3915. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3916. span_log_set_tag(logging, "Tester");
  3917. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_05_put_text_msg, (void *) (intptr_t) 1);
  3918. logging = v18_get_logging_state(v18[TUT]);
  3919. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  3920. span_log_set_tag(logging, "TUT");
  3921. if ((model = both_ways_line_model_init(line_model_no,
  3922. noise_level,
  3923. echo_level_cpe1,
  3924. echo_level_co1,
  3925. line_model_no,
  3926. noise_level,
  3927. echo_level_cpe2,
  3928. echo_level_co2,
  3929. channel_codec,
  3930. rbs_pattern)) == NULL)
  3931. {
  3932. fprintf(stderr, " Failed to create line model\n");
  3933. exit(2);
  3934. }
  3935. result[TESTER][0] =
  3936. result[TUT][0] = '\0';
  3937. for (i = 0; i < 10000; i++)
  3938. {
  3939. for (j = 0; j < 2; j++)
  3940. {
  3941. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  3942. push = 10;
  3943. if (samples < SAMPLES_PER_CHUNK)
  3944. {
  3945. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  3946. samples = SAMPLES_PER_CHUNK;
  3947. }
  3948. }
  3949. if (log_audio)
  3950. {
  3951. for (j = 0; j < samples; j++)
  3952. {
  3953. out_amp[2*j + 0] = amp[0][j];
  3954. out_amp[2*j + 1] = amp[1][j];
  3955. }
  3956. outframes = sf_writef_short(outhandle, out_amp, samples);
  3957. if (outframes != samples)
  3958. {
  3959. fprintf(stderr, " Error writing audio file\n");
  3960. exit(2);
  3961. }
  3962. }
  3963. #if 1
  3964. both_ways_line_model(model,
  3965. model_amp[0],
  3966. amp[0],
  3967. model_amp[1],
  3968. amp[1],
  3969. samples);
  3970. #else
  3971. vec_copyi16(model_amp[0], amp[0], samples);
  3972. vec_copyi16(model_amp[1], amp[1], samples);
  3973. #endif
  3974. v18_rx(v18[TESTER], model_amp[1], samples);
  3975. v18_rx(v18[TUT], model_amp[0], samples);
  3976. }
  3977. v18_free(v18[TESTER]);
  3978. v18_free(v18[TUT]);
  3979. printf("Test not yet implemented\n");
  3980. return 1;
  3981. }
  3982. /*- End of function --------------------------------------------------------*/
  3983. static void ans_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
  3984. {
  3985. }
  3986. /*- End of function --------------------------------------------------------*/
  3987. static int test_ans_06(void)
  3988. {
  3989. logging_state_t *logging;
  3990. int16_t amp[2][SAMPLES_PER_CHUNK];
  3991. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  3992. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  3993. int outframes;
  3994. int samples;
  3995. int push;
  3996. int i;
  3997. int j;
  3998. /*
  3999. III.5.4.3.6 ANS tone followed by 1300Hz
  4000. Purpose: To check correct detection of V.23 modem upper channel when preceded by answer
  4001. tone.
  4002. Preamble: N/A
  4003. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  4004. 1300Hz and starts a 2-s timer.
  4005. Pass criteria: TUT should respond with 390Hz after 1.7(+0.2-0.0)s of start of 1300Hz.
  4006. Comments: The TUT should indicate that V.23 mode has been selected.
  4007. */
  4008. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_06_put_text_msg, (void *) (intptr_t) 0);
  4009. logging = v18_get_logging_state(v18[TESTER]);
  4010. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4011. span_log_set_tag(logging, "Tester");
  4012. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_06_put_text_msg, (void *) (intptr_t) 1);
  4013. logging = v18_get_logging_state(v18[TUT]);
  4014. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4015. span_log_set_tag(logging, "TUT");
  4016. if ((model = both_ways_line_model_init(line_model_no,
  4017. noise_level,
  4018. echo_level_cpe1,
  4019. echo_level_co1,
  4020. line_model_no,
  4021. noise_level,
  4022. echo_level_cpe2,
  4023. echo_level_co2,
  4024. channel_codec,
  4025. rbs_pattern)) == NULL)
  4026. {
  4027. fprintf(stderr, " Failed to create line model\n");
  4028. exit(2);
  4029. }
  4030. result[TESTER][0] =
  4031. result[TUT][0] = '\0';
  4032. for (i = 0; i < 10000; i++)
  4033. {
  4034. for (j = 0; j < 2; j++)
  4035. {
  4036. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4037. push = 10;
  4038. if (samples < SAMPLES_PER_CHUNK)
  4039. {
  4040. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4041. samples = SAMPLES_PER_CHUNK;
  4042. }
  4043. }
  4044. if (log_audio)
  4045. {
  4046. for (j = 0; j < samples; j++)
  4047. {
  4048. out_amp[2*j + 0] = amp[0][j];
  4049. out_amp[2*j + 1] = amp[1][j];
  4050. }
  4051. outframes = sf_writef_short(outhandle, out_amp, samples);
  4052. if (outframes != samples)
  4053. {
  4054. fprintf(stderr, " Error writing audio file\n");
  4055. exit(2);
  4056. }
  4057. }
  4058. #if 1
  4059. both_ways_line_model(model,
  4060. model_amp[0],
  4061. amp[0],
  4062. model_amp[1],
  4063. amp[1],
  4064. samples);
  4065. #else
  4066. vec_copyi16(model_amp[0], amp[0], samples);
  4067. vec_copyi16(model_amp[1], amp[1], samples);
  4068. #endif
  4069. v18_rx(v18[TESTER], model_amp[1], samples);
  4070. v18_rx(v18[TUT], model_amp[0], samples);
  4071. }
  4072. v18_free(v18[TESTER]);
  4073. v18_free(v18[TUT]);
  4074. printf("Test not yet implemented\n");
  4075. return 1;
  4076. }
  4077. /*- End of function --------------------------------------------------------*/
  4078. static void ans_07_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4079. {
  4080. }
  4081. /*- End of function --------------------------------------------------------*/
  4082. static int test_ans_07(void)
  4083. {
  4084. logging_state_t *logging;
  4085. int16_t amp[2][SAMPLES_PER_CHUNK];
  4086. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4087. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4088. int outframes;
  4089. int samples;
  4090. int push;
  4091. int i;
  4092. int j;
  4093. /*
  4094. III.5.4.3.7 ANS tone followed by 1650Hz
  4095. Purpose: To check correct detection of V.21 modem upper channel when preceded by answer
  4096. tone and to confirm discrimination between V.21 and V.18 modes.
  4097. Preamble: N/A
  4098. Method: Tester transmits ANS for 2.5s followed by 75ms of no tone then transmits
  4099. 1650Hz and starts a 1-second timer.
  4100. Pass criteria: TUT should respond with 980Hz within 400+-100ms of start of 1650Hz.
  4101. Comments: The TUT should indicate that V.21 mode has been selected.
  4102. */
  4103. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_07_put_text_msg, (void *) (intptr_t) 0);
  4104. logging = v18_get_logging_state(v18[TESTER]);
  4105. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4106. span_log_set_tag(logging, "Tester");
  4107. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_07_put_text_msg, (void *) (intptr_t) 1);
  4108. logging = v18_get_logging_state(v18[TUT]);
  4109. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4110. span_log_set_tag(logging, "TUT");
  4111. if ((model = both_ways_line_model_init(line_model_no,
  4112. noise_level,
  4113. echo_level_cpe1,
  4114. echo_level_co1,
  4115. line_model_no,
  4116. noise_level,
  4117. echo_level_cpe2,
  4118. echo_level_co2,
  4119. channel_codec,
  4120. rbs_pattern)) == NULL)
  4121. {
  4122. fprintf(stderr, " Failed to create line model\n");
  4123. exit(2);
  4124. }
  4125. result[TESTER][0] =
  4126. result[TUT][0] = '\0';
  4127. for (i = 0; i < 10000; i++)
  4128. {
  4129. for (j = 0; j < 2; j++)
  4130. {
  4131. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4132. push = 10;
  4133. if (samples < SAMPLES_PER_CHUNK)
  4134. {
  4135. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4136. samples = SAMPLES_PER_CHUNK;
  4137. }
  4138. }
  4139. if (log_audio)
  4140. {
  4141. for (j = 0; j < samples; j++)
  4142. {
  4143. out_amp[2*j + 0] = amp[0][j];
  4144. out_amp[2*j + 1] = amp[1][j];
  4145. }
  4146. outframes = sf_writef_short(outhandle, out_amp, samples);
  4147. if (outframes != samples)
  4148. {
  4149. fprintf(stderr, " Error writing audio file\n");
  4150. exit(2);
  4151. }
  4152. }
  4153. #if 1
  4154. both_ways_line_model(model,
  4155. model_amp[0],
  4156. amp[0],
  4157. model_amp[1],
  4158. amp[1],
  4159. samples);
  4160. #else
  4161. vec_copyi16(model_amp[0], amp[0], samples);
  4162. vec_copyi16(model_amp[1], amp[1], samples);
  4163. #endif
  4164. v18_rx(v18[TESTER], model_amp[1], samples);
  4165. v18_rx(v18[TUT], model_amp[0], samples);
  4166. }
  4167. v18_free(v18[TESTER]);
  4168. v18_free(v18[TUT]);
  4169. printf("Test not yet implemented\n");
  4170. return 1;
  4171. }
  4172. /*- End of function --------------------------------------------------------*/
  4173. static void ans_08_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4174. {
  4175. }
  4176. /*- End of function --------------------------------------------------------*/
  4177. static int test_ans_08(void)
  4178. {
  4179. logging_state_t *logging;
  4180. int16_t amp[2][SAMPLES_PER_CHUNK];
  4181. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4182. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4183. int outframes;
  4184. int samples;
  4185. int push;
  4186. int i;
  4187. int j;
  4188. /*
  4189. III.5.4.3.8 980Hz followed by 1650Hz
  4190. Purpose: To ensure the correct selection of V.21 modem channel when certain types of
  4191. Swedish textphones are encountered.
  4192. Preamble: N/A
  4193. Method: The tester will simulate a call from a Diatext2 textphone that alternates between
  4194. 980Hz and 1650Hz until a connection is made.
  4195. Pass criteria: The TUT should respond with the appropriate carrier depending on when it
  4196. connects.
  4197. Comments: The TUT should indicate a V.21 connection. The time for which each frequency is
  4198. transmitted is random and varies between 0.64 and 2.56s.
  4199. */
  4200. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_08_put_text_msg, (void *) (intptr_t) 0);
  4201. logging = v18_get_logging_state(v18[TESTER]);
  4202. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4203. span_log_set_tag(logging, "Tester");
  4204. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_08_put_text_msg, (void *) (intptr_t) 1);
  4205. logging = v18_get_logging_state(v18[TUT]);
  4206. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4207. span_log_set_tag(logging, "TUT");
  4208. if ((model = both_ways_line_model_init(line_model_no,
  4209. noise_level,
  4210. echo_level_cpe1,
  4211. echo_level_co1,
  4212. line_model_no,
  4213. noise_level,
  4214. echo_level_cpe2,
  4215. echo_level_co2,
  4216. channel_codec,
  4217. rbs_pattern)) == NULL)
  4218. {
  4219. fprintf(stderr, " Failed to create line model\n");
  4220. exit(2);
  4221. }
  4222. result[TESTER][0] =
  4223. result[TUT][0] = '\0';
  4224. for (i = 0; i < 10000; i++)
  4225. {
  4226. for (j = 0; j < 2; j++)
  4227. {
  4228. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4229. push = 10;
  4230. if (samples < SAMPLES_PER_CHUNK)
  4231. {
  4232. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4233. samples = SAMPLES_PER_CHUNK;
  4234. }
  4235. }
  4236. if (log_audio)
  4237. {
  4238. for (j = 0; j < samples; j++)
  4239. {
  4240. out_amp[2*j + 0] = amp[0][j];
  4241. out_amp[2*j + 1] = amp[1][j];
  4242. }
  4243. outframes = sf_writef_short(outhandle, out_amp, samples);
  4244. if (outframes != samples)
  4245. {
  4246. fprintf(stderr, " Error writing audio file\n");
  4247. exit(2);
  4248. }
  4249. }
  4250. #if 1
  4251. both_ways_line_model(model,
  4252. model_amp[0],
  4253. amp[0],
  4254. model_amp[1],
  4255. amp[1],
  4256. samples);
  4257. #else
  4258. vec_copyi16(model_amp[0], amp[0], samples);
  4259. vec_copyi16(model_amp[1], amp[1], samples);
  4260. #endif
  4261. v18_rx(v18[TESTER], model_amp[1], samples);
  4262. v18_rx(v18[TUT], model_amp[0], samples);
  4263. }
  4264. v18_free(v18[TESTER]);
  4265. v18_free(v18[TUT]);
  4266. printf("Test not yet implemented\n");
  4267. return 1;
  4268. }
  4269. /*- End of function --------------------------------------------------------*/
  4270. static void ans_09_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4271. {
  4272. }
  4273. /*- End of function --------------------------------------------------------*/
  4274. static int test_ans_09(void)
  4275. {
  4276. logging_state_t *logging;
  4277. int16_t amp[2][SAMPLES_PER_CHUNK];
  4278. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4279. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4280. int outframes;
  4281. int samples;
  4282. int push;
  4283. int i;
  4284. int j;
  4285. /*
  4286. III.5.4.3.9 980Hz calling tone detection
  4287. Purpose: To confirm correct detection of 980Hz calling tones as defined in V.25.
  4288. Preamble: N/A
  4289. Method: The tester will send bursts of 980Hz signals (a) 400ms, (b) 500ms, (c) 700ms and
  4290. (d) 800ms followed by 1s of silence.
  4291. Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms.
  4292. 2) The TUT should immediately begin probing after a burst of 980Hz for 500ms or
  4293. 700ms followed by 1s of silence.
  4294. Comments: The probe sent by the TUT will depend on the country setting.
  4295. */
  4296. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_09_put_text_msg, (void *) (intptr_t) 0);
  4297. logging = v18_get_logging_state(v18[TESTER]);
  4298. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4299. span_log_set_tag(logging, "Tester");
  4300. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_09_put_text_msg, (void *) (intptr_t) 1);
  4301. logging = v18_get_logging_state(v18[TUT]);
  4302. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4303. span_log_set_tag(logging, "TUT");
  4304. if ((model = both_ways_line_model_init(line_model_no,
  4305. noise_level,
  4306. echo_level_cpe1,
  4307. echo_level_co1,
  4308. line_model_no,
  4309. noise_level,
  4310. echo_level_cpe2,
  4311. echo_level_co2,
  4312. channel_codec,
  4313. rbs_pattern)) == NULL)
  4314. {
  4315. fprintf(stderr, " Failed to create line model\n");
  4316. exit(2);
  4317. }
  4318. result[TESTER][0] =
  4319. result[TUT][0] = '\0';
  4320. for (i = 0; i < 10000; i++)
  4321. {
  4322. for (j = 0; j < 2; j++)
  4323. {
  4324. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4325. push = 10;
  4326. if (samples < SAMPLES_PER_CHUNK)
  4327. {
  4328. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4329. samples = SAMPLES_PER_CHUNK;
  4330. }
  4331. }
  4332. if (log_audio)
  4333. {
  4334. for (j = 0; j < samples; j++)
  4335. {
  4336. out_amp[2*j + 0] = amp[0][j];
  4337. out_amp[2*j + 1] = amp[1][j];
  4338. }
  4339. outframes = sf_writef_short(outhandle, out_amp, samples);
  4340. if (outframes != samples)
  4341. {
  4342. fprintf(stderr, " Error writing audio file\n");
  4343. exit(2);
  4344. }
  4345. }
  4346. #if 1
  4347. both_ways_line_model(model,
  4348. model_amp[0],
  4349. amp[0],
  4350. model_amp[1],
  4351. amp[1],
  4352. samples);
  4353. #else
  4354. vec_copyi16(model_amp[0], amp[0], samples);
  4355. vec_copyi16(model_amp[1], amp[1], samples);
  4356. #endif
  4357. v18_rx(v18[TESTER], model_amp[1], samples);
  4358. v18_rx(v18[TUT], model_amp[0], samples);
  4359. }
  4360. v18_free(v18[TESTER]);
  4361. v18_free(v18[TUT]);
  4362. printf("Test not yet implemented\n");
  4363. return 1;
  4364. }
  4365. /*- End of function --------------------------------------------------------*/
  4366. static void ans_10_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4367. {
  4368. }
  4369. /*- End of function --------------------------------------------------------*/
  4370. static int test_ans_10(void)
  4371. {
  4372. logging_state_t *logging;
  4373. int16_t amp[2][SAMPLES_PER_CHUNK];
  4374. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4375. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4376. int outframes;
  4377. int samples;
  4378. int push;
  4379. int i;
  4380. int j;
  4381. /*
  4382. III.5.4.3.10 V.21 detection by timer
  4383. Purpose: To confirm correct selection of V.21 calling modem when the received signal is not
  4384. modulated, i.e. there is no 1180Hz.
  4385. Preamble: N/A
  4386. Method: The tester sends 980Hz to TUT for 2s.
  4387. Pass criteria: The TUT should respond with a 1650Hz tone in 1.5+-0.1s.
  4388. Comments: The TUT should indicate that V.21 mode has been selected.
  4389. */
  4390. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_10_put_text_msg, (void *) (intptr_t) 0);
  4391. logging = v18_get_logging_state(v18[TESTER]);
  4392. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4393. span_log_set_tag(logging, "Tester");
  4394. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_10_put_text_msg, (void *) (intptr_t) 1);
  4395. logging = v18_get_logging_state(v18[TUT]);
  4396. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4397. span_log_set_tag(logging, "TUT");
  4398. if ((model = both_ways_line_model_init(line_model_no,
  4399. noise_level,
  4400. echo_level_cpe1,
  4401. echo_level_co1,
  4402. line_model_no,
  4403. noise_level,
  4404. echo_level_cpe2,
  4405. echo_level_co2,
  4406. channel_codec,
  4407. rbs_pattern)) == NULL)
  4408. {
  4409. fprintf(stderr, " Failed to create line model\n");
  4410. exit(2);
  4411. }
  4412. result[TESTER][0] =
  4413. result[TUT][0] = '\0';
  4414. for (i = 0; i < 10000; i++)
  4415. {
  4416. for (j = 0; j < 2; j++)
  4417. {
  4418. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4419. push = 10;
  4420. if (samples < SAMPLES_PER_CHUNK)
  4421. {
  4422. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4423. samples = SAMPLES_PER_CHUNK;
  4424. }
  4425. }
  4426. if (log_audio)
  4427. {
  4428. for (j = 0; j < samples; j++)
  4429. {
  4430. out_amp[2*j + 0] = amp[0][j];
  4431. out_amp[2*j + 1] = amp[1][j];
  4432. }
  4433. outframes = sf_writef_short(outhandle, out_amp, samples);
  4434. if (outframes != samples)
  4435. {
  4436. fprintf(stderr, " Error writing audio file\n");
  4437. exit(2);
  4438. }
  4439. }
  4440. #if 1
  4441. both_ways_line_model(model,
  4442. model_amp[0],
  4443. amp[0],
  4444. model_amp[1],
  4445. amp[1],
  4446. samples);
  4447. #else
  4448. vec_copyi16(model_amp[0], amp[0], samples);
  4449. vec_copyi16(model_amp[1], amp[1], samples);
  4450. #endif
  4451. v18_rx(v18[TESTER], model_amp[1], samples);
  4452. v18_rx(v18[TUT], model_amp[0], samples);
  4453. }
  4454. v18_free(v18[TESTER]);
  4455. v18_free(v18[TUT]);
  4456. printf("Test not yet implemented\n");
  4457. return 1;
  4458. }
  4459. /*- End of function --------------------------------------------------------*/
  4460. static void ans_11_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4461. {
  4462. }
  4463. /*- End of function --------------------------------------------------------*/
  4464. static int test_ans_11(void)
  4465. {
  4466. logging_state_t *logging;
  4467. int16_t amp[2][SAMPLES_PER_CHUNK];
  4468. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4469. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4470. int outframes;
  4471. int samples;
  4472. int push;
  4473. int i;
  4474. int j;
  4475. /*
  4476. III.5.4.3.11 EDT detection by rate
  4477. Purpose: To confirm detection of EDT modems by detecting the transmission rate of received
  4478. characters.
  4479. Preamble: N/A
  4480. Method: The tester transmits EDT characters "abcdef" to TUT at 110 bit/s. When TUT
  4481. indicates that the connection is established, type characters "abcdef<CR>" back to
  4482. the tester. The same characters will then be transmitted back to the TUT.
  4483. Pass criteria: Ensure correct reception of characters by tester and TUT.
  4484. Comments: The TUT should indicate that EDT mode has been selected. Some characters may
  4485. be lost during the detection process. However, the number lost should be minimal.
  4486. The data bits and parity are specified in Annex C.
  4487. */
  4488. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_11_put_text_msg, (void *) (intptr_t) 0);
  4489. logging = v18_get_logging_state(v18[TESTER]);
  4490. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4491. span_log_set_tag(logging, "Tester");
  4492. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_11_put_text_msg, (void *) (intptr_t) 1);
  4493. logging = v18_get_logging_state(v18[TUT]);
  4494. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4495. span_log_set_tag(logging, "TUT");
  4496. if ((model = both_ways_line_model_init(line_model_no,
  4497. noise_level,
  4498. echo_level_cpe1,
  4499. echo_level_co1,
  4500. line_model_no,
  4501. noise_level,
  4502. echo_level_cpe2,
  4503. echo_level_co2,
  4504. channel_codec,
  4505. rbs_pattern)) == NULL)
  4506. {
  4507. fprintf(stderr, " Failed to create line model\n");
  4508. exit(2);
  4509. }
  4510. result[TESTER][0] =
  4511. result[TUT][0] = '\0';
  4512. for (i = 0; i < 10000; i++)
  4513. {
  4514. for (j = 0; j < 2; j++)
  4515. {
  4516. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4517. push = 10;
  4518. if (samples < SAMPLES_PER_CHUNK)
  4519. {
  4520. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4521. samples = SAMPLES_PER_CHUNK;
  4522. }
  4523. }
  4524. if (log_audio)
  4525. {
  4526. for (j = 0; j < samples; j++)
  4527. {
  4528. out_amp[2*j + 0] = amp[0][j];
  4529. out_amp[2*j + 1] = amp[1][j];
  4530. }
  4531. outframes = sf_writef_short(outhandle, out_amp, samples);
  4532. if (outframes != samples)
  4533. {
  4534. fprintf(stderr, " Error writing audio file\n");
  4535. exit(2);
  4536. }
  4537. }
  4538. #if 1
  4539. both_ways_line_model(model,
  4540. model_amp[0],
  4541. amp[0],
  4542. model_amp[1],
  4543. amp[1],
  4544. samples);
  4545. #else
  4546. vec_copyi16(model_amp[0], amp[0], samples);
  4547. vec_copyi16(model_amp[1], amp[1], samples);
  4548. #endif
  4549. v18_rx(v18[TESTER], model_amp[1], samples);
  4550. v18_rx(v18[TUT], model_amp[0], samples);
  4551. }
  4552. v18_free(v18[TESTER]);
  4553. v18_free(v18[TUT]);
  4554. printf("Test not yet implemented\n");
  4555. return 1;
  4556. }
  4557. /*- End of function --------------------------------------------------------*/
  4558. static void ans_12_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4559. {
  4560. }
  4561. /*- End of function --------------------------------------------------------*/
  4562. static int test_ans_12(void)
  4563. {
  4564. logging_state_t *logging;
  4565. int16_t amp[2][SAMPLES_PER_CHUNK];
  4566. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4567. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4568. int outframes;
  4569. int samples;
  4570. int push;
  4571. int i;
  4572. int j;
  4573. /*
  4574. III.5.4.3.12 V.21 Detection by rate
  4575. Purpose: To confirm detection of V.21 modem low channel by detecting the transmission rate
  4576. of received characters and to ensure correct discrimination between V.18 and V.21
  4577. modes.
  4578. Preamble: N/A
  4579. Method: The tester transmits characters "abcdef" to TUT using V.21 (1) at 300 bit/s. When
  4580. TUT indicates that the connection is established, type characters "abcdef<CR>"
  4581. back to the tester. The same characters will then be transmitted back to the TUT.
  4582. Pass criteria: Ensure correct reception of characters by tester and TUT.
  4583. Comments: This situation is unlikely to occur in practice unless the DCE is sending a V.21
  4584. (1650Hz) probe. However, it is catered for in V.18. It is more likely that this is
  4585. where CI or TXP characters would be detected (see test ANS-02).
  4586. */
  4587. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_12_put_text_msg, (void *) (intptr_t) 0);
  4588. logging = v18_get_logging_state(v18[TESTER]);
  4589. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4590. span_log_set_tag(logging, "Tester");
  4591. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_12_put_text_msg, (void *) (intptr_t) 1);
  4592. logging = v18_get_logging_state(v18[TUT]);
  4593. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4594. span_log_set_tag(logging, "TUT");
  4595. if ((model = both_ways_line_model_init(line_model_no,
  4596. noise_level,
  4597. echo_level_cpe1,
  4598. echo_level_co1,
  4599. line_model_no,
  4600. noise_level,
  4601. echo_level_cpe2,
  4602. echo_level_co2,
  4603. channel_codec,
  4604. rbs_pattern)) == NULL)
  4605. {
  4606. fprintf(stderr, " Failed to create line model\n");
  4607. exit(2);
  4608. }
  4609. result[TESTER][0] =
  4610. result[TUT][0] = '\0';
  4611. for (i = 0; i < 10000; i++)
  4612. {
  4613. for (j = 0; j < 2; j++)
  4614. {
  4615. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4616. push = 10;
  4617. if (samples < SAMPLES_PER_CHUNK)
  4618. {
  4619. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4620. samples = SAMPLES_PER_CHUNK;
  4621. }
  4622. }
  4623. if (log_audio)
  4624. {
  4625. for (j = 0; j < samples; j++)
  4626. {
  4627. out_amp[2*j + 0] = amp[0][j];
  4628. out_amp[2*j + 1] = amp[1][j];
  4629. }
  4630. outframes = sf_writef_short(outhandle, out_amp, samples);
  4631. if (outframes != samples)
  4632. {
  4633. fprintf(stderr, " Error writing audio file\n");
  4634. exit(2);
  4635. }
  4636. }
  4637. #if 1
  4638. both_ways_line_model(model,
  4639. model_amp[0],
  4640. amp[0],
  4641. model_amp[1],
  4642. amp[1],
  4643. samples);
  4644. #else
  4645. vec_copyi16(model_amp[0], amp[0], samples);
  4646. vec_copyi16(model_amp[1], amp[1], samples);
  4647. #endif
  4648. v18_rx(v18[TESTER], model_amp[1], samples);
  4649. v18_rx(v18[TUT], model_amp[0], samples);
  4650. }
  4651. v18_free(v18[TESTER]);
  4652. v18_free(v18[TUT]);
  4653. printf("Test not yet implemented\n");
  4654. return 1;
  4655. }
  4656. /*- End of function --------------------------------------------------------*/
  4657. static void ans_13_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4658. {
  4659. }
  4660. /*- End of function --------------------------------------------------------*/
  4661. static int test_ans_13(void)
  4662. {
  4663. logging_state_t *logging;
  4664. int16_t amp[2][SAMPLES_PER_CHUNK];
  4665. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4666. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4667. int outframes;
  4668. int samples;
  4669. int push;
  4670. int i;
  4671. int j;
  4672. /*
  4673. III.5.4.3.13 Tr timer
  4674. Purpose: To ensure that the TUT returns to the Monitor A state on expiry of timer Tr
  4675. (2s). Timer Tr is started when a modulated V.21 (1) signal is detected.
  4676. Preamble: N/A
  4677. Method: The tester will transmit 980Hz for 200ms followed by alternating 980Hz/1180Hz
  4678. at 110 bit/s for 100ms followed by 980Hz for 1s.
  4679. Pass criteria: The TUT should begin probing 4+-0.5s after the 980Hz signal is removed.
  4680. Comments: It is not possible to be precise on timings for this test since the definition of a
  4681. "modulated signal" as in 5.2.4.4 is not specified. Therefore it is not known exactly
  4682. when timer Tr will start. It is assumed that timer Ta is restarted on re-entering the
  4683. Monitor A state.
  4684. */
  4685. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_13_put_text_msg, (void *) (intptr_t) 0);
  4686. logging = v18_get_logging_state(v18[TESTER]);
  4687. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4688. span_log_set_tag(logging, "Tester");
  4689. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_13_put_text_msg, (void *) (intptr_t) 1);
  4690. logging = v18_get_logging_state(v18[TUT]);
  4691. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4692. span_log_set_tag(logging, "TUT");
  4693. if ((model = both_ways_line_model_init(line_model_no,
  4694. noise_level,
  4695. echo_level_cpe1,
  4696. echo_level_co1,
  4697. line_model_no,
  4698. noise_level,
  4699. echo_level_cpe2,
  4700. echo_level_co2,
  4701. channel_codec,
  4702. rbs_pattern)) == NULL)
  4703. {
  4704. fprintf(stderr, " Failed to create line model\n");
  4705. exit(2);
  4706. }
  4707. result[TESTER][0] =
  4708. result[TUT][0] = '\0';
  4709. for (i = 0; i < 10000; i++)
  4710. {
  4711. for (j = 0; j < 2; j++)
  4712. {
  4713. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4714. push = 10;
  4715. if (samples < SAMPLES_PER_CHUNK)
  4716. {
  4717. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4718. samples = SAMPLES_PER_CHUNK;
  4719. }
  4720. }
  4721. if (log_audio)
  4722. {
  4723. for (j = 0; j < samples; j++)
  4724. {
  4725. out_amp[2*j + 0] = amp[0][j];
  4726. out_amp[2*j + 1] = amp[1][j];
  4727. }
  4728. outframes = sf_writef_short(outhandle, out_amp, samples);
  4729. if (outframes != samples)
  4730. {
  4731. fprintf(stderr, " Error writing audio file\n");
  4732. exit(2);
  4733. }
  4734. }
  4735. #if 1
  4736. both_ways_line_model(model,
  4737. model_amp[0],
  4738. amp[0],
  4739. model_amp[1],
  4740. amp[1],
  4741. samples);
  4742. #else
  4743. vec_copyi16(model_amp[0], amp[0], samples);
  4744. vec_copyi16(model_amp[1], amp[1], samples);
  4745. #endif
  4746. v18_rx(v18[TESTER], model_amp[1], samples);
  4747. v18_rx(v18[TUT], model_amp[0], samples);
  4748. }
  4749. v18_free(v18[TESTER]);
  4750. v18_free(v18[TUT]);
  4751. printf("Test not yet implemented\n");
  4752. return 1;
  4753. }
  4754. /*- End of function --------------------------------------------------------*/
  4755. static void ans_14_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4756. {
  4757. }
  4758. /*- End of function --------------------------------------------------------*/
  4759. static int test_ans_14(void)
  4760. {
  4761. logging_state_t *logging;
  4762. int16_t amp[2][SAMPLES_PER_CHUNK];
  4763. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4764. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4765. int outframes;
  4766. int samples;
  4767. int push;
  4768. int i;
  4769. int j;
  4770. /*
  4771. III.5.4.3.14 Te timer
  4772. Purpose: To ensure that the TUT returns to the Monitor A on expiry of timer Te
  4773. (2.7s). Timer Te is started when a 980Hz signal is detected.
  4774. Preamble: N/A
  4775. Method: The tester will transmit 980Hz for 200ms followed silence for 7 s.
  4776. Pass criteria: The TUT should begin probing 5.5+-0.5s after the 980Hz signal is removed.
  4777. Comments: It is assumed that timer Ta (3s) is restarted on re-entering the Monitor A
  4778. state.
  4779. */
  4780. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_14_put_text_msg, (void *) (intptr_t) 0);
  4781. logging = v18_get_logging_state(v18[TESTER]);
  4782. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4783. span_log_set_tag(logging, "Tester");
  4784. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_14_put_text_msg, (void *) (intptr_t) 1);
  4785. logging = v18_get_logging_state(v18[TUT]);
  4786. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4787. span_log_set_tag(logging, "TUT");
  4788. if ((model = both_ways_line_model_init(line_model_no,
  4789. noise_level,
  4790. echo_level_cpe1,
  4791. echo_level_co1,
  4792. line_model_no,
  4793. noise_level,
  4794. echo_level_cpe2,
  4795. echo_level_co2,
  4796. channel_codec,
  4797. rbs_pattern)) == NULL)
  4798. {
  4799. fprintf(stderr, " Failed to create line model\n");
  4800. exit(2);
  4801. }
  4802. result[TESTER][0] =
  4803. result[TUT][0] = '\0';
  4804. for (i = 0; i < 10000; i++)
  4805. {
  4806. for (j = 0; j < 2; j++)
  4807. {
  4808. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4809. push = 10;
  4810. if (samples < SAMPLES_PER_CHUNK)
  4811. {
  4812. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4813. samples = SAMPLES_PER_CHUNK;
  4814. }
  4815. }
  4816. if (log_audio)
  4817. {
  4818. for (j = 0; j < samples; j++)
  4819. {
  4820. out_amp[2*j + 0] = amp[0][j];
  4821. out_amp[2*j + 1] = amp[1][j];
  4822. }
  4823. outframes = sf_writef_short(outhandle, out_amp, samples);
  4824. if (outframes != samples)
  4825. {
  4826. fprintf(stderr, " Error writing audio file\n");
  4827. exit(2);
  4828. }
  4829. }
  4830. #if 1
  4831. both_ways_line_model(model,
  4832. model_amp[0],
  4833. amp[0],
  4834. model_amp[1],
  4835. amp[1],
  4836. samples);
  4837. #else
  4838. vec_copyi16(model_amp[0], amp[0], samples);
  4839. vec_copyi16(model_amp[1], amp[1], samples);
  4840. #endif
  4841. v18_rx(v18[TESTER], model_amp[1], samples);
  4842. v18_rx(v18[TUT], model_amp[0], samples);
  4843. }
  4844. v18_free(v18[TESTER]);
  4845. v18_free(v18[TUT]);
  4846. printf("Test not yet implemented\n");
  4847. return 1;
  4848. }
  4849. /*- End of function --------------------------------------------------------*/
  4850. static void ans_15_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4851. {
  4852. }
  4853. /*- End of function --------------------------------------------------------*/
  4854. static int test_ans_15(void)
  4855. {
  4856. logging_state_t *logging;
  4857. int16_t amp[2][SAMPLES_PER_CHUNK];
  4858. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4859. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4860. int outframes;
  4861. int samples;
  4862. int push;
  4863. int i;
  4864. int j;
  4865. /*
  4866. III.5.4.3.15 5 Bit mode (Baudot) detection tests
  4867. Purpose: To confirm detection of Baudot modulation at various bit rates that may be
  4868. encountered.
  4869. Preamble: N/A
  4870. Method: The tester transmits the 5-bit coded characters "0" to "9" followed by "abcdef" at
  4871. (a) 45.45, (b) 47.6, (c) 50 and (d) 100 bits per second. When TUT indicates a
  4872. connection, type at least 5 characters back to the tester so that correct selection of bit
  4873. rate can be confirmed.
  4874. Pass criteria: 1) The TUT should select Baudot mode and the appropriate bit rate.
  4875. 2) The tester will analyse the bit rate of received characters, which should be at an
  4876. appropriate rate, and confirm the carrier on/off times before and after the
  4877. characters.
  4878. Comments: 45.45 and 50 bit/s are the commonly used Baudot bit rates. However, some
  4879. textphones can transmit at higher rates, e.g. 100 bit/s. Responding at either 45.45 or
  4880. 50 bit/s is acceptable to these devices which then fall back to the selected rate.
  4881. A rate of 47.6 bit/s may be encountered from another V.18 textphone in the
  4882. automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
  4883. transmission.
  4884. */
  4885. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_15_put_text_msg, (void *) (intptr_t) 0);
  4886. logging = v18_get_logging_state(v18[TESTER]);
  4887. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4888. span_log_set_tag(logging, "Tester");
  4889. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_15_put_text_msg, (void *) (intptr_t) 1);
  4890. logging = v18_get_logging_state(v18[TUT]);
  4891. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4892. span_log_set_tag(logging, "TUT");
  4893. if ((model = both_ways_line_model_init(line_model_no,
  4894. noise_level,
  4895. echo_level_cpe1,
  4896. echo_level_co1,
  4897. line_model_no,
  4898. noise_level,
  4899. echo_level_cpe2,
  4900. echo_level_co2,
  4901. channel_codec,
  4902. rbs_pattern)) == NULL)
  4903. {
  4904. fprintf(stderr, " Failed to create line model\n");
  4905. exit(2);
  4906. }
  4907. result[TESTER][0] =
  4908. result[TUT][0] = '\0';
  4909. for (i = 0; i < 10000; i++)
  4910. {
  4911. for (j = 0; j < 2; j++)
  4912. {
  4913. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  4914. push = 10;
  4915. if (samples < SAMPLES_PER_CHUNK)
  4916. {
  4917. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  4918. samples = SAMPLES_PER_CHUNK;
  4919. }
  4920. }
  4921. if (log_audio)
  4922. {
  4923. for (j = 0; j < samples; j++)
  4924. {
  4925. out_amp[2*j + 0] = amp[0][j];
  4926. out_amp[2*j + 1] = amp[1][j];
  4927. }
  4928. outframes = sf_writef_short(outhandle, out_amp, samples);
  4929. if (outframes != samples)
  4930. {
  4931. fprintf(stderr, " Error writing audio file\n");
  4932. exit(2);
  4933. }
  4934. }
  4935. #if 1
  4936. both_ways_line_model(model,
  4937. model_amp[0],
  4938. amp[0],
  4939. model_amp[1],
  4940. amp[1],
  4941. samples);
  4942. #else
  4943. vec_copyi16(model_amp[0], amp[0], samples);
  4944. vec_copyi16(model_amp[1], amp[1], samples);
  4945. #endif
  4946. v18_rx(v18[TESTER], model_amp[1], samples);
  4947. v18_rx(v18[TUT], model_amp[0], samples);
  4948. }
  4949. v18_free(v18[TESTER]);
  4950. v18_free(v18[TUT]);
  4951. printf("Test not yet implemented\n");
  4952. return 1;
  4953. }
  4954. /*- End of function --------------------------------------------------------*/
  4955. static void ans_16_put_text_msg(void *user_data, const uint8_t *msg, int len)
  4956. {
  4957. }
  4958. /*- End of function --------------------------------------------------------*/
  4959. static int test_ans_16(void)
  4960. {
  4961. logging_state_t *logging;
  4962. int16_t amp[2][SAMPLES_PER_CHUNK];
  4963. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  4964. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  4965. int outframes;
  4966. int samples;
  4967. int push;
  4968. int i;
  4969. int j;
  4970. /*
  4971. III.5.4.3.16 DTMF signal detection
  4972. Purpose: To verify whether the TUT correctly recognizes DTMF signals.
  4973. Preamble: N/A
  4974. Method: The tester will send a single DTMF tone of 40ms duration to TUT. When TUT
  4975. indicates a connection, type at least 5 characters back to the tester so that correct
  4976. selection of mode can be confirmed.
  4977. Pass criteria: Tester will analyse the received characters to confirm DTMF mode selection.
  4978. Comments: The TUT should indicate that it has selected DTMF mode. The DTMF capabilities
  4979. of the TUT should comply with ITU-T Q.24 for the Danish Administration.
  4980. */
  4981. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_16_put_text_msg, (void *) (intptr_t) 0);
  4982. logging = v18_get_logging_state(v18[TESTER]);
  4983. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4984. span_log_set_tag(logging, "Tester");
  4985. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_16_put_text_msg, (void *) (intptr_t) 1);
  4986. logging = v18_get_logging_state(v18[TUT]);
  4987. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  4988. span_log_set_tag(logging, "TUT");
  4989. if ((model = both_ways_line_model_init(line_model_no,
  4990. noise_level,
  4991. echo_level_cpe1,
  4992. echo_level_co1,
  4993. line_model_no,
  4994. noise_level,
  4995. echo_level_cpe2,
  4996. echo_level_co2,
  4997. channel_codec,
  4998. rbs_pattern)) == NULL)
  4999. {
  5000. fprintf(stderr, " Failed to create line model\n");
  5001. exit(2);
  5002. }
  5003. result[TESTER][0] =
  5004. result[TUT][0] = '\0';
  5005. for (i = 0; i < 10000; i++)
  5006. {
  5007. for (j = 0; j < 2; j++)
  5008. {
  5009. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5010. push = 10;
  5011. if (samples < SAMPLES_PER_CHUNK)
  5012. {
  5013. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5014. samples = SAMPLES_PER_CHUNK;
  5015. }
  5016. }
  5017. if (log_audio)
  5018. {
  5019. for (j = 0; j < samples; j++)
  5020. {
  5021. out_amp[2*j + 0] = amp[0][j];
  5022. out_amp[2*j + 1] = amp[1][j];
  5023. }
  5024. outframes = sf_writef_short(outhandle, out_amp, samples);
  5025. if (outframes != samples)
  5026. {
  5027. fprintf(stderr, " Error writing audio file\n");
  5028. exit(2);
  5029. }
  5030. }
  5031. #if 1
  5032. both_ways_line_model(model,
  5033. model_amp[0],
  5034. amp[0],
  5035. model_amp[1],
  5036. amp[1],
  5037. samples);
  5038. #else
  5039. vec_copyi16(model_amp[0], amp[0], samples);
  5040. vec_copyi16(model_amp[1], amp[1], samples);
  5041. #endif
  5042. v18_rx(v18[TESTER], model_amp[1], samples);
  5043. v18_rx(v18[TUT], model_amp[0], samples);
  5044. }
  5045. v18_free(v18[TESTER]);
  5046. v18_free(v18[TUT]);
  5047. printf("Test not yet implemented\n");
  5048. return 1;
  5049. }
  5050. /*- End of function --------------------------------------------------------*/
  5051. static void ans_17_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5052. {
  5053. }
  5054. /*- End of function --------------------------------------------------------*/
  5055. static int test_ans_17(void)
  5056. {
  5057. logging_state_t *logging;
  5058. int16_t amp[2][SAMPLES_PER_CHUNK];
  5059. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5060. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5061. int outframes;
  5062. int samples;
  5063. int push;
  5064. int i;
  5065. int j;
  5066. /*
  5067. III.5.4.3.17 Bell 103 (1270Hz signal) detection
  5068. Purpose: To ensure correct detection and selection of Bell 103 modems.
  5069. Preamble: N/A
  5070. Method: The tester sends 1270Hz to TUT for 5s.
  5071. Pass criteria: TUT should respond with 2225Hz tone after 0.7+-0.1s.
  5072. Comments: The TUT should indicate that Bell 103 mode has been selected.
  5073. */
  5074. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_17_put_text_msg, (void *) (intptr_t) 0);
  5075. logging = v18_get_logging_state(v18[TESTER]);
  5076. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5077. span_log_set_tag(logging, "Tester");
  5078. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_17_put_text_msg, (void *) (intptr_t) 1);
  5079. logging = v18_get_logging_state(v18[TUT]);
  5080. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5081. span_log_set_tag(logging, "TUT");
  5082. if ((model = both_ways_line_model_init(line_model_no,
  5083. noise_level,
  5084. echo_level_cpe1,
  5085. echo_level_co1,
  5086. line_model_no,
  5087. noise_level,
  5088. echo_level_cpe2,
  5089. echo_level_co2,
  5090. channel_codec,
  5091. rbs_pattern)) == NULL)
  5092. {
  5093. fprintf(stderr, " Failed to create line model\n");
  5094. exit(2);
  5095. }
  5096. result[TESTER][0] =
  5097. result[TUT][0] = '\0';
  5098. for (i = 0; i < 10000; i++)
  5099. {
  5100. for (j = 0; j < 2; j++)
  5101. {
  5102. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5103. push = 10;
  5104. if (samples < SAMPLES_PER_CHUNK)
  5105. {
  5106. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5107. samples = SAMPLES_PER_CHUNK;
  5108. }
  5109. }
  5110. if (log_audio)
  5111. {
  5112. for (j = 0; j < samples; j++)
  5113. {
  5114. out_amp[2*j + 0] = amp[0][j];
  5115. out_amp[2*j + 1] = amp[1][j];
  5116. }
  5117. outframes = sf_writef_short(outhandle, out_amp, samples);
  5118. if (outframes != samples)
  5119. {
  5120. fprintf(stderr, " Error writing audio file\n");
  5121. exit(2);
  5122. }
  5123. }
  5124. #if 1
  5125. both_ways_line_model(model,
  5126. model_amp[0],
  5127. amp[0],
  5128. model_amp[1],
  5129. amp[1],
  5130. samples);
  5131. #else
  5132. vec_copyi16(model_amp[0], amp[0], samples);
  5133. vec_copyi16(model_amp[1], amp[1], samples);
  5134. #endif
  5135. v18_rx(v18[TESTER], model_amp[1], samples);
  5136. v18_rx(v18[TUT], model_amp[0], samples);
  5137. }
  5138. v18_free(v18[TESTER]);
  5139. v18_free(v18[TUT]);
  5140. printf("Test not yet implemented\n");
  5141. return 1;
  5142. }
  5143. /*- End of function --------------------------------------------------------*/
  5144. static void ans_18_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5145. {
  5146. }
  5147. /*- End of function --------------------------------------------------------*/
  5148. static int test_ans_18(void)
  5149. {
  5150. logging_state_t *logging;
  5151. int16_t amp[2][SAMPLES_PER_CHUNK];
  5152. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5153. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5154. int outframes;
  5155. int samples;
  5156. int push;
  5157. int i;
  5158. int j;
  5159. /*
  5160. III.5.4.3.18 Bell 103 (2225Hz signal) detection
  5161. Purpose: To ensure correct detection and selection of Bell 103 modems in reverse mode.
  5162. Preamble: N/A
  5163. Method: The tester sends 2225Hz to TUT for 5s.
  5164. Pass criteria: The TUT should respond with 1270Hz after 1+-0.2s.
  5165. Comments: The TUT should indicate that Bell 103 mode has been selected. Bell 103 modems
  5166. use 2225Hz as both answer tone and higher frequency of the upper channel.
  5167. */
  5168. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_18_put_text_msg, (void *) (intptr_t) 0);
  5169. logging = v18_get_logging_state(v18[TESTER]);
  5170. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5171. span_log_set_tag(logging, "Tester");
  5172. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_18_put_text_msg, (void *) (intptr_t) 1);
  5173. logging = v18_get_logging_state(v18[TUT]);
  5174. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5175. span_log_set_tag(logging, "TUT");
  5176. if ((model = both_ways_line_model_init(line_model_no,
  5177. noise_level,
  5178. echo_level_cpe1,
  5179. echo_level_co1,
  5180. line_model_no,
  5181. noise_level,
  5182. echo_level_cpe2,
  5183. echo_level_co2,
  5184. channel_codec,
  5185. rbs_pattern)) == NULL)
  5186. {
  5187. fprintf(stderr, " Failed to create line model\n");
  5188. exit(2);
  5189. }
  5190. result[TESTER][0] =
  5191. result[TUT][0] = '\0';
  5192. for (i = 0; i < 10000; i++)
  5193. {
  5194. for (j = 0; j < 2; j++)
  5195. {
  5196. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5197. push = 10;
  5198. if (samples < SAMPLES_PER_CHUNK)
  5199. {
  5200. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5201. samples = SAMPLES_PER_CHUNK;
  5202. }
  5203. }
  5204. if (log_audio)
  5205. {
  5206. for (j = 0; j < samples; j++)
  5207. {
  5208. out_amp[2*j + 0] = amp[0][j];
  5209. out_amp[2*j + 1] = amp[1][j];
  5210. }
  5211. outframes = sf_writef_short(outhandle, out_amp, samples);
  5212. if (outframes != samples)
  5213. {
  5214. fprintf(stderr, " Error writing audio file\n");
  5215. exit(2);
  5216. }
  5217. }
  5218. #if 1
  5219. both_ways_line_model(model,
  5220. model_amp[0],
  5221. amp[0],
  5222. model_amp[1],
  5223. amp[1],
  5224. samples);
  5225. #else
  5226. vec_copyi16(model_amp[0], amp[0], samples);
  5227. vec_copyi16(model_amp[1], amp[1], samples);
  5228. #endif
  5229. v18_rx(v18[TESTER], model_amp[1], samples);
  5230. v18_rx(v18[TUT], model_amp[0], samples);
  5231. }
  5232. v18_free(v18[TESTER]);
  5233. v18_free(v18[TUT]);
  5234. printf("Test not yet implemented\n");
  5235. return 1;
  5236. }
  5237. /*- End of function --------------------------------------------------------*/
  5238. static void ans_19_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5239. {
  5240. }
  5241. /*- End of function --------------------------------------------------------*/
  5242. static int test_ans_19(void)
  5243. {
  5244. logging_state_t *logging;
  5245. int16_t amp[2][SAMPLES_PER_CHUNK];
  5246. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5247. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5248. int outframes;
  5249. int samples;
  5250. int push;
  5251. int i;
  5252. int j;
  5253. /*
  5254. III.5.4.3.19 V.21 Reverse mode (1650Hz) detection
  5255. Purpose: To ensure correct detection and selection of V.21 reverse mode.
  5256. Preamble: N/A
  5257. Method: The tester sends 1650Hz to TUT for 5s.
  5258. Pass criteria: The TUT should respond with 980Hz after 0.4+-0.2s.
  5259. Comments: The TUT should indicate that V.21 mode has been selected.
  5260. */
  5261. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_19_put_text_msg, (void *) (intptr_t) 0);
  5262. logging = v18_get_logging_state(v18[TESTER]);
  5263. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5264. span_log_set_tag(logging, "Tester");
  5265. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_19_put_text_msg, (void *) (intptr_t) 1);
  5266. logging = v18_get_logging_state(v18[TUT]);
  5267. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5268. span_log_set_tag(logging, "TUT");
  5269. if ((model = both_ways_line_model_init(line_model_no,
  5270. noise_level,
  5271. echo_level_cpe1,
  5272. echo_level_co1,
  5273. line_model_no,
  5274. noise_level,
  5275. echo_level_cpe2,
  5276. echo_level_co2,
  5277. channel_codec,
  5278. rbs_pattern)) == NULL)
  5279. {
  5280. fprintf(stderr, " Failed to create line model\n");
  5281. exit(2);
  5282. }
  5283. result[TESTER][0] =
  5284. result[TUT][0] = '\0';
  5285. for (i = 0; i < 10000; i++)
  5286. {
  5287. for (j = 0; j < 2; j++)
  5288. {
  5289. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5290. push = 10;
  5291. if (samples < SAMPLES_PER_CHUNK)
  5292. {
  5293. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5294. samples = SAMPLES_PER_CHUNK;
  5295. }
  5296. }
  5297. if (log_audio)
  5298. {
  5299. for (j = 0; j < samples; j++)
  5300. {
  5301. out_amp[2*j + 0] = amp[0][j];
  5302. out_amp[2*j + 1] = amp[1][j];
  5303. }
  5304. outframes = sf_writef_short(outhandle, out_amp, samples);
  5305. if (outframes != samples)
  5306. {
  5307. fprintf(stderr, " Error writing audio file\n");
  5308. exit(2);
  5309. }
  5310. }
  5311. #if 1
  5312. both_ways_line_model(model,
  5313. model_amp[0],
  5314. amp[0],
  5315. model_amp[1],
  5316. amp[1],
  5317. samples);
  5318. #else
  5319. vec_copyi16(model_amp[0], amp[0], samples);
  5320. vec_copyi16(model_amp[1], amp[1], samples);
  5321. #endif
  5322. v18_rx(v18[TESTER], model_amp[1], samples);
  5323. v18_rx(v18[TUT], model_amp[0], samples);
  5324. }
  5325. v18_free(v18[TESTER]);
  5326. v18_free(v18[TUT]);
  5327. printf("Test not yet implemented\n");
  5328. return 1;
  5329. }
  5330. /*- End of function --------------------------------------------------------*/
  5331. static void ans_20_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5332. {
  5333. }
  5334. /*- End of function --------------------------------------------------------*/
  5335. static int test_ans_20(void)
  5336. {
  5337. logging_state_t *logging;
  5338. int16_t amp[2][SAMPLES_PER_CHUNK];
  5339. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5340. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5341. int outframes;
  5342. int samples;
  5343. int push;
  5344. int i;
  5345. int j;
  5346. /*
  5347. III.5.4.3.20 1300Hz calling tone discrimination
  5348. Purpose: To confirm correct detection of 1300Hz calling tones as defined in ITU-T V.25.
  5349. Preamble: N/A
  5350. Method: The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
  5351. (d) 800ms followed by 1s of silence.
  5352. Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms.
  5353. 2) The TUT should immediately begin probing after a burst of 1300Hz for 500ms or
  5354. 700ms followed by 1s of silence.
  5355. Comments: The probe sent by the TUT will depend on the country setting.
  5356. */
  5357. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_20_put_text_msg, (void *) (intptr_t) 0);
  5358. logging = v18_get_logging_state(v18[TESTER]);
  5359. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5360. span_log_set_tag(logging, "Tester");
  5361. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_20_put_text_msg, (void *) (intptr_t) 1);
  5362. logging = v18_get_logging_state(v18[TUT]);
  5363. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5364. span_log_set_tag(logging, "TUT");
  5365. if ((model = both_ways_line_model_init(line_model_no,
  5366. noise_level,
  5367. echo_level_cpe1,
  5368. echo_level_co1,
  5369. line_model_no,
  5370. noise_level,
  5371. echo_level_cpe2,
  5372. echo_level_co2,
  5373. channel_codec,
  5374. rbs_pattern)) == NULL)
  5375. {
  5376. fprintf(stderr, " Failed to create line model\n");
  5377. exit(2);
  5378. }
  5379. result[TESTER][0] =
  5380. result[TUT][0] = '\0';
  5381. for (i = 0; i < 10000; i++)
  5382. {
  5383. for (j = 0; j < 2; j++)
  5384. {
  5385. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5386. push = 10;
  5387. if (samples < SAMPLES_PER_CHUNK)
  5388. {
  5389. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5390. samples = SAMPLES_PER_CHUNK;
  5391. }
  5392. }
  5393. if (log_audio)
  5394. {
  5395. for (j = 0; j < samples; j++)
  5396. {
  5397. out_amp[2*j + 0] = amp[0][j];
  5398. out_amp[2*j + 1] = amp[1][j];
  5399. }
  5400. outframes = sf_writef_short(outhandle, out_amp, samples);
  5401. if (outframes != samples)
  5402. {
  5403. fprintf(stderr, " Error writing audio file\n");
  5404. exit(2);
  5405. }
  5406. }
  5407. #if 1
  5408. both_ways_line_model(model,
  5409. model_amp[0],
  5410. amp[0],
  5411. model_amp[1],
  5412. amp[1],
  5413. samples);
  5414. #else
  5415. vec_copyi16(model_amp[0], amp[0], samples);
  5416. vec_copyi16(model_amp[1], amp[1], samples);
  5417. #endif
  5418. v18_rx(v18[TESTER], model_amp[1], samples);
  5419. v18_rx(v18[TUT], model_amp[0], samples);
  5420. }
  5421. v18_free(v18[TESTER]);
  5422. v18_free(v18[TUT]);
  5423. printf("Test not yet implemented\n");
  5424. return 1;
  5425. }
  5426. /*- End of function --------------------------------------------------------*/
  5427. static void ans_21_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5428. {
  5429. }
  5430. /*- End of function --------------------------------------------------------*/
  5431. static int test_ans_21(void)
  5432. {
  5433. logging_state_t *logging;
  5434. int16_t amp[2][SAMPLES_PER_CHUNK];
  5435. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5436. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5437. int outframes;
  5438. int samples;
  5439. int push;
  5440. int i;
  5441. int j;
  5442. /*
  5443. III.5.4.3.21 V.23 Reverse mode (1300Hz) detection
  5444. Purpose: To ensure correct detection and selection of V.23 reverse mode.
  5445. Preamble: N/A
  5446. Method: The tester sends 1300Hz only, with no XCI signals, to TUT for 5s.
  5447. Pass criteria: The TUT should respond with 390Hz after 1.7+-0.1s.
  5448. Comments: The TUT should indicate that V.23 mode has been selected.
  5449. */
  5450. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_21_put_text_msg, (void *) (intptr_t) 0);
  5451. logging = v18_get_logging_state(v18[TESTER]);
  5452. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5453. span_log_set_tag(logging, "Tester");
  5454. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_21_put_text_msg, (void *) (intptr_t) 1);
  5455. logging = v18_get_logging_state(v18[TUT]);
  5456. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5457. span_log_set_tag(logging, "TUT");
  5458. if ((model = both_ways_line_model_init(line_model_no,
  5459. noise_level,
  5460. echo_level_cpe1,
  5461. echo_level_co1,
  5462. line_model_no,
  5463. noise_level,
  5464. echo_level_cpe2,
  5465. echo_level_co2,
  5466. channel_codec,
  5467. rbs_pattern)) == NULL)
  5468. {
  5469. fprintf(stderr, " Failed to create line model\n");
  5470. exit(2);
  5471. }
  5472. result[TESTER][0] =
  5473. result[TUT][0] = '\0';
  5474. for (i = 0; i < 10000; i++)
  5475. {
  5476. for (j = 0; j < 2; j++)
  5477. {
  5478. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5479. push = 10;
  5480. if (samples < SAMPLES_PER_CHUNK)
  5481. {
  5482. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5483. samples = SAMPLES_PER_CHUNK;
  5484. }
  5485. }
  5486. if (log_audio)
  5487. {
  5488. for (j = 0; j < samples; j++)
  5489. {
  5490. out_amp[2*j + 0] = amp[0][j];
  5491. out_amp[2*j + 1] = amp[1][j];
  5492. }
  5493. outframes = sf_writef_short(outhandle, out_amp, samples);
  5494. if (outframes != samples)
  5495. {
  5496. fprintf(stderr, " Error writing audio file\n");
  5497. exit(2);
  5498. }
  5499. }
  5500. #if 1
  5501. both_ways_line_model(model,
  5502. model_amp[0],
  5503. amp[0],
  5504. model_amp[1],
  5505. amp[1],
  5506. samples);
  5507. #else
  5508. vec_copyi16(model_amp[0], amp[0], samples);
  5509. vec_copyi16(model_amp[1], amp[1], samples);
  5510. #endif
  5511. v18_rx(v18[TESTER], model_amp[1], samples);
  5512. v18_rx(v18[TUT], model_amp[0], samples);
  5513. }
  5514. v18_free(v18[TESTER]);
  5515. v18_free(v18[TUT]);
  5516. printf("Test not yet implemented\n");
  5517. return 1;
  5518. }
  5519. /*- End of function --------------------------------------------------------*/
  5520. static void ans_22_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5521. {
  5522. }
  5523. /*- End of function --------------------------------------------------------*/
  5524. static int test_ans_22(void)
  5525. {
  5526. logging_state_t *logging;
  5527. int16_t amp[2][SAMPLES_PER_CHUNK];
  5528. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5529. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5530. int outframes;
  5531. int samples;
  5532. int push;
  5533. int i;
  5534. int j;
  5535. /*
  5536. III.5.4.3.22 1300Hz with XCI test
  5537. Purpose: To ensure correct detection of the XCI signal and selection of V.18 mode.
  5538. Preamble: N/A
  5539. Method: The tester sends XCI signal as defined in 3.11. On reception of ANS it will become
  5540. silent for 500ms then transmit the TXP signal in V.21 (1) mode.
  5541. Pass criteria: The TUT should respond with TXP using V.21 (2) and select V.18 mode.
  5542. */
  5543. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_22_put_text_msg, (void *) (intptr_t) 0);
  5544. logging = v18_get_logging_state(v18[TESTER]);
  5545. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5546. span_log_set_tag(logging, "Tester");
  5547. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_22_put_text_msg, (void *) (intptr_t) 1);
  5548. logging = v18_get_logging_state(v18[TUT]);
  5549. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5550. span_log_set_tag(logging, "TUT");
  5551. if ((model = both_ways_line_model_init(line_model_no,
  5552. noise_level,
  5553. echo_level_cpe1,
  5554. echo_level_co1,
  5555. line_model_no,
  5556. noise_level,
  5557. echo_level_cpe2,
  5558. echo_level_co2,
  5559. channel_codec,
  5560. rbs_pattern)) == NULL)
  5561. {
  5562. fprintf(stderr, " Failed to create line model\n");
  5563. exit(2);
  5564. }
  5565. result[TESTER][0] =
  5566. result[TUT][0] = '\0';
  5567. for (i = 0; i < 10000; i++)
  5568. {
  5569. for (j = 0; j < 2; j++)
  5570. {
  5571. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5572. push = 10;
  5573. if (samples < SAMPLES_PER_CHUNK)
  5574. {
  5575. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5576. samples = SAMPLES_PER_CHUNK;
  5577. }
  5578. }
  5579. if (log_audio)
  5580. {
  5581. for (j = 0; j < samples; j++)
  5582. {
  5583. out_amp[2*j + 0] = amp[0][j];
  5584. out_amp[2*j + 1] = amp[1][j];
  5585. }
  5586. outframes = sf_writef_short(outhandle, out_amp, samples);
  5587. if (outframes != samples)
  5588. {
  5589. fprintf(stderr, " Error writing audio file\n");
  5590. exit(2);
  5591. }
  5592. }
  5593. #if 1
  5594. both_ways_line_model(model,
  5595. model_amp[0],
  5596. amp[0],
  5597. model_amp[1],
  5598. amp[1],
  5599. samples);
  5600. #else
  5601. vec_copyi16(model_amp[0], amp[0], samples);
  5602. vec_copyi16(model_amp[1], amp[1], samples);
  5603. #endif
  5604. v18_rx(v18[TESTER], model_amp[1], samples);
  5605. v18_rx(v18[TUT], model_amp[0], samples);
  5606. }
  5607. v18_free(v18[TESTER]);
  5608. v18_free(v18[TUT]);
  5609. printf("Test not yet implemented\n");
  5610. return 1;
  5611. }
  5612. /*- End of function --------------------------------------------------------*/
  5613. static void ans_23_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5614. {
  5615. }
  5616. /*- End of function --------------------------------------------------------*/
  5617. static int test_ans_23(void)
  5618. {
  5619. logging_state_t *logging;
  5620. int16_t amp[2][SAMPLES_PER_CHUNK];
  5621. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5622. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5623. int outframes;
  5624. int samples;
  5625. int push;
  5626. int i;
  5627. int j;
  5628. /*
  5629. III.5.4.3.23 Stimulate mode country settings
  5630. Purpose: To ensure that the TUT steps through the probes in the specified order for the
  5631. country selected.
  5632. Preamble: The TUT should be configured for each of the possible probe orders specified in
  5633. Appendix I in turn.
  5634. Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent
  5635. by the TUT.
  5636. Pass criteria: The TUT should use the orders described in Appendix I.
  5637. Comments: The order of the probes is not mandatory.
  5638. */
  5639. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_23_put_text_msg, (void *) (intptr_t) 0);
  5640. logging = v18_get_logging_state(v18[TESTER]);
  5641. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5642. span_log_set_tag(logging, "Tester");
  5643. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_23_put_text_msg, (void *) (intptr_t) 1);
  5644. logging = v18_get_logging_state(v18[TUT]);
  5645. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5646. span_log_set_tag(logging, "TUT");
  5647. if ((model = both_ways_line_model_init(line_model_no,
  5648. noise_level,
  5649. echo_level_cpe1,
  5650. echo_level_co1,
  5651. line_model_no,
  5652. noise_level,
  5653. echo_level_cpe2,
  5654. echo_level_co2,
  5655. channel_codec,
  5656. rbs_pattern)) == NULL)
  5657. {
  5658. fprintf(stderr, " Failed to create line model\n");
  5659. exit(2);
  5660. }
  5661. result[TESTER][0] =
  5662. result[TUT][0] = '\0';
  5663. for (i = 0; i < 10000; i++)
  5664. {
  5665. for (j = 0; j < 2; j++)
  5666. {
  5667. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5668. push = 10;
  5669. if (samples < SAMPLES_PER_CHUNK)
  5670. {
  5671. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5672. samples = SAMPLES_PER_CHUNK;
  5673. }
  5674. }
  5675. if (log_audio)
  5676. {
  5677. for (j = 0; j < samples; j++)
  5678. {
  5679. out_amp[2*j + 0] = amp[0][j];
  5680. out_amp[2*j + 1] = amp[1][j];
  5681. }
  5682. outframes = sf_writef_short(outhandle, out_amp, samples);
  5683. if (outframes != samples)
  5684. {
  5685. fprintf(stderr, " Error writing audio file\n");
  5686. exit(2);
  5687. }
  5688. }
  5689. #if 1
  5690. both_ways_line_model(model,
  5691. model_amp[0],
  5692. amp[0],
  5693. model_amp[1],
  5694. amp[1],
  5695. samples);
  5696. #else
  5697. vec_copyi16(model_amp[0], amp[0], samples);
  5698. vec_copyi16(model_amp[1], amp[1], samples);
  5699. #endif
  5700. v18_rx(v18[TESTER], model_amp[1], samples);
  5701. v18_rx(v18[TUT], model_amp[0], samples);
  5702. }
  5703. v18_free(v18[TESTER]);
  5704. v18_free(v18[TUT]);
  5705. printf("Test not yet implemented\n");
  5706. return 1;
  5707. }
  5708. /*- End of function --------------------------------------------------------*/
  5709. static void ans_24_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5710. {
  5711. }
  5712. /*- End of function --------------------------------------------------------*/
  5713. static int test_ans_24(void)
  5714. {
  5715. logging_state_t *logging;
  5716. int16_t amp[2][SAMPLES_PER_CHUNK];
  5717. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5718. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5719. int outframes;
  5720. int samples;
  5721. int push;
  5722. int i;
  5723. int j;
  5724. /*
  5725. III.5.4.3.24 Stimulate carrierless mode probe message
  5726. Purpose: To ensure that the TUT sends the correct probe message for each of the carrierless
  5727. modes.
  5728. Preamble: N/A
  5729. Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent
  5730. by the TUT.
  5731. Pass criteria: The TUT should send the user defined probe message for Annexes A, B, and C
  5732. modes followed by a pause of Tm (default 3)s.
  5733. Comments: The carrierless modes are those described in Annexes A, B and C.
  5734. */
  5735. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_24_put_text_msg, (void *) (intptr_t) 0);
  5736. logging = v18_get_logging_state(v18[TESTER]);
  5737. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5738. span_log_set_tag(logging, "Tester");
  5739. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_24_put_text_msg, (void *) (intptr_t) 1);
  5740. logging = v18_get_logging_state(v18[TUT]);
  5741. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5742. span_log_set_tag(logging, "TUT");
  5743. if ((model = both_ways_line_model_init(line_model_no,
  5744. noise_level,
  5745. echo_level_cpe1,
  5746. echo_level_co1,
  5747. line_model_no,
  5748. noise_level,
  5749. echo_level_cpe2,
  5750. echo_level_co2,
  5751. channel_codec,
  5752. rbs_pattern)) == NULL)
  5753. {
  5754. fprintf(stderr, " Failed to create line model\n");
  5755. exit(2);
  5756. }
  5757. result[TESTER][0] =
  5758. result[TUT][0] = '\0';
  5759. for (i = 0; i < 10000; i++)
  5760. {
  5761. for (j = 0; j < 2; j++)
  5762. {
  5763. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5764. push = 10;
  5765. if (samples < SAMPLES_PER_CHUNK)
  5766. {
  5767. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5768. samples = SAMPLES_PER_CHUNK;
  5769. }
  5770. }
  5771. if (log_audio)
  5772. {
  5773. for (j = 0; j < samples; j++)
  5774. {
  5775. out_amp[2*j + 0] = amp[0][j];
  5776. out_amp[2*j + 1] = amp[1][j];
  5777. }
  5778. outframes = sf_writef_short(outhandle, out_amp, samples);
  5779. if (outframes != samples)
  5780. {
  5781. fprintf(stderr, " Error writing audio file\n");
  5782. exit(2);
  5783. }
  5784. }
  5785. #if 1
  5786. both_ways_line_model(model,
  5787. model_amp[0],
  5788. amp[0],
  5789. model_amp[1],
  5790. amp[1],
  5791. samples);
  5792. #else
  5793. vec_copyi16(model_amp[0], amp[0], samples);
  5794. vec_copyi16(model_amp[1], amp[1], samples);
  5795. #endif
  5796. v18_rx(v18[TESTER], model_amp[1], samples);
  5797. v18_rx(v18[TUT], model_amp[0], samples);
  5798. }
  5799. v18_free(v18[TESTER]);
  5800. v18_free(v18[TUT]);
  5801. printf("Test not yet implemented\n");
  5802. return 1;
  5803. }
  5804. /*- End of function --------------------------------------------------------*/
  5805. static void ans_25_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5806. {
  5807. }
  5808. /*- End of function --------------------------------------------------------*/
  5809. static int test_ans_25(void)
  5810. {
  5811. logging_state_t *logging;
  5812. int16_t amp[2][SAMPLES_PER_CHUNK];
  5813. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5814. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5815. int outframes;
  5816. int samples;
  5817. int push;
  5818. int i;
  5819. int j;
  5820. /*
  5821. III.5.4.3.25 Interrupted carrierless mode probe
  5822. Purpose: To ensure that the TUT continues probing from the point of interruption a maximum
  5823. of 20s after a failed connect attempt.
  5824. Preamble: The TUT should be configured for the UK country setting.
  5825. Method: The tester will call the TUT, wait for Ta to expire and then during the pause after
  5826. the first Baudot probe it will send a 200ms burst of 1270Hz followed by silence
  5827. for 30s.
  5828. Pass criteria: The TUT should transmit silence on detecting the 1270Hz tone and then continue
  5829. probing starting with the V.23 probe 20s after the end of the 1270Hz signal.
  5830. */
  5831. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_25_put_text_msg, (void *) (intptr_t) 0);
  5832. logging = v18_get_logging_state(v18[TESTER]);
  5833. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5834. span_log_set_tag(logging, "Tester");
  5835. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_25_put_text_msg, (void *) (intptr_t) 1);
  5836. logging = v18_get_logging_state(v18[TUT]);
  5837. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5838. span_log_set_tag(logging, "TUT");
  5839. if ((model = both_ways_line_model_init(line_model_no,
  5840. noise_level,
  5841. echo_level_cpe1,
  5842. echo_level_co1,
  5843. line_model_no,
  5844. noise_level,
  5845. echo_level_cpe2,
  5846. echo_level_co2,
  5847. channel_codec,
  5848. rbs_pattern)) == NULL)
  5849. {
  5850. fprintf(stderr, " Failed to create line model\n");
  5851. exit(2);
  5852. }
  5853. result[TESTER][0] =
  5854. result[TUT][0] = '\0';
  5855. for (i = 0; i < 10000; i++)
  5856. {
  5857. for (j = 0; j < 2; j++)
  5858. {
  5859. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5860. push = 10;
  5861. if (samples < SAMPLES_PER_CHUNK)
  5862. {
  5863. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5864. samples = SAMPLES_PER_CHUNK;
  5865. }
  5866. }
  5867. if (log_audio)
  5868. {
  5869. for (j = 0; j < samples; j++)
  5870. {
  5871. out_amp[2*j + 0] = amp[0][j];
  5872. out_amp[2*j + 1] = amp[1][j];
  5873. }
  5874. outframes = sf_writef_short(outhandle, out_amp, samples);
  5875. if (outframes != samples)
  5876. {
  5877. fprintf(stderr, " Error writing audio file\n");
  5878. exit(2);
  5879. }
  5880. }
  5881. #if 1
  5882. both_ways_line_model(model,
  5883. model_amp[0],
  5884. amp[0],
  5885. model_amp[1],
  5886. amp[1],
  5887. samples);
  5888. #else
  5889. vec_copyi16(model_amp[0], amp[0], samples);
  5890. vec_copyi16(model_amp[1], amp[1], samples);
  5891. #endif
  5892. v18_rx(v18[TESTER], model_amp[1], samples);
  5893. v18_rx(v18[TUT], model_amp[0], samples);
  5894. }
  5895. v18_free(v18[TESTER]);
  5896. v18_free(v18[TUT]);
  5897. printf("Test not yet implemented\n");
  5898. return 1;
  5899. }
  5900. /*- End of function --------------------------------------------------------*/
  5901. static void ans_26_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5902. {
  5903. }
  5904. /*- End of function --------------------------------------------------------*/
  5905. static int test_ans_26(void)
  5906. {
  5907. logging_state_t *logging;
  5908. int16_t amp[2][SAMPLES_PER_CHUNK];
  5909. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  5910. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  5911. int outframes;
  5912. int samples;
  5913. int push;
  5914. int i;
  5915. int j;
  5916. /*
  5917. III.5.4.3.26 Stimulate carrier mode probe time
  5918. Purpose: To ensure that the TUT sends each carrier mode for time Tc (default 6s)
  5919. preceded by the correct answer tone.
  5920. Preamble: None.
  5921. Method: The tester will call the TUT, wait for Ta to expire and then monitor the probes sent
  5922. by the TUT.
  5923. Pass criteria: The TUT should send the ANS tone (2100Hz) for 1s followed by silence for
  5924. 75+-5ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc.
  5925. Comments: The carrier modes are those described in Annexes D, E, and F.
  5926. */
  5927. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_26_put_text_msg, (void *) (intptr_t) 0);
  5928. logging = v18_get_logging_state(v18[TESTER]);
  5929. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5930. span_log_set_tag(logging, "Tester");
  5931. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_26_put_text_msg, (void *) (intptr_t) 1);
  5932. logging = v18_get_logging_state(v18[TUT]);
  5933. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  5934. span_log_set_tag(logging, "TUT");
  5935. if ((model = both_ways_line_model_init(line_model_no,
  5936. noise_level,
  5937. echo_level_cpe1,
  5938. echo_level_co1,
  5939. line_model_no,
  5940. noise_level,
  5941. echo_level_cpe2,
  5942. echo_level_co2,
  5943. channel_codec,
  5944. rbs_pattern)) == NULL)
  5945. {
  5946. fprintf(stderr, " Failed to create line model\n");
  5947. exit(2);
  5948. }
  5949. result[TESTER][0] =
  5950. result[TUT][0] = '\0';
  5951. for (i = 0; i < 10000; i++)
  5952. {
  5953. for (j = 0; j < 2; j++)
  5954. {
  5955. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  5956. push = 10;
  5957. if (samples < SAMPLES_PER_CHUNK)
  5958. {
  5959. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  5960. samples = SAMPLES_PER_CHUNK;
  5961. }
  5962. }
  5963. if (log_audio)
  5964. {
  5965. for (j = 0; j < samples; j++)
  5966. {
  5967. out_amp[2*j + 0] = amp[0][j];
  5968. out_amp[2*j + 1] = amp[1][j];
  5969. }
  5970. outframes = sf_writef_short(outhandle, out_amp, samples);
  5971. if (outframes != samples)
  5972. {
  5973. fprintf(stderr, " Error writing audio file\n");
  5974. exit(2);
  5975. }
  5976. }
  5977. #if 1
  5978. both_ways_line_model(model,
  5979. model_amp[0],
  5980. amp[0],
  5981. model_amp[1],
  5982. amp[1],
  5983. samples);
  5984. #else
  5985. vec_copyi16(model_amp[0], amp[0], samples);
  5986. vec_copyi16(model_amp[1], amp[1], samples);
  5987. #endif
  5988. v18_rx(v18[TESTER], model_amp[1], samples);
  5989. v18_rx(v18[TUT], model_amp[0], samples);
  5990. }
  5991. v18_free(v18[TESTER]);
  5992. v18_free(v18[TUT]);
  5993. printf("Test not yet implemented\n");
  5994. return 1;
  5995. }
  5996. /*- End of function --------------------------------------------------------*/
  5997. static void ans_27_put_text_msg(void *user_data, const uint8_t *msg, int len)
  5998. {
  5999. }
  6000. /*- End of function --------------------------------------------------------*/
  6001. static int test_ans_27(void)
  6002. {
  6003. logging_state_t *logging;
  6004. int16_t amp[2][SAMPLES_PER_CHUNK];
  6005. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6006. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6007. int outframes;
  6008. int samples;
  6009. int push;
  6010. int i;
  6011. int j;
  6012. /*
  6013. III.5.4.3.27 V.23 mode (390Hz) detection
  6014. Purpose: To confirm correct selection of V.23 mode.
  6015. Preamble: N/A
  6016. Method: The tester waits until the 1300Hz probe is detected from the TUT and then
  6017. transmits 390Hz for 11s.
  6018. Pass criteria: 1) After 3s of the 390Hz signal the TUT should indicate that V.23 has
  6019. been selected.
  6020. 2) The tester will confirm that the 1300Hz carrier is maintained for at least
  6021. 4s beyond the normal probe duration, i.e. Tc (= 6s default) + 4s =
  6022. 10s total.
  6023. Comments: All known V.23 devices need to receive 1300Hz tone before they will respond with
  6024. 390Hz. When the 1300Hz probe is not being transmitted, a 390Hz tone may be
  6025. interpreted as a 400Hz network tone.
  6026. */
  6027. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_27_put_text_msg, (void *) (intptr_t) 0);
  6028. logging = v18_get_logging_state(v18[TESTER]);
  6029. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6030. span_log_set_tag(logging, "Tester");
  6031. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_27_put_text_msg, (void *) (intptr_t) 1);
  6032. logging = v18_get_logging_state(v18[TUT]);
  6033. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6034. span_log_set_tag(logging, "TUT");
  6035. if ((model = both_ways_line_model_init(line_model_no,
  6036. noise_level,
  6037. echo_level_cpe1,
  6038. echo_level_co1,
  6039. line_model_no,
  6040. noise_level,
  6041. echo_level_cpe2,
  6042. echo_level_co2,
  6043. channel_codec,
  6044. rbs_pattern)) == NULL)
  6045. {
  6046. fprintf(stderr, " Failed to create line model\n");
  6047. exit(2);
  6048. }
  6049. result[TESTER][0] =
  6050. result[TUT][0] = '\0';
  6051. for (i = 0; i < 10000; i++)
  6052. {
  6053. for (j = 0; j < 2; j++)
  6054. {
  6055. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6056. push = 10;
  6057. if (samples < SAMPLES_PER_CHUNK)
  6058. {
  6059. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6060. samples = SAMPLES_PER_CHUNK;
  6061. }
  6062. }
  6063. if (log_audio)
  6064. {
  6065. for (j = 0; j < samples; j++)
  6066. {
  6067. out_amp[2*j + 0] = amp[0][j];
  6068. out_amp[2*j + 1] = amp[1][j];
  6069. }
  6070. outframes = sf_writef_short(outhandle, out_amp, samples);
  6071. if (outframes != samples)
  6072. {
  6073. fprintf(stderr, " Error writing audio file\n");
  6074. exit(2);
  6075. }
  6076. }
  6077. #if 1
  6078. both_ways_line_model(model,
  6079. model_amp[0],
  6080. amp[0],
  6081. model_amp[1],
  6082. amp[1],
  6083. samples);
  6084. #else
  6085. vec_copyi16(model_amp[0], amp[0], samples);
  6086. vec_copyi16(model_amp[1], amp[1], samples);
  6087. #endif
  6088. v18_rx(v18[TESTER], model_amp[1], samples);
  6089. v18_rx(v18[TUT], model_amp[0], samples);
  6090. }
  6091. v18_free(v18[TESTER]);
  6092. v18_free(v18[TUT]);
  6093. printf("Test not yet implemented\n");
  6094. return 1;
  6095. }
  6096. /*- End of function --------------------------------------------------------*/
  6097. static void ans_28_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6098. {
  6099. }
  6100. /*- End of function --------------------------------------------------------*/
  6101. static int test_ans_28(void)
  6102. {
  6103. logging_state_t *logging;
  6104. int16_t amp[2][SAMPLES_PER_CHUNK];
  6105. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6106. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6107. int outframes;
  6108. int samples;
  6109. int push;
  6110. int i;
  6111. int j;
  6112. /*
  6113. III.5.4.3.28 Interrupted carrier mode probe
  6114. Purpose: To ensure that the TUT continues probing from the point of interruption a maximum
  6115. of 4s after a failed connect attempt.
  6116. Preamble: The TUT should be configured for the UK country setting.
  6117. Method: The tester will call the TUT, wait for Ta to expire and then during the first V.21
  6118. probe it will send a 200ms burst of 1270Hz followed by silence for 30s.
  6119. Pass criteria: The TUT should transmit silence on detecting the 1270Hz tone and then continue
  6120. probing with the Baudot stored message 4s after the end of the 1270Hz
  6121. burst.
  6122. Comments: It is most likely that the TUT will return to probing time Ta (3s) after the
  6123. 1270Hz tone ceases. This condition needs further clarification.
  6124. */
  6125. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_28_put_text_msg, (void *) (intptr_t) 0);
  6126. logging = v18_get_logging_state(v18[TESTER]);
  6127. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6128. span_log_set_tag(logging, "Tester");
  6129. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_28_put_text_msg, (void *) (intptr_t) 1);
  6130. logging = v18_get_logging_state(v18[TUT]);
  6131. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6132. span_log_set_tag(logging, "TUT");
  6133. if ((model = both_ways_line_model_init(line_model_no,
  6134. noise_level,
  6135. echo_level_cpe1,
  6136. echo_level_co1,
  6137. line_model_no,
  6138. noise_level,
  6139. echo_level_cpe2,
  6140. echo_level_co2,
  6141. channel_codec,
  6142. rbs_pattern)) == NULL)
  6143. {
  6144. fprintf(stderr, " Failed to create line model\n");
  6145. exit(2);
  6146. }
  6147. result[TESTER][0] =
  6148. result[TUT][0] = '\0';
  6149. for (i = 0; i < 10000; i++)
  6150. {
  6151. for (j = 0; j < 2; j++)
  6152. {
  6153. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6154. push = 10;
  6155. if (samples < SAMPLES_PER_CHUNK)
  6156. {
  6157. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6158. samples = SAMPLES_PER_CHUNK;
  6159. }
  6160. }
  6161. if (log_audio)
  6162. {
  6163. for (j = 0; j < samples; j++)
  6164. {
  6165. out_amp[2*j + 0] = amp[0][j];
  6166. out_amp[2*j + 1] = amp[1][j];
  6167. }
  6168. outframes = sf_writef_short(outhandle, out_amp, samples);
  6169. if (outframes != samples)
  6170. {
  6171. fprintf(stderr, " Error writing audio file\n");
  6172. exit(2);
  6173. }
  6174. }
  6175. #if 1
  6176. both_ways_line_model(model,
  6177. model_amp[0],
  6178. amp[0],
  6179. model_amp[1],
  6180. amp[1],
  6181. samples);
  6182. #else
  6183. vec_copyi16(model_amp[0], amp[0], samples);
  6184. vec_copyi16(model_amp[1], amp[1], samples);
  6185. #endif
  6186. v18_rx(v18[TESTER], model_amp[1], samples);
  6187. v18_rx(v18[TUT], model_amp[0], samples);
  6188. }
  6189. v18_free(v18[TESTER]);
  6190. v18_free(v18[TUT]);
  6191. printf("Test not yet implemented\n");
  6192. return 1;
  6193. }
  6194. /*- End of function --------------------------------------------------------*/
  6195. static void ans_29_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6196. {
  6197. }
  6198. /*- End of function --------------------------------------------------------*/
  6199. static int test_ans_29(void)
  6200. {
  6201. logging_state_t *logging;
  6202. int16_t amp[2][SAMPLES_PER_CHUNK];
  6203. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6204. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6205. int outframes;
  6206. int samples;
  6207. int push;
  6208. int i;
  6209. int j;
  6210. /*
  6211. III.5.4.3.29 Stimulate mode response during probe
  6212. Purpose: To ensure that the TUT is able to detect an incoming signal while transmitting a
  6213. carrier mode probe.
  6214. Preamble: N/A
  6215. Method: The tester will step through each possible response as defined in tests ANS-08 to
  6216. ANS-23 for each of the carrier mode probes and for each pause after a carrierless
  6217. mode probe message.
  6218. Pass criteria: The TUT should respond as described in the appropriate test above.
  6219. Comments: The TUT may not respond to any signals while a carrierless mode probe is being
  6220. sent since these modes are half duplex.
  6221. */
  6222. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_29_put_text_msg, (void *) (intptr_t) 0);
  6223. logging = v18_get_logging_state(v18[TESTER]);
  6224. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6225. span_log_set_tag(logging, "Tester");
  6226. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_29_put_text_msg, (void *) (intptr_t) 1);
  6227. logging = v18_get_logging_state(v18[TUT]);
  6228. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6229. span_log_set_tag(logging, "TUT");
  6230. if ((model = both_ways_line_model_init(line_model_no,
  6231. noise_level,
  6232. echo_level_cpe1,
  6233. echo_level_co1,
  6234. line_model_no,
  6235. noise_level,
  6236. echo_level_cpe2,
  6237. echo_level_co2,
  6238. channel_codec,
  6239. rbs_pattern)) == NULL)
  6240. {
  6241. fprintf(stderr, " Failed to create line model\n");
  6242. exit(2);
  6243. }
  6244. result[TESTER][0] =
  6245. result[TUT][0] = '\0';
  6246. for (i = 0; i < 10000; i++)
  6247. {
  6248. for (j = 0; j < 2; j++)
  6249. {
  6250. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6251. push = 10;
  6252. if (samples < SAMPLES_PER_CHUNK)
  6253. {
  6254. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6255. samples = SAMPLES_PER_CHUNK;
  6256. }
  6257. }
  6258. if (log_audio)
  6259. {
  6260. for (j = 0; j < samples; j++)
  6261. {
  6262. out_amp[2*j + 0] = amp[0][j];
  6263. out_amp[2*j + 1] = amp[1][j];
  6264. }
  6265. outframes = sf_writef_short(outhandle, out_amp, samples);
  6266. if (outframes != samples)
  6267. {
  6268. fprintf(stderr, " Error writing audio file\n");
  6269. exit(2);
  6270. }
  6271. }
  6272. #if 1
  6273. both_ways_line_model(model,
  6274. model_amp[0],
  6275. amp[0],
  6276. model_amp[1],
  6277. amp[1],
  6278. samples);
  6279. #else
  6280. vec_copyi16(model_amp[0], amp[0], samples);
  6281. vec_copyi16(model_amp[1], amp[1], samples);
  6282. #endif
  6283. v18_rx(v18[TESTER], model_amp[1], samples);
  6284. v18_rx(v18[TUT], model_amp[0], samples);
  6285. }
  6286. v18_free(v18[TESTER]);
  6287. v18_free(v18[TUT]);
  6288. printf("Test not yet implemented\n");
  6289. return 1;
  6290. }
  6291. /*- End of function --------------------------------------------------------*/
  6292. static void ans_30_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6293. {
  6294. }
  6295. /*- End of function --------------------------------------------------------*/
  6296. static int test_ans_30(void)
  6297. {
  6298. logging_state_t *logging;
  6299. int16_t amp[2][SAMPLES_PER_CHUNK];
  6300. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6301. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6302. int outframes;
  6303. int samples;
  6304. int push;
  6305. int i;
  6306. int j;
  6307. /*
  6308. III.5.4.3.30 Immunity to network tones
  6309. Purpose: To ensure that the TUT does not interpret network tones as valid signals.
  6310. Preamble: N/A
  6311. Method: The tester will first send a busy tone to the TUT this will be followed by a number
  6312. unobtainable tone. The frequencies and cadences of the tones will vary according to
  6313. the country setting. The tester must be configured for the same country as the TUT.
  6314. Pass criteria: The countries supported by the TUT should be noted along with the response to
  6315. each tone. The tones should either be ignored or reported as the relevant network
  6316. tone to the user.
  6317. Comments: V.18 is required to recognize and report RINGING and BUSY tones. Other network
  6318. tones may be ignored. Some devices may only provide a visual indication of the
  6319. presence and cadence of the tones for instance by a flashing light.
  6320. */
  6321. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_30_put_text_msg, (void *) (intptr_t) 0);
  6322. logging = v18_get_logging_state(v18[TESTER]);
  6323. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6324. span_log_set_tag(logging, "Tester");
  6325. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_30_put_text_msg, (void *) (intptr_t) 1);
  6326. logging = v18_get_logging_state(v18[TUT]);
  6327. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6328. span_log_set_tag(logging, "TUT");
  6329. if ((model = both_ways_line_model_init(line_model_no,
  6330. noise_level,
  6331. echo_level_cpe1,
  6332. echo_level_co1,
  6333. line_model_no,
  6334. noise_level,
  6335. echo_level_cpe2,
  6336. echo_level_co2,
  6337. channel_codec,
  6338. rbs_pattern)) == NULL)
  6339. {
  6340. fprintf(stderr, " Failed to create line model\n");
  6341. exit(2);
  6342. }
  6343. result[TESTER][0] =
  6344. result[TUT][0] = '\0';
  6345. for (i = 0; i < 10000; i++)
  6346. {
  6347. for (j = 0; j < 2; j++)
  6348. {
  6349. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6350. push = 10;
  6351. if (samples < SAMPLES_PER_CHUNK)
  6352. {
  6353. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6354. samples = SAMPLES_PER_CHUNK;
  6355. }
  6356. }
  6357. if (log_audio)
  6358. {
  6359. for (j = 0; j < samples; j++)
  6360. {
  6361. out_amp[2*j + 0] = amp[0][j];
  6362. out_amp[2*j + 1] = amp[1][j];
  6363. }
  6364. outframes = sf_writef_short(outhandle, out_amp, samples);
  6365. if (outframes != samples)
  6366. {
  6367. fprintf(stderr, " Error writing audio file\n");
  6368. exit(2);
  6369. }
  6370. }
  6371. #if 1
  6372. both_ways_line_model(model,
  6373. model_amp[0],
  6374. amp[0],
  6375. model_amp[1],
  6376. amp[1],
  6377. samples);
  6378. #else
  6379. vec_copyi16(model_amp[0], amp[0], samples);
  6380. vec_copyi16(model_amp[1], amp[1], samples);
  6381. #endif
  6382. v18_rx(v18[TESTER], model_amp[1], samples);
  6383. v18_rx(v18[TUT], model_amp[0], samples);
  6384. }
  6385. v18_free(v18[TESTER]);
  6386. v18_free(v18[TUT]);
  6387. printf("Test not yet implemented\n");
  6388. return 1;
  6389. }
  6390. /*- End of function --------------------------------------------------------*/
  6391. static void ans_31_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6392. {
  6393. }
  6394. /*- End of function --------------------------------------------------------*/
  6395. static int test_ans_31(void)
  6396. {
  6397. logging_state_t *logging;
  6398. int16_t amp[2][SAMPLES_PER_CHUNK];
  6399. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6400. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6401. int outframes;
  6402. int samples;
  6403. int push;
  6404. int i;
  6405. int j;
  6406. /*
  6407. III.5.4.3.31 Immunity to fax calling tones
  6408. Purpose: To determine whether the TUT can discriminate fax calling tones.
  6409. Preamble: N/A
  6410. Method: The tester will call the TUT and send the fax calling tone, CNG. This is an 1100Hz
  6411. tone with cadence of 0.5s ON and 3s OFF as defined in ITU-T T.30.
  6412. Pass criteria: The TUT should not respond to this signal and may report it as being a calling fax
  6413. machine.
  6414. Comments: This is an optional test as detection of the fax calling tone is not required by
  6415. ITU-T V.18.
  6416. */
  6417. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_31_put_text_msg, (void *) (intptr_t) 0);
  6418. logging = v18_get_logging_state(v18[TESTER]);
  6419. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6420. span_log_set_tag(logging, "Tester");
  6421. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_31_put_text_msg, (void *) (intptr_t) 1);
  6422. logging = v18_get_logging_state(v18[TUT]);
  6423. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6424. span_log_set_tag(logging, "TUT");
  6425. if ((model = both_ways_line_model_init(line_model_no,
  6426. noise_level,
  6427. echo_level_cpe1,
  6428. echo_level_co1,
  6429. line_model_no,
  6430. noise_level,
  6431. echo_level_cpe2,
  6432. echo_level_co2,
  6433. channel_codec,
  6434. rbs_pattern)) == NULL)
  6435. {
  6436. fprintf(stderr, " Failed to create line model\n");
  6437. exit(2);
  6438. }
  6439. result[TESTER][0] =
  6440. result[TUT][0] = '\0';
  6441. for (i = 0; i < 10000; i++)
  6442. {
  6443. for (j = 0; j < 2; j++)
  6444. {
  6445. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6446. push = 10;
  6447. if (samples < SAMPLES_PER_CHUNK)
  6448. {
  6449. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6450. samples = SAMPLES_PER_CHUNK;
  6451. }
  6452. }
  6453. if (log_audio)
  6454. {
  6455. for (j = 0; j < samples; j++)
  6456. {
  6457. out_amp[2*j + 0] = amp[0][j];
  6458. out_amp[2*j + 1] = amp[1][j];
  6459. }
  6460. outframes = sf_writef_short(outhandle, out_amp, samples);
  6461. if (outframes != samples)
  6462. {
  6463. fprintf(stderr, " Error writing audio file\n");
  6464. exit(2);
  6465. }
  6466. }
  6467. #if 1
  6468. both_ways_line_model(model,
  6469. model_amp[0],
  6470. amp[0],
  6471. model_amp[1],
  6472. amp[1],
  6473. samples);
  6474. #else
  6475. vec_copyi16(model_amp[0], amp[0], samples);
  6476. vec_copyi16(model_amp[1], amp[1], samples);
  6477. #endif
  6478. v18_rx(v18[TESTER], model_amp[1], samples);
  6479. v18_rx(v18[TUT], model_amp[0], samples);
  6480. }
  6481. v18_free(v18[TESTER]);
  6482. v18_free(v18[TUT]);
  6483. printf("Test not yet implemented\n");
  6484. return 1;
  6485. }
  6486. /*- End of function --------------------------------------------------------*/
  6487. static void ans_32_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6488. {
  6489. }
  6490. /*- End of function --------------------------------------------------------*/
  6491. static int test_ans_32(void)
  6492. {
  6493. logging_state_t *logging;
  6494. int16_t amp[2][SAMPLES_PER_CHUNK];
  6495. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6496. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6497. int outframes;
  6498. int samples;
  6499. int push;
  6500. int i;
  6501. int j;
  6502. /*
  6503. III.5.4.3.32 Immunity to voice
  6504. Purpose: To ensure that the TUT does not misinterpret speech as a valid textphone signal.
  6505. Preamble: N/A
  6506. Method: The tester will respond with sampled speech. A number of phrases recorded from
  6507. typical male and female speakers will be transmitted. This will include a typical
  6508. network announcement.
  6509. Pass criteria: The TUT should ignore the speech.
  6510. Comments: Ideally the TUT should report the presence of speech back to the user. This is an
  6511. optional test.
  6512. */
  6513. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_32_put_text_msg, (void *) (intptr_t) 0);
  6514. logging = v18_get_logging_state(v18[TESTER]);
  6515. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6516. span_log_set_tag(logging, "Tester");
  6517. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_32_put_text_msg, (void *) (intptr_t) 1);
  6518. logging = v18_get_logging_state(v18[TUT]);
  6519. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6520. span_log_set_tag(logging, "TUT");
  6521. if ((model = both_ways_line_model_init(line_model_no,
  6522. noise_level,
  6523. echo_level_cpe1,
  6524. echo_level_co1,
  6525. line_model_no,
  6526. noise_level,
  6527. echo_level_cpe2,
  6528. echo_level_co2,
  6529. channel_codec,
  6530. rbs_pattern)) == NULL)
  6531. {
  6532. fprintf(stderr, " Failed to create line model\n");
  6533. exit(2);
  6534. }
  6535. result[TESTER][0] =
  6536. result[TUT][0] = '\0';
  6537. for (i = 0; i < 10000; i++)
  6538. {
  6539. for (j = 0; j < 2; j++)
  6540. {
  6541. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6542. push = 10;
  6543. if (samples < SAMPLES_PER_CHUNK)
  6544. {
  6545. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6546. samples = SAMPLES_PER_CHUNK;
  6547. }
  6548. }
  6549. if (log_audio)
  6550. {
  6551. for (j = 0; j < samples; j++)
  6552. {
  6553. out_amp[2*j + 0] = amp[0][j];
  6554. out_amp[2*j + 1] = amp[1][j];
  6555. }
  6556. outframes = sf_writef_short(outhandle, out_amp, samples);
  6557. if (outframes != samples)
  6558. {
  6559. fprintf(stderr, " Error writing audio file\n");
  6560. exit(2);
  6561. }
  6562. }
  6563. #if 1
  6564. both_ways_line_model(model,
  6565. model_amp[0],
  6566. amp[0],
  6567. model_amp[1],
  6568. amp[1],
  6569. samples);
  6570. #else
  6571. vec_copyi16(model_amp[0], amp[0], samples);
  6572. vec_copyi16(model_amp[1], amp[1], samples);
  6573. #endif
  6574. v18_rx(v18[TESTER], model_amp[1], samples);
  6575. v18_rx(v18[TUT], model_amp[0], samples);
  6576. }
  6577. v18_free(v18[TESTER]);
  6578. v18_free(v18[TUT]);
  6579. printf("Test not yet implemented\n");
  6580. return 1;
  6581. }
  6582. /*- End of function --------------------------------------------------------*/
  6583. static void ans_33_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6584. {
  6585. }
  6586. /*- End of function --------------------------------------------------------*/
  6587. static int test_ans_33(void)
  6588. {
  6589. logging_state_t *logging;
  6590. int16_t amp[2][SAMPLES_PER_CHUNK];
  6591. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6592. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6593. int outframes;
  6594. int samples;
  6595. int push;
  6596. int i;
  6597. int j;
  6598. /*
  6599. III.5.4.3.33 CM detection and V.8 answering
  6600. Purpose: To confirm that the TUT will respond correctly to CM signals and connect
  6601. according to V.8 procedures.
  6602. Preamble: N/A
  6603. Method: The tester will transmit 2 sequences of 4 CI patterns separated by 2s. On
  6604. reception of the ANSam tone the tester will wait 0.5s and then begin
  6605. transmitting the CM signal with textphone and V.21 specified.
  6606. Pass criteria: 1) On reception of the CM signal, the TUT should transmit JM with textphone
  6607. and V.21.
  6608. 2) The TUT should then transmit in V.21 (2) mode.
  6609. 3) The JM should be followed by continuous 1650Hz.
  6610. 4) Correct transmission and reception of T.140 data should be verified after the
  6611. V.18 mode connection is completed.
  6612. Comments: The TUT should indicate V.18 mode.
  6613. */
  6614. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_33_put_text_msg, (void *) (intptr_t) 0);
  6615. logging = v18_get_logging_state(v18[TESTER]);
  6616. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6617. span_log_set_tag(logging, "Tester");
  6618. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, ans_33_put_text_msg, (void *) (intptr_t) 1);
  6619. logging = v18_get_logging_state(v18[TUT]);
  6620. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6621. span_log_set_tag(logging, "TUT");
  6622. if ((model = both_ways_line_model_init(line_model_no,
  6623. noise_level,
  6624. echo_level_cpe1,
  6625. echo_level_co1,
  6626. line_model_no,
  6627. noise_level,
  6628. echo_level_cpe2,
  6629. echo_level_co2,
  6630. channel_codec,
  6631. rbs_pattern)) == NULL)
  6632. {
  6633. fprintf(stderr, " Failed to create line model\n");
  6634. exit(2);
  6635. }
  6636. result[TESTER][0] =
  6637. result[TUT][0] = '\0';
  6638. for (i = 0; i < 10000; i++)
  6639. {
  6640. for (j = 0; j < 2; j++)
  6641. {
  6642. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6643. push = 10;
  6644. if (samples < SAMPLES_PER_CHUNK)
  6645. {
  6646. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6647. samples = SAMPLES_PER_CHUNK;
  6648. }
  6649. }
  6650. if (log_audio)
  6651. {
  6652. for (j = 0; j < samples; j++)
  6653. {
  6654. out_amp[2*j + 0] = amp[0][j];
  6655. out_amp[2*j + 1] = amp[1][j];
  6656. }
  6657. outframes = sf_writef_short(outhandle, out_amp, samples);
  6658. if (outframes != samples)
  6659. {
  6660. fprintf(stderr, " Error writing audio file\n");
  6661. exit(2);
  6662. }
  6663. }
  6664. #if 1
  6665. both_ways_line_model(model,
  6666. model_amp[0],
  6667. amp[0],
  6668. model_amp[1],
  6669. amp[1],
  6670. samples);
  6671. #else
  6672. vec_copyi16(model_amp[0], amp[0], samples);
  6673. vec_copyi16(model_amp[1], amp[1], samples);
  6674. #endif
  6675. v18_rx(v18[TESTER], model_amp[1], samples);
  6676. v18_rx(v18[TUT], model_amp[0], samples);
  6677. }
  6678. v18_free(v18[TESTER]);
  6679. v18_free(v18[TUT]);
  6680. printf("Test not yet implemented\n");
  6681. return 1;
  6682. }
  6683. /*- End of function --------------------------------------------------------*/
  6684. static void mon_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6685. {
  6686. }
  6687. /*- End of function --------------------------------------------------------*/
  6688. static int test_mon_01(void)
  6689. {
  6690. printf("Test not yet implemented\n");
  6691. return 1;
  6692. }
  6693. /*- End of function --------------------------------------------------------*/
  6694. static void mon_21_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6695. {
  6696. }
  6697. /*- End of function --------------------------------------------------------*/
  6698. static int test_mon_21(void)
  6699. {
  6700. logging_state_t *logging;
  6701. int16_t amp[2][SAMPLES_PER_CHUNK];
  6702. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6703. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6704. int outframes;
  6705. int samples;
  6706. int push;
  6707. int i;
  6708. int j;
  6709. /*
  6710. III.5.4.4.1 Automode monitor Ta timer test
  6711. Purpose: To ensure that on entering monitor mode, timer Ta (3s) is not active and that
  6712. the TUT does not enter the probing state.
  6713. Preamble: N/A
  6714. Method: The TUT should be put into monitor state. The tester will then monitor for signals
  6715. for 1 minute.
  6716. Pass criteria: The TUT should not start probing.
  6717. */
  6718. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_21_put_text_msg, (void *) (intptr_t) 0);
  6719. logging = v18_get_logging_state(v18[TESTER]);
  6720. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6721. span_log_set_tag(logging, "Tester");
  6722. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_21_put_text_msg, (void *) (intptr_t) 1);
  6723. logging = v18_get_logging_state(v18[TUT]);
  6724. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6725. span_log_set_tag(logging, "TUT");
  6726. if ((model = both_ways_line_model_init(line_model_no,
  6727. noise_level,
  6728. echo_level_cpe1,
  6729. echo_level_co1,
  6730. line_model_no,
  6731. noise_level,
  6732. echo_level_cpe2,
  6733. echo_level_co2,
  6734. channel_codec,
  6735. rbs_pattern)) == NULL)
  6736. {
  6737. fprintf(stderr, " Failed to create line model\n");
  6738. exit(2);
  6739. }
  6740. result[TESTER][0] =
  6741. result[TUT][0] = '\0';
  6742. for (i = 0; i < 10000; i++)
  6743. {
  6744. for (j = 0; j < 2; j++)
  6745. {
  6746. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6747. push = 10;
  6748. if (samples < SAMPLES_PER_CHUNK)
  6749. {
  6750. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6751. samples = SAMPLES_PER_CHUNK;
  6752. }
  6753. }
  6754. if (log_audio)
  6755. {
  6756. for (j = 0; j < samples; j++)
  6757. {
  6758. out_amp[2*j + 0] = amp[0][j];
  6759. out_amp[2*j + 1] = amp[1][j];
  6760. }
  6761. outframes = sf_writef_short(outhandle, out_amp, samples);
  6762. if (outframes != samples)
  6763. {
  6764. fprintf(stderr, " Error writing audio file\n");
  6765. exit(2);
  6766. }
  6767. }
  6768. #if 1
  6769. both_ways_line_model(model,
  6770. model_amp[0],
  6771. amp[0],
  6772. model_amp[1],
  6773. amp[1],
  6774. samples);
  6775. #else
  6776. vec_copyi16(model_amp[0], amp[0], samples);
  6777. vec_copyi16(model_amp[1], amp[1], samples);
  6778. #endif
  6779. v18_rx(v18[TESTER], model_amp[1], samples);
  6780. v18_rx(v18[TUT], model_amp[0], samples);
  6781. }
  6782. v18_free(v18[TESTER]);
  6783. v18_free(v18[TUT]);
  6784. printf("Test not yet implemented\n");
  6785. return 1;
  6786. }
  6787. /*- End of function --------------------------------------------------------*/
  6788. static void mon_22_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6789. {
  6790. }
  6791. /*- End of function --------------------------------------------------------*/
  6792. static int test_mon_22(void)
  6793. {
  6794. logging_state_t *logging;
  6795. int16_t amp[2][SAMPLES_PER_CHUNK];
  6796. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6797. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6798. int outframes;
  6799. int samples;
  6800. int push;
  6801. int i;
  6802. int j;
  6803. /*
  6804. III.5.4.4.2 Automode monitor 1300Hz calling tone discrimination
  6805. Purpose: To confirm correct detection and reporting of 1300Hz calling tones as defined in
  6806. ITU-T V.25.
  6807. Preamble: N/A
  6808. Method: The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
  6809. (d) 800ms followed by 1s of silence.
  6810. Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms.
  6811. 2) The TUT should report detection of calling tones to the DTE after a burst of
  6812. 1300Hz for 500ms or 700ms followed by 1s of silence.
  6813. Comments: In automode answer, the 1300Hz calling causes the DCE to start probing. In
  6814. monitor mode it should only report detection to the DTE.
  6815. */
  6816. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_22_put_text_msg, (void *) (intptr_t) 0);
  6817. logging = v18_get_logging_state(v18[TESTER]);
  6818. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6819. span_log_set_tag(logging, "Tester");
  6820. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_22_put_text_msg, (void *) (intptr_t) 1);
  6821. logging = v18_get_logging_state(v18[TUT]);
  6822. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6823. span_log_set_tag(logging, "TUT");
  6824. if ((model = both_ways_line_model_init(line_model_no,
  6825. noise_level,
  6826. echo_level_cpe1,
  6827. echo_level_co1,
  6828. line_model_no,
  6829. noise_level,
  6830. echo_level_cpe2,
  6831. echo_level_co2,
  6832. channel_codec,
  6833. rbs_pattern)) == NULL)
  6834. {
  6835. fprintf(stderr, " Failed to create line model\n");
  6836. exit(2);
  6837. }
  6838. result[TESTER][0] =
  6839. result[TUT][0] = '\0';
  6840. for (i = 0; i < 10000; i++)
  6841. {
  6842. for (j = 0; j < 2; j++)
  6843. {
  6844. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6845. push = 10;
  6846. if (samples < SAMPLES_PER_CHUNK)
  6847. {
  6848. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6849. samples = SAMPLES_PER_CHUNK;
  6850. }
  6851. }
  6852. if (log_audio)
  6853. {
  6854. for (j = 0; j < samples; j++)
  6855. {
  6856. out_amp[2*j + 0] = amp[0][j];
  6857. out_amp[2*j + 1] = amp[1][j];
  6858. }
  6859. outframes = sf_writef_short(outhandle, out_amp, samples);
  6860. if (outframes != samples)
  6861. {
  6862. fprintf(stderr, " Error writing audio file\n");
  6863. exit(2);
  6864. }
  6865. }
  6866. #if 1
  6867. both_ways_line_model(model,
  6868. model_amp[0],
  6869. amp[0],
  6870. model_amp[1],
  6871. amp[1],
  6872. samples);
  6873. #else
  6874. vec_copyi16(model_amp[0], amp[0], samples);
  6875. vec_copyi16(model_amp[1], amp[1], samples);
  6876. #endif
  6877. v18_rx(v18[TESTER], model_amp[1], samples);
  6878. v18_rx(v18[TUT], model_amp[0], samples);
  6879. }
  6880. v18_free(v18[TESTER]);
  6881. v18_free(v18[TUT]);
  6882. printf("Test not yet implemented\n");
  6883. return 1;
  6884. }
  6885. /*- End of function --------------------------------------------------------*/
  6886. static void mon_23_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6887. {
  6888. }
  6889. /*- End of function --------------------------------------------------------*/
  6890. static int test_mon_23(void)
  6891. {
  6892. logging_state_t *logging;
  6893. int16_t amp[2][SAMPLES_PER_CHUNK];
  6894. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6895. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6896. int outframes;
  6897. int samples;
  6898. int push;
  6899. int i;
  6900. int j;
  6901. /*
  6902. III.5.4.4.3 Automode monitor 980Hz calling tone discrimination
  6903. Purpose: To confirm correct detection and reporting of 980Hz calling tones as defined in
  6904. ITU-T V.25.
  6905. Preamble: N/A
  6906. Method: The tester will send 980Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
  6907. (d) 800ms followed by 1s of silence.
  6908. Pass criteria: 1) The TUT should not respond to bursts of 400ms or 800ms.
  6909. 2) The TUT should report detection of calling tones to the DTE after a burst of
  6910. 980Hz for 500ms or 700ms followed by 1s of silence.
  6911. Comments: In automode answer, the 980Hz calling causes the DCE to start probing. In monitor
  6912. mode it should only report detection to the DTE.
  6913. */
  6914. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_23_put_text_msg, (void *) (intptr_t) 0);
  6915. logging = v18_get_logging_state(v18[TESTER]);
  6916. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6917. span_log_set_tag(logging, "Tester");
  6918. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, mon_23_put_text_msg, (void *) (intptr_t) 1);
  6919. logging = v18_get_logging_state(v18[TUT]);
  6920. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  6921. span_log_set_tag(logging, "TUT");
  6922. if ((model = both_ways_line_model_init(line_model_no,
  6923. noise_level,
  6924. echo_level_cpe1,
  6925. echo_level_co1,
  6926. line_model_no,
  6927. noise_level,
  6928. echo_level_cpe2,
  6929. echo_level_co2,
  6930. channel_codec,
  6931. rbs_pattern)) == NULL)
  6932. {
  6933. fprintf(stderr, " Failed to create line model\n");
  6934. exit(2);
  6935. }
  6936. result[TESTER][0] =
  6937. result[TUT][0] = '\0';
  6938. for (i = 0; i < 10000; i++)
  6939. {
  6940. for (j = 0; j < 2; j++)
  6941. {
  6942. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  6943. push = 10;
  6944. if (samples < SAMPLES_PER_CHUNK)
  6945. {
  6946. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  6947. samples = SAMPLES_PER_CHUNK;
  6948. }
  6949. }
  6950. if (log_audio)
  6951. {
  6952. for (j = 0; j < samples; j++)
  6953. {
  6954. out_amp[2*j + 0] = amp[0][j];
  6955. out_amp[2*j + 1] = amp[1][j];
  6956. }
  6957. outframes = sf_writef_short(outhandle, out_amp, samples);
  6958. if (outframes != samples)
  6959. {
  6960. fprintf(stderr, " Error writing audio file\n");
  6961. exit(2);
  6962. }
  6963. }
  6964. #if 1
  6965. both_ways_line_model(model,
  6966. model_amp[0],
  6967. amp[0],
  6968. model_amp[1],
  6969. amp[1],
  6970. samples);
  6971. #else
  6972. vec_copyi16(model_amp[0], amp[0], samples);
  6973. vec_copyi16(model_amp[1], amp[1], samples);
  6974. #endif
  6975. v18_rx(v18[TESTER], model_amp[1], samples);
  6976. v18_rx(v18[TUT], model_amp[0], samples);
  6977. }
  6978. v18_free(v18[TESTER]);
  6979. v18_free(v18[TUT]);
  6980. printf("Test not yet implemented\n");
  6981. return 1;
  6982. }
  6983. /*- End of function --------------------------------------------------------*/
  6984. static void x_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
  6985. {
  6986. printf("1-1 %d '%s'\n", len, msg);
  6987. if (user_data == NULL)
  6988. strcat(result[TUT], (const char *) msg);
  6989. else
  6990. v18_put(v18[TUT], "abcdefghij", 10);
  6991. }
  6992. /*- End of function --------------------------------------------------------*/
  6993. static int test_x_01(void)
  6994. {
  6995. logging_state_t *logging;
  6996. int16_t amp[2][SAMPLES_PER_CHUNK];
  6997. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  6998. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  6999. int outframes;
  7000. int samples;
  7001. int push;
  7002. int i;
  7003. int j;
  7004. const char *ref;
  7005. /*
  7006. III.5.4.5.1 Baudot carrier timing and receiver disabling
  7007. Purpose: To verify that the TUT sends unmodulated carrier for 150ms before a new character
  7008. and disables its receiver for 300ms after a character is transmitted.
  7009. Preamble: Establish a call between the tester and TUT in Baudot mode.
  7010. Method: The operator should send a single character from the TUT. The tester will
  7011. immediately start sending a unique character sequence. Examination of the TUT
  7012. display will show when its receiver is re-enabled.
  7013. Pass criteria: 1) The TUT should send unmodulated carrier for 150ms before the beginning of
  7014. the start bit.
  7015. 2) The receiver should be re-enabled after 300ms.
  7016. 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
  7017. Comments: The carrier should be maintained during the 300ms after a character.
  7018. */
  7019. v18[TESTER] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 0);
  7020. logging = v18_get_logging_state(v18[TESTER]);
  7021. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7022. span_log_set_tag(logging, "Tester");
  7023. v18[TUT] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 1);
  7024. logging = v18_get_logging_state(v18[TUT]);
  7025. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7026. span_log_set_tag(logging, "TUT");
  7027. if ((model = both_ways_line_model_init(line_model_no,
  7028. noise_level,
  7029. echo_level_cpe1,
  7030. echo_level_co1,
  7031. line_model_no,
  7032. noise_level,
  7033. echo_level_cpe2,
  7034. echo_level_co2,
  7035. channel_codec,
  7036. rbs_pattern)) == NULL)
  7037. {
  7038. fprintf(stderr, " Failed to create line model\n");
  7039. exit(2);
  7040. }
  7041. result[TESTER][0] =
  7042. result[TUT][0] = '\0';
  7043. v18_put(v18[TESTER], "zabcdefghijklmnopq", -1);
  7044. for (i = 0; i < 10000; i++)
  7045. {
  7046. for (j = 0; j < 2; j++)
  7047. {
  7048. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7049. push = 10;
  7050. if (samples < SAMPLES_PER_CHUNK)
  7051. {
  7052. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7053. samples = SAMPLES_PER_CHUNK;
  7054. }
  7055. }
  7056. if (log_audio)
  7057. {
  7058. for (j = 0; j < samples; j++)
  7059. {
  7060. out_amp[2*j + 0] = amp[0][j];
  7061. out_amp[2*j + 1] = amp[1][j];
  7062. }
  7063. outframes = sf_writef_short(outhandle, out_amp, samples);
  7064. if (outframes != samples)
  7065. {
  7066. fprintf(stderr, " Error writing audio file\n");
  7067. exit(2);
  7068. }
  7069. }
  7070. #if 1
  7071. both_ways_line_model(model,
  7072. model_amp[0],
  7073. amp[0],
  7074. model_amp[1],
  7075. amp[1],
  7076. samples);
  7077. #else
  7078. vec_copyi16(model_amp[0], amp[0], samples);
  7079. vec_copyi16(model_amp[1], amp[1], samples);
  7080. #endif
  7081. v18_rx(v18[TESTER], model_amp[1], samples);
  7082. v18_rx(v18[TUT], model_amp[0], samples);
  7083. }
  7084. v18_free(v18[TESTER]);
  7085. v18_free(v18[TUT]);
  7086. ref = "cdefghij";
  7087. printf("Result:\n%s\n", result[TUT]);
  7088. printf("Reference result:\n%s\n", ref);
  7089. if (unexpected_echo || strcmp(result[TUT], ref) != 0)
  7090. return -1;
  7091. return 1;
  7092. }
  7093. /*- End of function --------------------------------------------------------*/
  7094. static void x_02_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7095. {
  7096. }
  7097. /*- End of function --------------------------------------------------------*/
  7098. static int test_x_02(void)
  7099. {
  7100. logging_state_t *logging;
  7101. int16_t amp[2][SAMPLES_PER_CHUNK];
  7102. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7103. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7104. int outframes;
  7105. int samples;
  7106. int push;
  7107. int i;
  7108. int j;
  7109. /*
  7110. III.5.4.5.2 Baudot bit rate confirmation
  7111. Purpose: To verify that the TUT uses the correct bit rates in the Baudot mode.
  7112. Preamble: Establish a call between the tester and TUT in Baudot mode for each of the two
  7113. tests.
  7114. Method: The operator should select Baudot (a) 45 bit/s followed by (b) 50 bit/s modes and
  7115. transmit the string "abcdef" at each rate.
  7116. Pass criteria: The tester will measure the bit timings and confirm the rates.
  7117. */
  7118. v18[TESTER] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_02_put_text_msg, (void *) (intptr_t) 0);
  7119. logging = v18_get_logging_state(v18[TESTER]);
  7120. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7121. span_log_set_tag(logging, "Tester");
  7122. v18[TUT] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_02_put_text_msg, (void *) (intptr_t) 1);
  7123. logging = v18_get_logging_state(v18[TUT]);
  7124. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7125. span_log_set_tag(logging, "TUT");
  7126. if ((model = both_ways_line_model_init(line_model_no,
  7127. noise_level,
  7128. echo_level_cpe1,
  7129. echo_level_co1,
  7130. line_model_no,
  7131. noise_level,
  7132. echo_level_cpe2,
  7133. echo_level_co2,
  7134. channel_codec,
  7135. rbs_pattern)) == NULL)
  7136. {
  7137. fprintf(stderr, " Failed to create line model\n");
  7138. exit(2);
  7139. }
  7140. result[TESTER][0] =
  7141. result[TUT][0] = '\0';
  7142. for (i = 0; i < 10000; i++)
  7143. {
  7144. for (j = 0; j < 2; j++)
  7145. {
  7146. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7147. push = 10;
  7148. if (samples < SAMPLES_PER_CHUNK)
  7149. {
  7150. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7151. samples = SAMPLES_PER_CHUNK;
  7152. }
  7153. }
  7154. if (log_audio)
  7155. {
  7156. for (j = 0; j < samples; j++)
  7157. {
  7158. out_amp[2*j + 0] = amp[0][j];
  7159. out_amp[2*j + 1] = amp[1][j];
  7160. }
  7161. outframes = sf_writef_short(outhandle, out_amp, samples);
  7162. if (outframes != samples)
  7163. {
  7164. fprintf(stderr, " Error writing audio file\n");
  7165. exit(2);
  7166. }
  7167. }
  7168. #if 1
  7169. both_ways_line_model(model,
  7170. model_amp[0],
  7171. amp[0],
  7172. model_amp[1],
  7173. amp[1],
  7174. samples);
  7175. #else
  7176. vec_copyi16(model_amp[0], amp[0], samples);
  7177. vec_copyi16(model_amp[1], amp[1], samples);
  7178. #endif
  7179. v18_rx(v18[TESTER], model_amp[1], samples);
  7180. v18_rx(v18[TUT], model_amp[0], samples);
  7181. }
  7182. v18_free(v18[TESTER]);
  7183. v18_free(v18[TUT]);
  7184. printf("Test not yet implemented\n");
  7185. return 1;
  7186. }
  7187. /*- End of function --------------------------------------------------------*/
  7188. static void x_03_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7189. {
  7190. }
  7191. /*- End of function --------------------------------------------------------*/
  7192. static int test_x_03(void)
  7193. {
  7194. logging_state_t *logging;
  7195. int16_t amp[2][SAMPLES_PER_CHUNK];
  7196. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7197. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7198. int outframes;
  7199. int samples;
  7200. int push;
  7201. int i;
  7202. int j;
  7203. /*
  7204. III.5.4.5.3 Baudot probe bit rate confirmation
  7205. Purpose: To verify that the TUT uses the correct bit rates in the Baudot mode probe during
  7206. automoding.
  7207. Preamble: Set the user defined carrierless mode probe message to the string "abcdef" if
  7208. possible. Set the TUT country setting to "United States". A call should be initiated
  7209. from the tester to the TUT.
  7210. Method: The tester will wait for the Baudot mode probe and measure the bit rate.
  7211. Pass criteria: The tester will measure the bit timings and confirm the rate of 47.6 bit/s.
  7212. Comments: The probe message must be long enough for the tester to establish the bit rate. "GA"
  7213. may not be sufficient.
  7214. */
  7215. v18[TESTER] = v18_init(NULL, true, V18_MODE_5BIT_4545, V18_AUTOMODING_USA, x_03_put_text_msg, (void *) (intptr_t) 0);
  7216. logging = v18_get_logging_state(v18[TESTER]);
  7217. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7218. span_log_set_tag(logging, "Tester");
  7219. v18[TUT] = v18_init(NULL, false, V18_MODE_5BIT_4545, V18_AUTOMODING_USA, x_03_put_text_msg, (void *) (intptr_t) 1);
  7220. logging = v18_get_logging_state(v18[TUT]);
  7221. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7222. span_log_set_tag(logging, "TUT");
  7223. if ((model = both_ways_line_model_init(line_model_no,
  7224. noise_level,
  7225. echo_level_cpe1,
  7226. echo_level_co1,
  7227. line_model_no,
  7228. noise_level,
  7229. echo_level_cpe2,
  7230. echo_level_co2,
  7231. channel_codec,
  7232. rbs_pattern)) == NULL)
  7233. {
  7234. fprintf(stderr, " Failed to create line model\n");
  7235. exit(2);
  7236. }
  7237. result[TESTER][0] =
  7238. result[TUT][0] = '\0';
  7239. for (i = 0; i < 10000; i++)
  7240. {
  7241. for (j = 0; j < 2; j++)
  7242. {
  7243. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7244. push = 10;
  7245. if (samples < SAMPLES_PER_CHUNK)
  7246. {
  7247. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7248. samples = SAMPLES_PER_CHUNK;
  7249. }
  7250. }
  7251. if (log_audio)
  7252. {
  7253. for (j = 0; j < samples; j++)
  7254. {
  7255. out_amp[2*j + 0] = amp[0][j];
  7256. out_amp[2*j + 1] = amp[1][j];
  7257. }
  7258. outframes = sf_writef_short(outhandle, out_amp, samples);
  7259. if (outframes != samples)
  7260. {
  7261. fprintf(stderr, " Error writing audio file\n");
  7262. exit(2);
  7263. }
  7264. }
  7265. #if 1
  7266. both_ways_line_model(model,
  7267. model_amp[0],
  7268. amp[0],
  7269. model_amp[1],
  7270. amp[1],
  7271. samples);
  7272. #else
  7273. vec_copyi16(model_amp[0], amp[0], samples);
  7274. vec_copyi16(model_amp[1], amp[1], samples);
  7275. #endif
  7276. v18_rx(v18[TESTER], model_amp[1], samples);
  7277. v18_rx(v18[TUT], model_amp[0], samples);
  7278. }
  7279. v18_free(v18[TESTER]);
  7280. v18_free(v18[TUT]);
  7281. printf("Test not yet implemented\n");
  7282. return 1;
  7283. }
  7284. /*- End of function --------------------------------------------------------*/
  7285. static void x_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7286. {
  7287. if (user_data == NULL)
  7288. {
  7289. strcat(result[TESTER], (const char *) msg);
  7290. printf("Unexpected ECHO received (%d) '%s'\n", len, msg);
  7291. unexpected_echo = true;
  7292. }
  7293. else
  7294. {
  7295. printf("1-1 %d '%s'\n", len, msg);
  7296. strcat(result[TUT], (const char *) msg);
  7297. /* Echo each received character */
  7298. //v18_put(v18[TUT], msg, len);
  7299. }
  7300. }
  7301. /*- End of function --------------------------------------------------------*/
  7302. static int test_x_04(void)
  7303. {
  7304. char msg[1024];
  7305. logging_state_t *logging;
  7306. int16_t amp[2][SAMPLES_PER_CHUNK];
  7307. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7308. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7309. int outframes;
  7310. int samples;
  7311. int i;
  7312. int j;
  7313. /*
  7314. III.5.4.5.4 5 Bit to T.50 character conversion
  7315. Purpose: To check that the character conversion tables in Annex A have been correctly
  7316. implemented.
  7317. Preamble: Establish a call between the tester and TUT in Baudot mode at 45 bit/s.
  7318. Method: The tester will send all possible characters preceded by the relevant case shift
  7319. command one at a time and wait for a response from the TUT operator. Each
  7320. character should be responded to at the TUT by typing the received character or
  7321. <CR> if the character is not available.
  7322. Pass criteria: 1) The tester will verify that each character is correctly echoed back by the TUT.
  7323. The operator should verify that each character is correctly displayed on the TUT.
  7324. 2) The TUT will send the LTRS symbol before its first character and the
  7325. appropriate mode character (either LTRS or FIGS) after every 72 subsequent
  7326. characters.
  7327. Comments: The tester should indicate which character has been sent in each case. Some of the
  7328. characters may not be available from the TUT keyboard and can be ignored. It is
  7329. assumed that the character conversion is the same for Baudot at 50 bit/s and any
  7330. other supported speed.
  7331. */
  7332. v18[TESTER] = v18_init(NULL, true, V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, (void *) (intptr_t) 0);
  7333. logging = v18_get_logging_state(v18[TESTER]);
  7334. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7335. span_log_set_tag(logging, "Tester");
  7336. v18[TUT] = v18_init(NULL, false, V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, (void *) (intptr_t) 1);
  7337. logging = v18_get_logging_state(v18[TUT]);
  7338. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7339. span_log_set_tag(logging, "TUT");
  7340. if ((model = both_ways_line_model_init(line_model_no,
  7341. noise_level,
  7342. echo_level_cpe1,
  7343. echo_level_co1,
  7344. line_model_no,
  7345. noise_level,
  7346. echo_level_cpe2,
  7347. echo_level_co2,
  7348. channel_codec,
  7349. rbs_pattern)) == NULL)
  7350. {
  7351. fprintf(stderr, " Failed to create line model\n");
  7352. exit(2);
  7353. }
  7354. result[TESTER][0] =
  7355. result[TUT][0] = '\0';
  7356. unexpected_echo = false;
  7357. for (i = 0; i < 127; i++)
  7358. msg[i] = i + 1;
  7359. msg[127] = '\0';
  7360. v18_put(v18[TESTER], msg, 127);
  7361. for (i = 0; i < 2000; i++)
  7362. {
  7363. for (j = 0; j < 2; j++)
  7364. {
  7365. samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK);
  7366. if (samples < SAMPLES_PER_CHUNK)
  7367. {
  7368. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7369. samples = SAMPLES_PER_CHUNK;
  7370. }
  7371. }
  7372. if (log_audio)
  7373. {
  7374. for (j = 0; j < samples; j++)
  7375. {
  7376. out_amp[2*j + 0] = amp[0][j];
  7377. out_amp[2*j + 1] = amp[1][j];
  7378. }
  7379. outframes = sf_writef_short(outhandle, out_amp, samples);
  7380. if (outframes != samples)
  7381. {
  7382. fprintf(stderr, " Error writing audio file\n");
  7383. exit(2);
  7384. }
  7385. }
  7386. #if 1
  7387. both_ways_line_model(model,
  7388. model_amp[0],
  7389. amp[0],
  7390. model_amp[1],
  7391. amp[1],
  7392. samples);
  7393. #else
  7394. vec_copyi16(model_amp[0], amp[0], samples);
  7395. vec_copyi16(model_amp[1], amp[1], samples);
  7396. #endif
  7397. v18_rx(v18[TESTER], model_amp[1], samples);
  7398. v18_rx(v18[TUT], model_amp[0], samples);
  7399. }
  7400. v18_free(v18[TESTER]);
  7401. v18_free(v18[TUT]);
  7402. printf("Result:\n%s\n", result[TESTER]);
  7403. printf("Result:\n%s\n", result[TUT]);
  7404. printf("Reference result:\n%s\n", full_baudot_rx);
  7405. if (unexpected_echo || strcmp(result[TUT], full_baudot_rx) != 0)
  7406. return -1;
  7407. return 0;
  7408. }
  7409. /*- End of function --------------------------------------------------------*/
  7410. static void x_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7411. {
  7412. if (user_data == NULL)
  7413. {
  7414. /* Gather the received characters, which should be like the transmitted characters,
  7415. but with the first three characters missing. */
  7416. strcat(result[TESTER], (const char *) msg);
  7417. }
  7418. else
  7419. {
  7420. /* Receiving a character from the far end should block out its receiver
  7421. for a while. If we send a stream of DTMF back, the first few characters
  7422. (actually 3 for this particular text string) should be lost. */
  7423. v18_put(v18[TUT], "behknqtwz", 9);
  7424. }
  7425. }
  7426. /*- End of function --------------------------------------------------------*/
  7427. static int test_x_05(void)
  7428. {
  7429. logging_state_t *logging;
  7430. int16_t amp[2][SAMPLES_PER_CHUNK];
  7431. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7432. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7433. int outframes;
  7434. int samples;
  7435. int push;
  7436. int i;
  7437. int j;
  7438. const char *ref;
  7439. /*
  7440. III.5.4.5.5 DTMF receiver disabling
  7441. Purpose: To verify that the TUT disables its DTMF receiver for 300ms when a character is
  7442. transmitted.
  7443. Preamble: Establish a call between the tester and TUT in DTMF mode.
  7444. Method: The operator should send a single "e" character from the TUT which will result in
  7445. sending a single DTMF tone to the tester. The tester will immediately start sending a
  7446. unique character sequence using single DTMF tones. Examination of the TUT
  7447. display will show when its receiver is re-enabled.
  7448. Pass criteria: The receiver should be re-enabled after 300ms.
  7449. */
  7450. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, (void *) (intptr_t) 0);
  7451. logging = v18_get_logging_state(v18[TESTER]);
  7452. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7453. span_log_set_tag(logging, "Tester");
  7454. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, (void *) (intptr_t) 1);
  7455. logging = v18_get_logging_state(v18[TUT]);
  7456. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7457. span_log_set_tag(logging, "TUT");
  7458. if ((model = both_ways_line_model_init(line_model_no,
  7459. noise_level,
  7460. echo_level_cpe1,
  7461. echo_level_co1,
  7462. line_model_no,
  7463. noise_level,
  7464. echo_level_cpe2,
  7465. echo_level_co2,
  7466. channel_codec,
  7467. rbs_pattern)) == NULL)
  7468. {
  7469. fprintf(stderr, " Failed to create line model\n");
  7470. exit(2);
  7471. }
  7472. result[TESTER][0] =
  7473. result[TUT][0] = '\0';
  7474. /* Sending a character should block out the receiver for a while */
  7475. v18_put(v18[TESTER], "z", 1);
  7476. for (i = 0; i < 1000; i++)
  7477. {
  7478. for (j = 0; j < 2; j++)
  7479. {
  7480. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7481. push = 10;
  7482. if (samples < SAMPLES_PER_CHUNK)
  7483. {
  7484. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7485. samples = SAMPLES_PER_CHUNK;
  7486. }
  7487. }
  7488. if (log_audio)
  7489. {
  7490. for (j = 0; j < samples; j++)
  7491. {
  7492. out_amp[2*j + 0] = amp[0][j];
  7493. out_amp[2*j + 1] = amp[1][j];
  7494. }
  7495. outframes = sf_writef_short(outhandle, out_amp, samples);
  7496. if (outframes != samples)
  7497. {
  7498. fprintf(stderr, " Error writing audio file\n");
  7499. exit(2);
  7500. }
  7501. }
  7502. #if 1
  7503. both_ways_line_model(model,
  7504. model_amp[0],
  7505. amp[0],
  7506. model_amp[1],
  7507. amp[1],
  7508. samples);
  7509. #else
  7510. vec_copyi16(model_amp[0], amp[0], samples);
  7511. vec_copyi16(model_amp[1], amp[1], samples);
  7512. #endif
  7513. v18_rx(v18[TESTER], model_amp[1], samples);
  7514. v18_rx(v18[TUT], model_amp[0], samples);
  7515. }
  7516. v18_free(v18[TESTER]);
  7517. v18_free(v18[TUT]);
  7518. ref = "knqtwz";
  7519. printf("Result:\n%s\n", result[TESTER]);
  7520. printf("Reference result:\n%s\n", ref);
  7521. if (strcmp(result[TESTER], ref) != 0)
  7522. return -1;
  7523. return 0;
  7524. }
  7525. /*- End of function --------------------------------------------------------*/
  7526. static void x_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7527. {
  7528. if (user_data == NULL)
  7529. ;
  7530. else
  7531. strcat(result[TUT], (const char *) msg);
  7532. }
  7533. /*- End of function --------------------------------------------------------*/
  7534. static int test_x_06(void)
  7535. {
  7536. char msg[128];
  7537. const char *ref;
  7538. logging_state_t *logging;
  7539. int16_t amp[2][SAMPLES_PER_CHUNK];
  7540. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7541. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7542. int outframes;
  7543. int samples;
  7544. int push;
  7545. int i;
  7546. int j;
  7547. /*
  7548. III.5.4.5.6 DTMF character conversion
  7549. Purpose: To check that the character conversion tables in Annex B have been correctly
  7550. implemented.
  7551. Preamble: Establish a call between the tester and TUT in DTMF mode.
  7552. Method: The tester will send each character from the set in Annex B, waiting for a response
  7553. after each one. Each character should be responded to at the TUT by typing the
  7554. same character.
  7555. Pass criteria: The tester will verify that each character is correctly echoed back by the TUT.
  7556. Comments: The conversion table is specified in Annex B. The receiver at the tester may be
  7557. re-enabled 100ms after transmission of each character to maximize likelihood of
  7558. receiving character from the TUT. It is assumed that the echo delay in the test
  7559. system is negligible.
  7560. */
  7561. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 0);
  7562. logging = v18_get_logging_state(v18[TESTER]);
  7563. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7564. span_log_set_tag(logging, "Tester");
  7565. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 1);
  7566. logging = v18_get_logging_state(v18[TUT]);
  7567. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7568. span_log_set_tag(logging, "TUT");
  7569. if ((model = both_ways_line_model_init(line_model_no,
  7570. noise_level,
  7571. echo_level_cpe1,
  7572. echo_level_co1,
  7573. line_model_no,
  7574. noise_level,
  7575. echo_level_cpe2,
  7576. echo_level_co2,
  7577. channel_codec,
  7578. rbs_pattern)) == NULL)
  7579. {
  7580. fprintf(stderr, " Failed to create line model\n");
  7581. exit(2);
  7582. }
  7583. result[TESTER][0] =
  7584. result[TUT][0] = '\0';
  7585. for (i = 0; i < 127; i++)
  7586. msg[i] = i + 1;
  7587. msg[127] = '\0';
  7588. v18_put(v18[TESTER], msg, 127);
  7589. for (i = 0; i < 10000; i++)
  7590. {
  7591. for (j = 0; j < 2; j++)
  7592. {
  7593. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7594. push = 10;
  7595. if (samples < SAMPLES_PER_CHUNK)
  7596. {
  7597. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7598. samples = SAMPLES_PER_CHUNK;
  7599. }
  7600. }
  7601. if (log_audio)
  7602. {
  7603. for (j = 0; j < samples; j++)
  7604. {
  7605. out_amp[2*j + 0] = amp[0][j];
  7606. out_amp[2*j + 1] = amp[1][j];
  7607. }
  7608. outframes = sf_writef_short(outhandle, out_amp, samples);
  7609. if (outframes != samples)
  7610. {
  7611. fprintf(stderr, " Error writing audio file\n");
  7612. exit(2);
  7613. }
  7614. }
  7615. #if 1
  7616. both_ways_line_model(model,
  7617. model_amp[0],
  7618. amp[0],
  7619. model_amp[1],
  7620. amp[1],
  7621. samples);
  7622. #else
  7623. vec_copyi16(model_amp[0], amp[0], samples);
  7624. vec_copyi16(model_amp[1], amp[1], samples);
  7625. #endif
  7626. v18_rx(v18[TESTER], model_amp[1], samples);
  7627. v18_rx(v18[TUT], model_amp[0], samples);
  7628. }
  7629. ref = "\b \n\n\n?\n\n\n !%+().+,-.0123456789:;(=)?"
  7630. "XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5"
  7631. " abcdefghijklmnopqrstuvwxyz\xE6\xF8\xE5 \b";
  7632. printf("Result:\n%s\n", result[TESTER]);
  7633. printf("Reference result:\n%s\n", ref);
  7634. v18_free(v18[TESTER]);
  7635. v18_free(v18[TUT]);
  7636. if (strcmp(result[TUT], ref) != 0)
  7637. return -1;
  7638. return 0;
  7639. }
  7640. /*- End of function --------------------------------------------------------*/
  7641. static void x_07_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7642. {
  7643. }
  7644. /*- End of function --------------------------------------------------------*/
  7645. static int test_x_07(void)
  7646. {
  7647. logging_state_t *logging;
  7648. int16_t amp[2][SAMPLES_PER_CHUNK];
  7649. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7650. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7651. int outframes;
  7652. int samples;
  7653. int push;
  7654. int i;
  7655. int j;
  7656. /*
  7657. III.5.4.5.7 EDT carrier timing and receiver disabling
  7658. Purpose: To verify that the TUT sends unmodulated carrier for 300ms before a character and
  7659. disables its receiver for 300ms after a character is transmitted.
  7660. Preamble: Establish a call between the tester and TUT in EDT mode.
  7661. Method: The operator should send a single character from the TUT. The tester will
  7662. immediately start sending a unique character sequence. Examination of the TUT
  7663. display will show when its receiver is re-enabled.
  7664. Pass criteria: 1) The TUT should send unmodulated carrier for 300ms before the beginning of
  7665. the start bit.
  7666. 2) The receiver should be re-enabled after 300ms.
  7667. 3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
  7668. Comments: The carrier should be maintained during the 300ms after a character.
  7669. */
  7670. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 0);
  7671. logging = v18_get_logging_state(v18[TESTER]);
  7672. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7673. span_log_set_tag(logging, "Tester");
  7674. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 1);
  7675. logging = v18_get_logging_state(v18[TUT]);
  7676. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7677. span_log_set_tag(logging, "TUT");
  7678. if ((model = both_ways_line_model_init(line_model_no,
  7679. noise_level,
  7680. echo_level_cpe1,
  7681. echo_level_co1,
  7682. line_model_no,
  7683. noise_level,
  7684. echo_level_cpe2,
  7685. echo_level_co2,
  7686. channel_codec,
  7687. rbs_pattern)) == NULL)
  7688. {
  7689. fprintf(stderr, " Failed to create line model\n");
  7690. exit(2);
  7691. }
  7692. result[TESTER][0] =
  7693. result[TUT][0] = '\0';
  7694. for (i = 0; i < 10000; i++)
  7695. {
  7696. for (j = 0; j < 2; j++)
  7697. {
  7698. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7699. push = 10;
  7700. if (samples < SAMPLES_PER_CHUNK)
  7701. {
  7702. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7703. samples = SAMPLES_PER_CHUNK;
  7704. }
  7705. }
  7706. if (log_audio)
  7707. {
  7708. for (j = 0; j < samples; j++)
  7709. {
  7710. out_amp[2*j + 0] = amp[0][j];
  7711. out_amp[2*j + 1] = amp[1][j];
  7712. }
  7713. outframes = sf_writef_short(outhandle, out_amp, samples);
  7714. if (outframes != samples)
  7715. {
  7716. fprintf(stderr, " Error writing audio file\n");
  7717. exit(2);
  7718. }
  7719. }
  7720. #if 1
  7721. both_ways_line_model(model,
  7722. model_amp[0],
  7723. amp[0],
  7724. model_amp[1],
  7725. amp[1],
  7726. samples);
  7727. #else
  7728. vec_copyi16(model_amp[0], amp[0], samples);
  7729. vec_copyi16(model_amp[1], amp[1], samples);
  7730. #endif
  7731. v18_rx(v18[TESTER], model_amp[1], samples);
  7732. v18_rx(v18[TUT], model_amp[0], samples);
  7733. }
  7734. v18_free(v18[TESTER]);
  7735. v18_free(v18[TUT]);
  7736. printf("Test not yet implemented\n");
  7737. return 0;
  7738. }
  7739. /*- End of function --------------------------------------------------------*/
  7740. static void x_08_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7741. {
  7742. }
  7743. /*- End of function --------------------------------------------------------*/
  7744. static int test_x_08(void)
  7745. {
  7746. logging_state_t *logging;
  7747. int16_t amp[2][SAMPLES_PER_CHUNK];
  7748. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7749. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7750. int outframes;
  7751. int samples;
  7752. int push;
  7753. int i;
  7754. int j;
  7755. /*
  7756. III.5.4.5.8 EDT bit rate and character structure
  7757. Purpose: To verify that the TUT uses the correct bit rate and character structure in the EDT
  7758. mode.
  7759. Preamble: Establish a call between the tester and TUT in EDT mode.
  7760. Method: The operator should transmit the string "abcdef" from the TUT.
  7761. Pass criteria: 1) The tester should measure the bit timings and confirm that the rate is 110 bit/s.
  7762. 2) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop
  7763. bits are used.
  7764. */
  7765. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 0);
  7766. logging = v18_get_logging_state(v18[TESTER]);
  7767. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7768. span_log_set_tag(logging, "Tester");
  7769. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 1);
  7770. logging = v18_get_logging_state(v18[TUT]);
  7771. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7772. span_log_set_tag(logging, "TUT");
  7773. if ((model = both_ways_line_model_init(line_model_no,
  7774. noise_level,
  7775. echo_level_cpe1,
  7776. echo_level_co1,
  7777. line_model_no,
  7778. noise_level,
  7779. echo_level_cpe2,
  7780. echo_level_co2,
  7781. channel_codec,
  7782. rbs_pattern)) == NULL)
  7783. {
  7784. fprintf(stderr, " Failed to create line model\n");
  7785. exit(2);
  7786. }
  7787. result[TESTER][0] =
  7788. result[TUT][0] = '\0';
  7789. for (i = 0; i < 10000; i++)
  7790. {
  7791. for (j = 0; j < 2; j++)
  7792. {
  7793. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7794. push = 10;
  7795. if (samples < SAMPLES_PER_CHUNK)
  7796. {
  7797. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7798. samples = SAMPLES_PER_CHUNK;
  7799. }
  7800. }
  7801. if (log_audio)
  7802. {
  7803. for (j = 0; j < samples; j++)
  7804. {
  7805. out_amp[2*j + 0] = amp[0][j];
  7806. out_amp[2*j + 1] = amp[1][j];
  7807. }
  7808. outframes = sf_writef_short(outhandle, out_amp, samples);
  7809. if (outframes != samples)
  7810. {
  7811. fprintf(stderr, " Error writing audio file\n");
  7812. exit(2);
  7813. }
  7814. }
  7815. #if 1
  7816. both_ways_line_model(model,
  7817. model_amp[0],
  7818. amp[0],
  7819. model_amp[1],
  7820. amp[1],
  7821. samples);
  7822. #else
  7823. vec_copyi16(model_amp[0], amp[0], samples);
  7824. vec_copyi16(model_amp[1], amp[1], samples);
  7825. #endif
  7826. v18_rx(v18[TESTER], model_amp[1], samples);
  7827. v18_rx(v18[TUT], model_amp[0], samples);
  7828. }
  7829. v18_free(v18[TESTER]);
  7830. v18_free(v18[TUT]);
  7831. printf("Test not yet implemented\n");
  7832. return 0;
  7833. }
  7834. /*- End of function --------------------------------------------------------*/
  7835. static void x_09_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7836. {
  7837. }
  7838. /*- End of function --------------------------------------------------------*/
  7839. static int test_x_09(void)
  7840. {
  7841. logging_state_t *logging;
  7842. int16_t amp[2][SAMPLES_PER_CHUNK];
  7843. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7844. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7845. int outframes;
  7846. int samples;
  7847. int push;
  7848. int i;
  7849. int j;
  7850. /*
  7851. III.5.4.5.9 V.23 calling mode character format
  7852. Purpose: To verify that the TUT uses the correct character format in the V.23 calling mode.
  7853. Preamble: Establish a call from the TUT to the tester in V.23 mode.
  7854. Method: The operator should transmit the string "abcdef" from the TUT. The tester will echo
  7855. characters back to the TUT as they are received. The tester will then transmit the
  7856. string "abcdef" with ODD parity to the TUT.
  7857. Pass criteria: 1) Confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop bits are
  7858. transmitted.
  7859. 2) The operator should confirm that there is no local echo at the TUT by checking
  7860. that there are no duplicate characters on the TUT display.
  7861. 3) The received string should be correctly displayed despite the incorrect parity.
  7862. */
  7863. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 0);
  7864. logging = v18_get_logging_state(v18[TESTER]);
  7865. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7866. span_log_set_tag(logging, "Tester");
  7867. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 1);
  7868. logging = v18_get_logging_state(v18[TUT]);
  7869. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7870. span_log_set_tag(logging, "TUT");
  7871. if ((model = both_ways_line_model_init(line_model_no,
  7872. noise_level,
  7873. echo_level_cpe1,
  7874. echo_level_co1,
  7875. line_model_no,
  7876. noise_level,
  7877. echo_level_cpe2,
  7878. echo_level_co2,
  7879. channel_codec,
  7880. rbs_pattern)) == NULL)
  7881. {
  7882. fprintf(stderr, " Failed to create line model\n");
  7883. exit(2);
  7884. }
  7885. result[TESTER][0] =
  7886. result[TUT][0] = '\0';
  7887. for (i = 0; i < 10000; i++)
  7888. {
  7889. for (j = 0; j < 2; j++)
  7890. {
  7891. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7892. push = 10;
  7893. if (samples < SAMPLES_PER_CHUNK)
  7894. {
  7895. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7896. samples = SAMPLES_PER_CHUNK;
  7897. }
  7898. }
  7899. if (log_audio)
  7900. {
  7901. for (j = 0; j < samples; j++)
  7902. {
  7903. out_amp[2*j + 0] = amp[0][j];
  7904. out_amp[2*j + 1] = amp[1][j];
  7905. }
  7906. outframes = sf_writef_short(outhandle, out_amp, samples);
  7907. if (outframes != samples)
  7908. {
  7909. fprintf(stderr, " Error writing audio file\n");
  7910. exit(2);
  7911. }
  7912. }
  7913. #if 1
  7914. both_ways_line_model(model,
  7915. model_amp[0],
  7916. amp[0],
  7917. model_amp[1],
  7918. amp[1],
  7919. samples);
  7920. #else
  7921. vec_copyi16(model_amp[0], amp[0], samples);
  7922. vec_copyi16(model_amp[1], amp[1], samples);
  7923. #endif
  7924. v18_rx(v18[TESTER], model_amp[1], samples);
  7925. v18_rx(v18[TUT], model_amp[0], samples);
  7926. }
  7927. v18_free(v18[TESTER]);
  7928. v18_free(v18[TUT]);
  7929. printf("Test not yet implemented\n");
  7930. return 0;
  7931. }
  7932. /*- End of function --------------------------------------------------------*/
  7933. static void x_10_put_text_msg(void *user_data, const uint8_t *msg, int len)
  7934. {
  7935. }
  7936. /*- End of function --------------------------------------------------------*/
  7937. static int test_x_10(void)
  7938. {
  7939. logging_state_t *logging;
  7940. int16_t amp[2][SAMPLES_PER_CHUNK];
  7941. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  7942. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  7943. int outframes;
  7944. int samples;
  7945. int push;
  7946. int i;
  7947. int j;
  7948. /*
  7949. III.5.4.5.10 V.23 answer mode character format
  7950. Purpose: To verify that the TUT uses the correct character format in the V.23 answer mode.
  7951. Preamble: Establish a call from the tester to the TUT in V.23 mode.
  7952. Method: The tester will transmit the string "abcdef" with ODD parity. The TUT should echo
  7953. characters back to the tester as they are received. The operator should then transmit
  7954. the string "abcdef" from the TUT.
  7955. Pass criteria: 1) The received string should be correctly displayed at the TUT despite the
  7956. incorrect parity.
  7957. 2) Confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop bits are
  7958. transmitted by the TUT.
  7959. 3) The tester should confirm that there is remote echo from TUT.
  7960. 4) The operator should confirm that there is local echo on the TUT.
  7961. Comments: This test is only applicable to Minitel Dialogue terminals. Prestel and Minitel
  7962. Normal terminals cannot operate in this mode.
  7963. */
  7964. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 0);
  7965. logging = v18_get_logging_state(v18[TESTER]);
  7966. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7967. span_log_set_tag(logging, "Tester");
  7968. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 1);
  7969. logging = v18_get_logging_state(v18[TUT]);
  7970. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  7971. span_log_set_tag(logging, "TUT");
  7972. if ((model = both_ways_line_model_init(line_model_no,
  7973. noise_level,
  7974. echo_level_cpe1,
  7975. echo_level_co1,
  7976. line_model_no,
  7977. noise_level,
  7978. echo_level_cpe2,
  7979. echo_level_co2,
  7980. channel_codec,
  7981. rbs_pattern)) == NULL)
  7982. {
  7983. fprintf(stderr, " Failed to create line model\n");
  7984. exit(2);
  7985. }
  7986. result[TESTER][0] =
  7987. result[TUT][0] = '\0';
  7988. for (i = 0; i < 10000; i++)
  7989. {
  7990. for (j = 0; j < 2; j++)
  7991. {
  7992. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  7993. push = 10;
  7994. if (samples < SAMPLES_PER_CHUNK)
  7995. {
  7996. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  7997. samples = SAMPLES_PER_CHUNK;
  7998. }
  7999. }
  8000. if (log_audio)
  8001. {
  8002. for (j = 0; j < samples; j++)
  8003. {
  8004. out_amp[2*j + 0] = amp[0][j];
  8005. out_amp[2*j + 1] = amp[1][j];
  8006. }
  8007. outframes = sf_writef_short(outhandle, out_amp, samples);
  8008. if (outframes != samples)
  8009. {
  8010. fprintf(stderr, " Error writing audio file\n");
  8011. exit(2);
  8012. }
  8013. }
  8014. #if 1
  8015. both_ways_line_model(model,
  8016. model_amp[0],
  8017. amp[0],
  8018. model_amp[1],
  8019. amp[1],
  8020. samples);
  8021. #else
  8022. vec_copyi16(model_amp[0], amp[0], samples);
  8023. vec_copyi16(model_amp[1], amp[1], samples);
  8024. #endif
  8025. v18_rx(v18[TESTER], model_amp[1], samples);
  8026. v18_rx(v18[TUT], model_amp[0], samples);
  8027. }
  8028. v18_free(v18[TESTER]);
  8029. v18_free(v18[TUT]);
  8030. printf("Test not yet implemented\n");
  8031. return 0;
  8032. }
  8033. /*- End of function --------------------------------------------------------*/
  8034. static void x_11_put_text_msg(void *user_data, const uint8_t *msg, int len)
  8035. {
  8036. }
  8037. /*- End of function --------------------------------------------------------*/
  8038. static int test_x_11(void)
  8039. {
  8040. logging_state_t *logging;
  8041. int16_t amp[2][SAMPLES_PER_CHUNK];
  8042. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  8043. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  8044. int outframes;
  8045. int samples;
  8046. int push;
  8047. int i;
  8048. int j;
  8049. /*
  8050. III.5.4.5.11 V.21 character structure
  8051. Purpose: To verify that the TUT uses the character structure in the V.21 mode.
  8052. Preamble: Establish a call from the TUT to the tester in V.21 mode.
  8053. Method: The operator should transmit a string from the TUT that is long enough to cause the
  8054. display to word wrap followed by "abcdef", new line (CR+LF). The tester will then
  8055. transmit the string "123456", BACKSPACE (0/8) with ODD parity to the TUT.
  8056. Pass criteria: 1) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 1 stop
  8057. bits are transmitted.
  8058. 2) The word wrap should not result in CR+LF.
  8059. 3) The forced new line should be indicated by CR+LF.
  8060. 4) The last five characters on the TUT display should be "12345" (no "6")
  8061. correctly displayed despite the incorrect parity.
  8062. */
  8063. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 0);
  8064. logging = v18_get_logging_state(v18[TESTER]);
  8065. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  8066. span_log_set_tag(logging, "Tester");
  8067. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 1);
  8068. logging = v18_get_logging_state(v18[TUT]);
  8069. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  8070. span_log_set_tag(logging, "TUT");
  8071. if ((model = both_ways_line_model_init(line_model_no,
  8072. noise_level,
  8073. echo_level_cpe1,
  8074. echo_level_co1,
  8075. line_model_no,
  8076. noise_level,
  8077. echo_level_cpe2,
  8078. echo_level_co2,
  8079. channel_codec,
  8080. rbs_pattern)) == NULL)
  8081. {
  8082. fprintf(stderr, " Failed to create line model\n");
  8083. exit(2);
  8084. }
  8085. result[TESTER][0] =
  8086. result[TUT][0] = '\0';
  8087. for (i = 0; i < 10000; i++)
  8088. {
  8089. for (j = 0; j < 2; j++)
  8090. {
  8091. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  8092. push = 10;
  8093. if (samples < SAMPLES_PER_CHUNK)
  8094. {
  8095. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  8096. samples = SAMPLES_PER_CHUNK;
  8097. }
  8098. }
  8099. if (log_audio)
  8100. {
  8101. for (j = 0; j < samples; j++)
  8102. {
  8103. out_amp[2*j + 0] = amp[0][j];
  8104. out_amp[2*j + 1] = amp[1][j];
  8105. }
  8106. outframes = sf_writef_short(outhandle, out_amp, samples);
  8107. if (outframes != samples)
  8108. {
  8109. fprintf(stderr, " Error writing audio file\n");
  8110. exit(2);
  8111. }
  8112. }
  8113. #if 1
  8114. both_ways_line_model(model,
  8115. model_amp[0],
  8116. amp[0],
  8117. model_amp[1],
  8118. amp[1],
  8119. samples);
  8120. #else
  8121. vec_copyi16(model_amp[0], amp[0], samples);
  8122. vec_copyi16(model_amp[1], amp[1], samples);
  8123. #endif
  8124. v18_rx(v18[TESTER], model_amp[1], samples);
  8125. v18_rx(v18[TUT], model_amp[0], samples);
  8126. }
  8127. v18_free(v18[TESTER]);
  8128. v18_free(v18[TUT]);
  8129. printf("Test not yet implemented\n");
  8130. return 0;
  8131. }
  8132. /*- End of function --------------------------------------------------------*/
  8133. static void x_12_put_text_msg(void *user_data, const uint8_t *msg, int len)
  8134. {
  8135. }
  8136. /*- End of function --------------------------------------------------------*/
  8137. static int test_x_12(void)
  8138. {
  8139. logging_state_t *logging;
  8140. int16_t amp[2][SAMPLES_PER_CHUNK];
  8141. int16_t model_amp[2][SAMPLES_PER_CHUNK];
  8142. int16_t out_amp[2*SAMPLES_PER_CHUNK];
  8143. int outframes;
  8144. int samples;
  8145. int push;
  8146. int i;
  8147. int j;
  8148. /*
  8149. III.5.4.5.12 V.18 mode
  8150. Purpose: To verify that the TUT uses the protocol defined in ITU-T T.140.
  8151. Preamble: Establish a call from the TUT to the tester in V.18 mode.
  8152. Method: The operator should transmit a string from the TUT that is long enough to cause the
  8153. display to word wrap followed by "abcdef", new line (CR+LF), new line
  8154. (UNICODE preferred). The tester will then transmit the string "123456",
  8155. BACKSPACE.
  8156. Pass criteria: The tester should confirm UTF8 encoded UNICODE characters are used with the
  8157. controls specified in ITU-T T.140.
  8158. */
  8159. v18[TESTER] = v18_init(NULL, true, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 0);
  8160. logging = v18_get_logging_state(v18[TESTER]);
  8161. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  8162. span_log_set_tag(logging, "Tester");
  8163. v18[TUT] = v18_init(NULL, false, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 1);
  8164. logging = v18_get_logging_state(v18[TUT]);
  8165. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  8166. span_log_set_tag(logging, "TUT");
  8167. if ((model = both_ways_line_model_init(line_model_no,
  8168. noise_level,
  8169. echo_level_cpe1,
  8170. echo_level_co1,
  8171. line_model_no,
  8172. noise_level,
  8173. echo_level_cpe2,
  8174. echo_level_co2,
  8175. channel_codec,
  8176. rbs_pattern)) == NULL)
  8177. {
  8178. fprintf(stderr, " Failed to create line model\n");
  8179. exit(2);
  8180. }
  8181. result[TESTER][0] =
  8182. result[TUT][0] = '\0';
  8183. for (i = 0; i < 10000; i++)
  8184. {
  8185. for (j = 0; j < 2; j++)
  8186. {
  8187. if ((samples = v18_tx(v18[j], amp[j], SAMPLES_PER_CHUNK)) == 0)
  8188. push = 10;
  8189. if (samples < SAMPLES_PER_CHUNK)
  8190. {
  8191. vec_zeroi16(&amp[j][samples], SAMPLES_PER_CHUNK - samples);
  8192. samples = SAMPLES_PER_CHUNK;
  8193. }
  8194. }
  8195. if (log_audio)
  8196. {
  8197. for (j = 0; j < samples; j++)
  8198. {
  8199. out_amp[2*j + 0] = amp[0][j];
  8200. out_amp[2*j + 1] = amp[1][j];
  8201. }
  8202. outframes = sf_writef_short(outhandle, out_amp, samples);
  8203. if (outframes != samples)
  8204. {
  8205. fprintf(stderr, " Error writing audio file\n");
  8206. exit(2);
  8207. }
  8208. }
  8209. #if 1
  8210. both_ways_line_model(model,
  8211. model_amp[0],
  8212. amp[0],
  8213. model_amp[1],
  8214. amp[1],
  8215. samples);
  8216. #else
  8217. vec_copyi16(model_amp[0], amp[0], samples);
  8218. vec_copyi16(model_amp[1], amp[1], samples);
  8219. #endif
  8220. v18_rx(v18[TESTER], model_amp[1], samples);
  8221. v18_rx(v18[TUT], model_amp[0], samples);
  8222. }
  8223. v18_free(v18[TESTER]);
  8224. v18_free(v18[TUT]);
  8225. printf("Test not yet implemented\n");
  8226. return 0;
  8227. }
  8228. /*- End of function --------------------------------------------------------*/
  8229. static void put_v18_msg(void *user_data, const uint8_t *msg, int len)
  8230. {
  8231. char buf[1024];
  8232. memcpy(buf, msg, len);
  8233. buf[len] = '\0';
  8234. printf("Received (%d bytes) '%s'\n", len, buf);
  8235. }
  8236. /*- End of function --------------------------------------------------------*/
  8237. static int decode_test_data_file(int mode, const char *filename)
  8238. {
  8239. int16_t amp[SAMPLES_PER_CHUNK];
  8240. SNDFILE *inhandle;
  8241. int len;
  8242. v18_state_t *v18_state;
  8243. logging_state_t *logging;
  8244. printf("Decoding as '%s'\n", v18_mode_to_str(mode));
  8245. /* We will decode the audio from a file. */
  8246. if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
  8247. {
  8248. fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
  8249. exit(2);
  8250. }
  8251. v18_state = v18_init(NULL, false, mode, V18_AUTOMODING_GLOBAL, put_v18_msg, NULL);
  8252. logging = v18_get_logging_state(v18_state);
  8253. span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
  8254. span_log_set_tag(logging, "");
  8255. for (;;)
  8256. {
  8257. if ((len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) <= 0)
  8258. break;
  8259. v18_rx(v18_state, amp, len);
  8260. }
  8261. if (sf_close_telephony(inhandle))
  8262. {
  8263. fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
  8264. exit(2);
  8265. }
  8266. v18_free(v18_state);
  8267. return 0;
  8268. }
  8269. /*- End of function --------------------------------------------------------*/
  8270. const struct
  8271. {
  8272. const char *title;
  8273. int (*func)(void);
  8274. } test_list[] =
  8275. {
  8276. {"III.3.2.1 Operational requirements tests", NULL},
  8277. {"MISC-01 4 (1) No disconnection test", test_misc_01},
  8278. {"MISC-02 4 (2) Automatic resumption of automoding", test_misc_02},
  8279. {"MISC-03 4 (2) Retention of selected mode on loss of signal", test_misc_03},
  8280. {"MISC-04 4 (4) Detection of BUSY tone", test_misc_04},
  8281. {"MISC-05 4 (4) Detection of RINGING", test_misc_05},
  8282. {"MISC-06 4 (4) LOSS OF CARRIER indication", test_misc_06},
  8283. {"MISC-07 4 (4) Call progress indication", test_misc_07},
  8284. {"MISC-08 4 (5) Circuit 135 test", test_misc_08},
  8285. {"MISC-09 4 (6) Connection procedures", test_misc_09},
  8286. {"III.3.2.2 Automode originate tests", NULL},
  8287. {"ORG-01 5.1.1 CI & XCI signal coding and cadence", test_org_01},
  8288. {"ORG-02 5.1.3 ANS signal detection", test_org_02},
  8289. {"ORG-03 5.2.3.1 End of ANS signal detection", test_org_03},
  8290. {"ORG-04 5.1.3.2 ANS tone followed by TXP", test_org_04},
  8291. {"ORG-05 5.1.3.3 ANS tone followed by 1650Hz", test_org_05},
  8292. {"ORG-06 5.1.3.4 ANS tone followed by 1300Hz", test_org_06},
  8293. {"ORG-07 5.1.3 ANS tone followed by no tone", test_org_07},
  8294. {"ORG-08 5.1.4 Bell 103 (2225Hz signal) detection", test_org_08},
  8295. {"ORG-09 5.1.5 V.21 (1650Hz signal) detection", test_org_09},
  8296. {"ORG-10 5.1.6 V.23 (1300Hz signal) detection", test_org_10},
  8297. {"ORG-11 5.1.7 V.23 (390Hz signal) detection", test_org_11},
  8298. {"ORG-12a to d 5.1.8 5 Bit Mode (baudot) detection Tests", test_org_12},
  8299. {"ORG-13 5.1.9 DTMF signal detection", test_org_13},
  8300. {"ORG-14 5.1.10 EDT rate detection", test_org_14},
  8301. {"ORG-15 5.1.10.1 Rate detection test", test_org_15},
  8302. {"ORG-16 5.1.10.2 980Hz detection", test_org_16},
  8303. {"ORG-17 5.1.10.3 Loss of signal after 980Hz", test_org_17},
  8304. {"ORG-18 5.1.10.3 Tr Timer", test_org_18},
  8305. {"ORG-19 5.1.11 Bell 103 (1270Hz signal) detection", test_org_19},
  8306. {"ORG-20 Immunity to network tones", test_org_20},
  8307. {"ORG-21a to b Immunity to other non-textphone modems", test_org_21},
  8308. {"ORG-22 Immunity to Fax tones", test_org_22},
  8309. {"ORG-23 Immunity to voice", test_org_23},
  8310. {"ORG-24 5.1.2 ANSam detection", test_org_24},
  8311. {"ORG-25 6.1 V.8 originate call", test_org_25},
  8312. {"III.3.2.3 Automode answer tests", NULL},
  8313. {"ANS-01 5.2.1 Ta timer", test_ans_01},
  8314. {"ANS-02 5.2.2 CI signal detection", test_ans_02},
  8315. {"ANS-03 5.2.2.1 Early termination of ANS tone", test_ans_03},
  8316. {"ANS-04 5.2.2.2 Tt Timer", test_ans_04},
  8317. {"ANS-05 5.2.3.2 ANS tone followed by 980Hz", test_ans_05},
  8318. {"ANS-06 5.2.3.2 ANS tone followed by 1300Hz", test_ans_06},
  8319. {"ANS-07 5.2.3.3 ANS tone followed by 1650Hz", test_ans_07},
  8320. {"ANS-08 5.2.4.1 980Hz followed by 1650Hz", test_ans_08},
  8321. {"ANS-09a to d 5.2.4.2 980Hz calling tone detection", test_ans_09},
  8322. {"ANS-10 5.2.4.3 V.21 detection by timer", test_ans_10},
  8323. {"ANS-11 5.2.4.4.1 EDT detection by rate", test_ans_11},
  8324. {"ANS-12 5.2.4.4.2 V.21 detection by rate", test_ans_12},
  8325. {"ANS-13 5.2.4.4.3 Tr Timer", test_ans_13},
  8326. {"ANS-14 5.2.4.5 Te Timer", test_ans_14},
  8327. {"ANS-15a to d 5.2.5 5 bit mode (Baudot) detection tests", test_ans_15},
  8328. {"ANS-16 5.2.6 DTMF signal detection", test_ans_16},
  8329. {"ANS-17 5.2.7 Bell 103 (1270Hz signal) detection", test_ans_17},
  8330. {"ANS-18 5.2.8 Bell 103 (2225Hz signal) detection", test_ans_18},
  8331. {"ANS-19 5.2.9 V.21 reverse mode (1650Hz) detection", test_ans_19},
  8332. {"ANS-20a to d 5.2.10 1300Hz calling tone discrimination", test_ans_20},
  8333. {"ANS-21 5.2.11 V.23 reverse mode (1300Hz) detection", test_ans_21},
  8334. {"ANS-22 1300Hz with XCI Test", test_ans_22},
  8335. {"ANS-23 5.2.12 Stimulate mode country settings", test_ans_23},
  8336. {"ANS-24 5.2.12.1 Stimulate carrierless mode probe message", test_ans_24},
  8337. {"ANS-25 5.2.12.1.1 Interrupted carrierless mode probe", test_ans_25},
  8338. {"ANS-26 5.2.12.2 Stimulate carrier mode probe time", test_ans_26},
  8339. {"ANS-27 5.2.12.2.1 V.23 mode (390Hz) detection", test_ans_27},
  8340. {"ANS-28 5.2.12.2.2 Interrupted carrier mode probe", test_ans_28},
  8341. {"ANS-29 5.2.12.2.2 Stimulate mode response during probe", test_ans_29},
  8342. {"ANS-30 Immunity to network tones", test_ans_30},
  8343. {"ANS-31 Immunity to Fax calling tones", test_ans_31},
  8344. {"ANS-32 Immunity to voice", test_ans_32},
  8345. {"ANS-33 5.2.2.1 V.8 CM detection and V.8 answering", test_ans_33},
  8346. {"III.3.2.4 Automode monitor tests", NULL},
  8347. {"MON-01 to -20 5.3 Repeat all answer mode tests excluding tests ANS-01, ANS-20 and ANS-23 to ANS-29", test_mon_01},
  8348. {"MON-21 5.3 Automode monitor Ta timer", test_mon_21},
  8349. {"MON-22a to d 5.3 Automode monitor 1300Hz calling tone discrimination", test_mon_22},
  8350. {"MON-23a to d 5.3 Automode monitor 980Hz calling tone discrimination", test_mon_23},
  8351. {"III.3.2.5 ITU-T V.18 annexes tests", NULL},
  8352. {"X-01 A.1 Baudot carrier timing and receiver disabling", test_x_01},
  8353. {"X-02 A.2 Baudot bit rate confirmation", test_x_02},
  8354. {"X-03 A.3 Baudot probe bit rate confirmation", test_x_03},
  8355. {"X-04 A.4 5 Bit to T.50 character conversion", test_x_04},
  8356. {"X-05 B.1 DTMF receiver disabling", test_x_05},
  8357. {"X-06 B.2 DTMF character conversion", test_x_06},
  8358. {"X-07 C.1 EDT carrier timing and receiver disabling", test_x_07},
  8359. {"X-08 C.2-3 EDT bit rate and character structure", test_x_08},
  8360. {"X-09 E V.23 calling mode character format", test_x_09},
  8361. {"X-10 E V.23 answer mode character format", test_x_10},
  8362. {"X-11 F.4-5 V.21 character structure", test_x_11},
  8363. {"X-12 G.1-3 V.18 mode", test_x_12},
  8364. {"", NULL}
  8365. };
  8366. int main(int argc, char *argv[])
  8367. {
  8368. int i;
  8369. int res;
  8370. bool hit;
  8371. const char *match;
  8372. int test_standard;
  8373. int opt;
  8374. match = NULL;
  8375. test_standard = -1;
  8376. while ((opt = getopt(argc, argv, "d:ls:")) != -1)
  8377. {
  8378. switch (opt)
  8379. {
  8380. case 'd':
  8381. decode_test_file = optarg;
  8382. break;
  8383. case 'l':
  8384. log_audio = true;
  8385. break;
  8386. case 's':
  8387. test_standard = atoi(optarg);
  8388. break;
  8389. default:
  8390. //usage();
  8391. exit(2);
  8392. break;
  8393. }
  8394. }
  8395. argc -= optind;
  8396. argv += optind;
  8397. if (decode_test_file)
  8398. {
  8399. decode_test_data_file(test_standard, decode_test_file);
  8400. exit(0);
  8401. }
  8402. if (argc > 0)
  8403. match = argv[0];
  8404. outhandle = NULL;
  8405. if (log_audio)
  8406. {
  8407. if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
  8408. {
  8409. fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
  8410. exit(2);
  8411. }
  8412. }
  8413. hit = false;
  8414. for (i = 0; test_list[i].title[0]; i++)
  8415. {
  8416. if (test_list[i].func
  8417. &&
  8418. (match == NULL
  8419. ||
  8420. (strncmp(match, test_list[i].title, strlen(match)) == 0
  8421. &&
  8422. test_list[i].title[strlen(match)] == ' ')))
  8423. {
  8424. hit = true;
  8425. printf("%s\n", test_list[i].title);
  8426. res = test_list[i].func();
  8427. if (res < 0)
  8428. {
  8429. printf(" Test failed\n");
  8430. exit(2);
  8431. }
  8432. if (res == 0)
  8433. {
  8434. printf(" Test passed\n");
  8435. }
  8436. }
  8437. else
  8438. {
  8439. if (match == NULL)
  8440. printf("%s\n", test_list[i].title);
  8441. }
  8442. }
  8443. if (!hit)
  8444. {
  8445. printf("Test not found\n");
  8446. exit(2);
  8447. }
  8448. basic_tests(V18_MODE_5BIT_4545);
  8449. basic_tests(V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION);
  8450. if (log_audio)
  8451. {
  8452. if (sf_close_telephony(outhandle))
  8453. {
  8454. fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
  8455. exit(2);
  8456. }
  8457. }
  8458. printf("Tests passed\n");
  8459. return 0;
  8460. return 0;
  8461. }
  8462. /*- End of function --------------------------------------------------------*/
  8463. /*- End of file ------------------------------------------------------------*/