Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GSen1
New Contributor I
902 Views

Getting error while using HC-SR04 Ultrasonic Sensor on Eclipse IDE

Jump to solution

Hello,

I am trying to getting the distance by using HC-SR04 Ultrasonic sensor with my intel galileo gen 1. I'm coding on Eclipse IDE. I found a sample code from here: https://github.com/intel-iot-devkit/upm/blob/master/examples/c%2B%2B/hcsr04.cxx upm/hcsr04.cxx at master · intel-iot-devkit/upm · GitHub I added the header by using IoT Sensor Support on Eclipse. Now I found another cpp file from here: https://github.com/intel-iot-devkit/upm/blob/master/src/hcsr04/hcsr04.cxx upm/hcsr04.cxx at master · intel-iot-devkit/upm · GitHub This cpp file has codes for constructor and functions. How can I add this second cpp file to my project? Will there be two cpp files in my project's src file? I copied and pasted this second cpp file on my project and it gives errors like that:

Multiple markers at this line

- Member 'm_RisingTimeStamp' was not initialized in this

constructor

- Member 'm_InterruptCounter' was not initialized in this

constructor

- Member 'm_FallingTimeStamp' was not initialized in this

constructor

- Member 'm_doWork' was not initialized in this constructor

And also it says "unused variable 'error' [-Wunused-variable]" for this line: mraa_result_t error = MRAA_SUCCESS;

Since it's a sample code, I wasn't expecting any errors. How can I solve this problem?

Thanks.


Accepted Solutions
idata
Community Manager
31 Views

Hi davulist,

 

 

The example you need to use is the one on: https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B

 

This: https://github.com/intel-iot-devkit/upm/blob/master/src/hcsr04/hcsr04.cxx https://github.com/intel-iot-devkit/upm/blob/master/src/hcsr04/hcsr04.cxx is the source used to generate the headers for this sensor, you don't need to use this file unless you are building the library from scratch, but you are using the headers that are in the Eclipse IDE so it is not required.

 

 

Once you have the example on Eclipse, you need to add –lupm-hcsr04 in the linkers for Cross G++ Linker > Miscellaneous. Try with this and let us know if you still have problems, if you do please a screenshot of the errors you get under the problems tab.

 

 

Regards,

 

Charlie

View solution in original post

1 Reply
idata
Community Manager
32 Views

Hi davulist,

 

 

The example you need to use is the one on: https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B https://github.com/intel-iot-devkit/upm/tree/master/examples/c%2B%2B

 

This: https://github.com/intel-iot-devkit/upm/blob/master/src/hcsr04/hcsr04.cxx https://github.com/intel-iot-devkit/upm/blob/master/src/hcsr04/hcsr04.cxx is the source used to generate the headers for this sensor, you don't need to use this file unless you are building the library from scratch, but you are using the headers that are in the Eclipse IDE so it is not required.

 

 

Once you have the example on Eclipse, you need to add –lupm-hcsr04 in the linkers for Cross G++ Linker > Miscellaneous. Try with this and let us know if you still have problems, if you do please a screenshot of the errors you get under the problems tab.

 

 

Regards,

 

Charlie

View solution in original post