LUIS

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pirottealex
Date:
Fri Oct 05 14:54:54 2018 +0000
Commit message:
a

Changed in this revision

fct.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 96bdb0d08de1 fct.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fct.h	Fri Oct 05 14:54:54 2018 +0000
@@ -0,0 +1,102 @@
+
+#define PERIOD 0.00005
+#define GET_INFO 0x50
+#define GET_HEALTH 0x52
+#define RESET 0x40 
+#define SYNC 0xA5
+#define SCAN 0x20
+#define STOP 0x25
+#define BOFF 7
+
+Serial Lidar (PC_10,PC_11); 
+Serial pc(USBTX,USBRX);
+
+PwmOut LIDAR(A3);
+
+char msg[50] = {0};
+int i=0;
+int flag=0;
+
+
+
+void get_health(void)
+{
+    Lidar.putc(SYNC);
+    Lidar.putc(GET_HEALTH);
+    wait(0.1);
+    int statut=msg[BOFF];
+    if( statut==0)
+    {
+        pc.printf("Statut = 0 : GOOD");
+    }
+    else if( statut==1)
+    {
+        pc.printf("Statut = 1 : WARNING");
+    }    
+    else if( statut==2)
+    {
+        pc.printf("Statut = 2 : ERROR");
+    } 
+    pc.printf("\n\r");
+    for(int j=0; j<=50;j++)
+    {
+        msg[i]=0;
+    }
+    i=0; 
+}   
+
+
+void get_info(void)
+{
+    Lidar.putc(SYNC);
+    Lidar.putc(GET_INFO);
+    wait(0.1);
+    pc.printf("LIDAR MODEL : %d, LIDAR FIRMWARE : %d.%d, NUMERO DE SERIE : ",msg[BOFF],msg[BOFF+2],msg[BOFF+1]);
+    for(int j=BOFF+3; j<=16+BOFF+3;j++)
+    {
+        pc.printf("%x",msg[j]);
+    }
+    pc.printf("\n\r");
+    for(int j=0; j<=50;j++)
+    {
+        msg[i]=0;
+    }
+    i=0;    
+}
+
+void reception (void)
+{
+    msg[i] =Lidar.getc();
+    /*if((flag==0)&&(i==6))
+    {
+        pc.printf("%d ,%d ,%d,%d ,%d, %d ,%d\n\r",msg[0],msg[1],msg[2],msg[3],msg[4], msg[5], msg[6]);
+        flag=1;
+        i=-1;
+        for(int j=0; j<=50;j++)
+        {
+            msg[i]=0;
+        }  
+    }
+    //pc.printf("%d",c);
+    
+    if((i==4) && (flag==1))
+    {
+        if(msg[1] & 0xb1)
+        int qualite= msg[0]>>2;
+        if(qualite>=2)
+        {
+            int angle=((msg[1] >> 1) + (msg[2] << 7)) / 64.0;
+            int dist=((msg[3]) + ((msg[4]) << 8)) / 4.0;
+            pc.printf("%d ,%d ,%d\n\r",qualite,angle,dist); 
+        }
+        //pc.printf("%d",i);
+        i=-1;
+        for(int j=0; j<=50;j++)
+        {
+            msg[i]=0;
+        }        
+    }*/
+    
+    i++;
+
+}
\ No newline at end of file
diff -r 000000000000 -r 96bdb0d08de1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 05 14:54:54 2018 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "fct.h"
+
+
+int main() {
+    
+    LIDAR.period(PERIOD);
+    LIDAR.pulsewidth(PERIOD*0.2);
+    pc.baud(230400);
+    Lidar.baud(115200);
+    Lidar.attach(&reception);
+    //pc.printf("NAW SCAN\n\r");
+    wait(2);   
+    get_info();
+    //get_health();
+    /*Lidar.putc(SYNC);
+    Lidar.putc(SCAN);
+    
+    wait(5);
+    Lidar.putc(SYNC);
+    Lidar.putc(STOP);  */  
+    while(1)
+    {
+
+
+
+    }
+}
+
+
+
+
diff -r 000000000000 -r 96bdb0d08de1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 05 14:54:54 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file