Hrt_absolute_time() always return 0

Hello there;

When i use the function which is defined in drv_hrt.c called hrt_absolute_time(), It always returning 0 value.

here is my use of it:
hrt_abstime clock = hrt_absolute_time();
PX4_INFO(“Time is : %10.6f”,clock);

Here is the code of the function:

/*
 * Get absolute time.
 */
hrt_abstime hrt_absolute_time(void)
{
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    return ts_to_abstime(&ts);
}

Here is my full code :

int myserial_thread_main(int argc, char *argv[]){
	char str[100]={0};
	char c;
  
  hrt_abstime clock;
	//UART open
	hrt_init();
  int uart = uart_initt("/dev/ttyS6");
	if(false == uart)return -1;
	if(false == set_uart_baudratee(uart,9600)){
			printf("[YCM]set_uart_baudrate is failed\n");
			return -1;
	}
	int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));
	
	px4_pollfd_struct_t fds[] = {
	{ .fd = sensor_sub_fd,   .events = POLLIN },
	};
	
	
	while(1){
    /*  start measuring */
  
   clock=hrt_absolute_time();
		int poll_ret = px4_poll(fds, 1,1000);
		if(poll_ret > 0){
			if (fds[0].revents & POLLIN) {
				/* obtained data for the first file descriptor */
				struct sensor_combined_s raw;
				/* copy sensors raw data into local buffer */
				orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);
				sprintf(str,"S %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f E\r\n",(double)raw.accelerometer_m_s2[0],
																		  (double)raw.accelerometer_m_s2[1],
																		  (double)raw.accelerometer_m_s2[2],
																		  (double)raw.gyro_rad[0],
																		  (double)raw.gyro_rad[1],
																		  (double)raw.gyro_rad[2]);
				
				for(int j=0;j<sizeof(str);j++){
					c = str[j];
					write(uart, &c, 1);
				}
        
          PX4_INFO("Time is: %10.6f",clock);
			}
		}		
	} 
}

and the resulst is :

Do I forgot something ?

typedef uint64_t hrt_abstime;

in drv_hrt_h

Its a type long. So I change PX4_INFO(“Time is: %10.6f”,clock); in
PX4_INFO(“Time is: %d”,clock);

and now I have

Srange …

anybody on this one ?
I triyed just a simple version of it:

and it is still printing this :

Not sure, but I don’t think the %d print flag will work. Pretty sure abs_time type is defined as uint64_t, so it should be printed as such: PX4_INFO("Time is %" PRIu64 ", now);

somehow I made it works using directly the clock_gettime() function.

can you put your code which with the function clock_gettime()?

I am having the same issue.
hrt_absolute_time() in mavlink_reciever.cpp always returns 0, however in logger.cpp almost at same time hrt_absolute_time() returns 97203352.