Skip to content

Compiler warning: "'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated" #164

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
rmlearney opened this issue Mar 9, 2021 · 1 comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@rmlearney
Copy link

rmlearney commented Mar 9, 2021

Compilation of the library for boards with an Mbed OS-based core generates multiple compiler warnings about the use of deprecated Mbed OS functions:

libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp: In function 'void bleLoop()':
libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:123:68: warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer microseconds are needed, you can use `elapsed_time().count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         last_update_us += (uint64_t) timer.read_high_resolution_us();
                                                                    ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:81:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/drivers/Timer.h:104:20: note: declared here
     us_timestamp_t read_high_resolution_us() const;
                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:145:72: warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer microseconds are needed, you can use `elapsed_time().count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         uint64_t time_spent = (uint64_t) timer.read_high_resolution_us();
                                                                        ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:81:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/drivers/Timer.h:104:20: note: declared here
     us_timestamp_t read_high_resolution_us() const;
                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:156:55: warning: 'void rtos::ThisThread::sleep_for(uint32_t)' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
               rtos::ThisThread::sleep_for(wait_time_ms);
                                                       ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/rtos/rtos.h:30:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:23,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/rtos/ThisThread.h:216:6: note: declared here
 void sleep_for(uint32_t millisec);
      ^~~~~~~~~

These come from code such as:

last_update_us += (uint64_t) timer.read_high_resolution_us();

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Mar 9, 2021
@paulvha
Copy link

paulvha commented Nov 10, 2022

These are just warnings for now, but these calls will be depreciated in the future.
instead of
(uint64_t) timer.read_high_resolution_us();
use
(uint64_t) timer.elapsed_time().count();

and instead of
rtos::ThisThread::sleep_for(wait_time_ms);
use
rtos::ThisThread::sleep_for(mbed::chrono::milliseconds_u32(wait_time_ms));

@per1234 per1234 added the topic: code Related to content of the project itself label Mar 21, 2025
@per1234 per1234 changed the title Compiler warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated Compiler warning: "'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated" Mar 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants