Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LidarSpi USBDevice mbed
tests.cpp
00001 00002 #include "tests.h" 00003 int traceTest(LidarSpi* lidar, Serial * pc, USBSerial * serial) 00004 { 00005 int res=0; 00006 uint16_t buf[9473]; 00007 uint32_t nBytes; 00008 res=lidar->setTrace(); 00009 pc->printf("Set trace result: %d\n\r"); 00010 memset(buf, 0, sizeof(buf[0])*9472); 00011 //for(int i=0;i<64;i++) res=lidar.GetTraceOne( buf, 9472*2, 0, 0, i, &pc); 00012 //res=lidar.GetTraceOne( buf, 9472*2, 0, 0, 0, &pc); 00013 res=lidar->GetTrace( buf, 9472*2, 0, 0, pc); 00014 pc->printf("============\n\r============\n\r==================\n\r"); 00015 pc->printf("Result: %d \tTrace values after Patch:\n\r", res); 00016 00017 //"%d \n", ((buf[i] & 0x00ff) << 8) | ((buf[i] & 0xff00) >> 8) 00018 //for (int i =0; i<(74*8*16);i++) pc->printf("%d ",((buf[i] & 0x00ff) << 8) | ((buf[i] & 0xff00) >> 8)); 00019 /* 00020 for(int i =0;i<16;i++) serial->printf("CH%d;",i); 00021 serial->printf("\n"); 00022 for (int i =0; i<(592);i++) { 00023 for(int j=0;j<16;j++) serial->printf("%d;",((buf[i+(j*74*8)] & 0x00ff) << 8) | ((buf[i+(j*74*8)] & 0xff00) >> 8)); 00024 serial->printf("\n"); 00025 } 00026 00027 serial->printf("\n");*/ 00028 00029 if(res<0) { 00030 serial->putc(1); 00031 for(int i=0;i<4;i++) serial->putc(0); 00032 return 0; 00033 } 00034 else nBytes=res*2; 00035 00036 uint8_t * pntrS=(uint8_t *) &nBytes; 00037 pc->printf("size: %d\n\r", *pntrS); 00038 serial->putc(0); 00039 for(int i=0;i<sizeof(nBytes);i++) serial->putc(*(pntrS+i)); 00040 uint8_t * pnt; 00041 pnt=(uint8_t *)buf; 00042 pc->printf("Shows some values of trace, nBytes: %d\n\r", nBytes*2); 00043 00044 for(int i=0;i<(nBytes);i=i+100) pc->printf("Value= %d\n\r", pnt[i]); 00045 pc->printf("Transmit trace\n\r"); 00046 for(int i=0;i<(nBytes);i++) { 00047 serial->putc(pnt[i]); 00048 if(i<50)pc->printf("Char [%d] -> %x \n\r", i, pnt[i]); 00049 if(((i % 2)==0)&&i<50 )pc->printf("Transmit [%d] -> %x \n\r",i, ((pnt[i])<<8)|(pnt[i+1])); 00050 } 00051 pc->printf("Trace transmitted\n\r"); 00052 //delete buf; 00053 wait_us(4); 00054 return res; 00055 }
Generated on Sun Jul 24 2022 09:26:17 by
1.7.2