From a9a94282f867d965f771960a2ab8df57a14f2392 Mon Sep 17 00:00:00 2001 From: Arthur 'Grizzly' Grisel-Davy Date: Thu, 18 Feb 2021 01:16:05 +0100 Subject: [PATCH] recuperation des sample par l'application de test --- adxl345.c | 58 ++++++++++++++++++++++++++++++++++++++++----------- test_adxl345 | Bin 0 -> 12540 bytes 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100755 test_adxl345 diff --git a/adxl345.c b/adxl345.c index f1f8317..1615d24 100644 --- a/adxl345.c +++ b/adxl345.c @@ -81,29 +81,63 @@ static struct Sample fifo_pop(struct Fifo *f) { // Fonctions ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ssize_t adxl345_read(struct file *file, char __user *buf, size_t count, loff_t *f_pos){ + + char nsample; + char rest; + unsigned char res[count]; + int i=0; + int16_t direction_sample; + struct Sample sample; + // TODO: permetre de choisir l'axe de lecture - pr_info("In adxl345_read function\n"); + //pr_info("In adxl345_read function\n"); // Recuperation de la structure adxl345 struct adxl345_device *d = container_of(file->private_data,struct adxl345_device,miscdev); - pr_info("Got pointer to adxl345_device structure\n"); + //pr_info("Got pointer to adxl345_device structure\n"); - int nsample = fifo_len(&(d->fifo)); - pr_info("Got %i sample in the FIFO\n",nsample); - - struct Sample sample; - int i; - for(i=count; i<0; i--){ - sample = fifo_pop(&(d->fifo)); - pr_info("Sample %i: (%i,%i,%i)\n",i,sample.x,sample.y,sample.z); + // Compute the number of complete samples (6 bytes) to get + nsample = count/6; + rest = count%6; + // Adjust what to get depending on the number of sample in the fifo + if(fifo_len(&(d->fifo))<=nsample){ + nsample = fifo_len(&(d->fifo)); + rest = 0; } + //pr_info("%i sample in fifo\nGetting %i full sample ans %i more bytes\n",fifo_len(&(d->fifo)),nsample,rest); + // Get the full samples + for(i=0;ififo)); + res[i*6+1] = (unsigned char) (sample.x>>8); + res[i*6+0] = (unsigned char) (sample.x & 0x00ff); + res[i*6+3] = (unsigned char) (sample.y>>8); + res[i*6+2] = (unsigned char) (sample.y & 0x00ff); + res[i*6+5] = (unsigned char) (sample.z>>8); + res[i*6+4] = (unsigned char) (sample.z & 0x00ff); + //pr_info("%i %i %i\n",sample.x,sample.y,sample.z); + //pr_info("%x %x %x %x\n",res[i], res[i+1], res[i+2],res[i+3]); + } + // Get the rest + sample = fifo_pop(&(d->fifo)); + for(i=nsample*6;iSZD!oG#+`QR{-maMnUKaUw&E5N+^XMq z@4KrfAvcp|GRaIi(s}osd%kz>z31J1@1FbK<6E{58-^h?1;i>r?YB)s^q}my1Bajp z^$1JMfo+9YPJ5xLMu?^wLvkG;(*ycc$V`){L;%=6i|XeK=p%_PE^bgptJ>=d)9WTcdjtbs{l=!3YeJMUwaU_97o z5`DCRSx5Ufx;}o(z=nI)oc+7#KVNwL)Jrd4`-9tQW4v`dYa#oIzK9{Q9TgX;Ru2oS zk`OJBZ<(Rj&(K%S(AWEP3-WC~o&GpRP1FTq5@!_Fi9)4Z63$4zSQdq1I#*7LqU$6? zzToDBZ4+mg%1*ItXPq=_Mzi^xS7VE<+qVr4+1(M&&4Bl(B#zaa8(zb0>GV9>?)LOm zO#!h0L2E#{5P@l8iD0#{M8Miv;sPvX37o|e!CTG}L9Xi$fA@AFzE^kb+~wfK@TK6z z)0Y}AK6$b3?UydS*Z_xr_T(E)FaOFLFTVHHOIm);CqL_xpZ3X5`Q%eR`6T3BZ;N_x zW8kYF9}b=|&b)rD>HLms!M`x?4&F0)^|dRLS1(_AC}apHXozJf+qzC)YO_vXGP|C< z7_ffzJD9C+-Z~jI-khBLR||byg;)$s^pMT-69EA>PYi}G^iK%r!ZiP|eQRN>_?m|? zJd81C@e@tP_g;NuThoo$rY`{<1TxrpXvrT>UVUZK=VsFV zC9Y@09kqYoKk<}@+JD99j9mO-W<1+Jao(#NymI8olEC8UHyl~=eCyDX=f867y41ho z>DP}PIV$Z(m3_l6zVL%!SI6)RKd9+ijALC_|HONquchck`|$qWbHm5Z2@(G8wV~SK z`kg0-KQlac$77o(ufF&1k8U1Y^5v#E7s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