c - PX4 Autopilot: "initialization makes integer from pointer without a cast" -


i've started working on px4 autopilot , working throught 1 of example applicaton , tried compile , upload firmware pixhawk.

the problem failed load giving me these errors:

make[2]: * [px4_simple_app.c.o] error 1 make[1]: * [/c/px4/firmware/build/px4fmu-v2_default.build//c/px4/firmware/src/examples/px4_simple_app/module.pre.o] error 2 make[1]: leaving directory `/c/px4/firmware/build/px4fmu-v2_default.build' make: *** [/c/px4/firmware/build/px4fmu-v2_default.build/firmware.px4] error 2

i'm not sure these mean, inspecting code gave me error in line:

initialization makes integer pointer without cast

from line:

int att_pub_fd = orb_advertise(orb_id(vehicle_attitude), &att); 

and i'm not sure how can fix this. can give me help?

this rest of code:

/**  * @file px4_simple_app.c  * minimal application example px4 autopilot  */  #include <string.h> #include <nuttx/config.h> #include <unistd.h> #include <stdio.h> #include <poll.h>  #include <uorb/uorb.h> #include <uorb/topics/sensor_combined.h> #include <uorb/topics/vehicle_attitude.h>  __export int px4_simple_app_main(int argc, char *argv[]);  int px4_simple_app_main(int argc, char *argv[]) { printf("hello sky!\n");  /* subscribe sensor_combined topic */ int sensor_sub_fd = orb_subscribe(orb_id(sensor_combined)); orb_set_interval(sensor_sub_fd, 1000);  /* advertise attitude topic */ struct vehicle_attitude_s att; memset(&att, 0, sizeof(att)); int att_pub_fd = orb_advertise(orb_id(vehicle_attitude), &att);  /* 1 wait multiple topics technique, using 1 here */ struct pollfd fds[] = {     { .fd = sensor_sub_fd,   .events = pollin },     /* there more file descriptors here, in form like:      * { .fd = other_sub_fd,   .events = pollin },      */ };  int error_counter = 0;  while (true) {     /* wait sensor update of 1 file descriptor 1000 ms (1 second) */     int poll_ret = poll(fds, 1, 1000);      /* handle poll result */     if (poll_ret == 0) {         /* means none of our providers giving data */         printf("[px4_simple_app] got no data within second\n");     } else if (poll_ret < 0) {         /* bad - should emergency */         if (error_counter < 10 || error_counter % 50 == 0) {             /* use counter prevent flooding (and slowing down) */             printf("[px4_simple_app] error return value poll(): %d\n"                 , poll_ret);         }         error_counter++;     } else {          if (fds[0].revents & pollin) {             /* obtained data first file descriptor */             struct sensor_combined_s raw;             /* copy sensors raw data local buffer */             orb_copy(orb_id(sensor_combined), sensor_sub_fd, &raw);             printf("[px4_simple_app] accelerometer:\t%8.4f\t%8.4f\t%8.4f\n",                 (double)raw.accelerometer_m_s2[0],                 (double)raw.accelerometer_m_s2[1],                 (double)raw.accelerometer_m_s2[2]);              /* set att , publish information other apps */             att.roll = raw.accelerometer_m_s2[0];             att.pitch = raw.accelerometer_m_s2[1];             att.yaw = raw.accelerometer_m_s2[2];             orb_publish(orb_id(vehicle_attitude), att_pub_fd, &att);         }         /* there more file descriptors here, in form like:          * if (fds[1..n].revents & pollin) {}          */     } }  return 0; } 

the function

orb_advertise(orb_id(vehicle_attitude), &att)  

returns pointer , assigning int. im not sure trying if pointing integer need dereference pointer.


Comments