API to interface sensor with host PC
Dependencies: LidarSpi USBDevice mbed
Diff: tests.cpp
- Revision:
- 0:10bd8964965a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests.cpp Tue Apr 05 08:16:30 2016 +0000 @@ -0,0 +1,55 @@ + +#include "tests.h" +int traceTest(LidarSpi* lidar, Serial * pc, USBSerial * serial) +{ + int res=0; + uint16_t buf[9473]; + uint32_t nBytes; + res=lidar->setTrace(); + pc->printf("Set trace result: %d\n\r"); + memset(buf, 0, sizeof(buf[0])*9472); + //for(int i=0;i<64;i++) res=lidar.GetTraceOne( buf, 9472*2, 0, 0, i, &pc); + //res=lidar.GetTraceOne( buf, 9472*2, 0, 0, 0, &pc); + res=lidar->GetTrace( buf, 9472*2, 0, 0, pc); + pc->printf("============\n\r============\n\r==================\n\r"); + pc->printf("Result: %d \tTrace values after Patch:\n\r", res); + + //"%d \n", ((buf[i] & 0x00ff) << 8) | ((buf[i] & 0xff00) >> 8) + //for (int i =0; i<(74*8*16);i++) pc->printf("%d ",((buf[i] & 0x00ff) << 8) | ((buf[i] & 0xff00) >> 8)); + /* + for(int i =0;i<16;i++) serial->printf("CH%d;",i); + serial->printf("\n"); + for (int i =0; i<(592);i++) { + for(int j=0;j<16;j++) serial->printf("%d;",((buf[i+(j*74*8)] & 0x00ff) << 8) | ((buf[i+(j*74*8)] & 0xff00) >> 8)); + serial->printf("\n"); + } + + serial->printf("\n");*/ + + if(res<0) { + serial->putc(1); + for(int i=0;i<4;i++) serial->putc(0); + return 0; + } + else nBytes=res*2; + + uint8_t * pntrS=(uint8_t *) &nBytes; + pc->printf("size: %d\n\r", *pntrS); + serial->putc(0); + for(int i=0;i<sizeof(nBytes);i++) serial->putc(*(pntrS+i)); + uint8_t * pnt; + pnt=(uint8_t *)buf; + pc->printf("Shows some values of trace, nBytes: %d\n\r", nBytes*2); + + for(int i=0;i<(nBytes);i=i+100) pc->printf("Value= %d\n\r", pnt[i]); + pc->printf("Transmit trace\n\r"); + for(int i=0;i<(nBytes);i++) { + serial->putc(pnt[i]); + if(i<50)pc->printf("Char [%d] -> %x \n\r", i, pnt[i]); + if(((i % 2)==0)&&i<50 )pc->printf("Transmit [%d] -> %x \n\r",i, ((pnt[i])<<8)|(pnt[i+1])); + } + pc->printf("Trace transmitted\n\r"); + //delete buf; + wait_us(4); + return res; +} \ No newline at end of file