Skip to content

Commit b9808a8

Browse files
committed
nuttx poll event struct uyumsuzluk problemi cozuldu
1 parent f98259f commit b9808a8

File tree

3 files changed

+18
-37
lines changed

3 files changed

+18
-37
lines changed

src/examples/px4_simple_app/px4_simple_app.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,6 @@ int rust_px4_poll(px4_pollfd_struct_t *fds, unsigned int nfds, int timeout) {
6363
return px4_poll(fds, nfds, timeout);
6464
}
6565

66-
// SITL derlemesinde bu blok otomatik olarak silinir, çakışma olmaz.
67-
// #if defined(__PX4_NUTTX)
68-
69-
// #include <poll.h>
70-
71-
// // Macro çakışmasını önle
72-
// #ifdef px4_poll
73-
// #undef px4_poll
74-
// #endif
75-
76-
// // Wrapper fonksiyonu tanımla
77-
// __EXPORT int px4_poll(px4_pollfd_struct_t *fds, unsigned int nfds, int timeout) {
78-
// return poll((struct pollfd *)fds, (nfds_t)nfds, timeout);
79-
// }
80-
81-
// #endif
82-
83-
// #ifdef px4_poll
84-
// #undef px4_poll
85-
// #endif
86-
87-
// // 2. Şimdi gerçek "px4_poll" fonksiyonunu tanımlıyoruz.
88-
// // Rust artık bu ismi gerçek bir fonksiyon olarak bulabilecek.
89-
// __EXPORT int px4_poll(px4_pollfd_struct_t *fds, unsigned int nfds, int timeout) {
90-
// // İçeride sistemin orijinal poll fonksiyonunu çağırıyoruz.
91-
// return poll((struct pollfd *)fds, (nfds_t)nfds, timeout);
92-
// }
93-
9466
int px4_simple_app_main(int argc, char *argv[])
9567
{
9668
// PX4_INFO("Hello Sky miii!");

src/examples/px4_simple_app/px4_simple_app/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// lib.rs veya main.rs başında
55
// extern crate alloc;
66

7-
use pictorus_px4::message_impls::VehicleLocalPosition;
7+
use pictorus_px4::message_impls::*;
88

99
use panic_halt as _;
1010

@@ -39,11 +39,11 @@ pub extern "C" fn rust_main() -> isize {
3939
unsafe {
4040
logging::init();
4141
};
42-
log::info!("merhaba dunya form rust");
42+
log::info!("selamunleykum dunya form rust 1");
4343

44-
let mut sub = Subscriber::<VehicleLocalPosition>::new().unwrap();
45-
for _ in 0..1000 {
46-
if let Ok(msg) = sub.next_timeout(1) {
44+
let mut sub = Subscriber::<SensorAccel>::new().unwrap();
45+
for _ in 0..100 {
46+
if let Ok(msg) = sub.next_timeout(50) {
4747
log::info!("local pos geldi {}", msg.timestamp);
4848
} else {
4949
log::info!("gelmedi");

src/examples/px4_simple_app/px4_simple_app/src/subscribe.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
use core::ffi::{c_int, c_short, c_uint, c_void};
1+
#[cfg(not(target_os = "none"))]
2+
use core::ffi::c_ushort;
3+
4+
#[cfg(target_os = "none")] // Genelde gömülü sistemler "none" olarak geçer
5+
use core::ffi::c_uint;
6+
7+
use core::ffi::{c_int, c_void};
28

39
use pictorus_px4::message_impls::Topic;
410
use px4_msgs_sys::orb::orb_copy;
511

6-
const POLLIN: c_short = 0x01;
7-
812
// PX4'teki typedef'lere karşılık gelen tipler
913
// Eğer C tarafında short ise burayı u16 yapın, ama genelde u32'dir.
10-
pub type Px4PollEvent = c_short;
14+
#[cfg(target_os = "none")] // Genelde gömülü sistemler "none" olarak geçer
15+
pub type Px4PollEvent = c_uint;
16+
#[cfg(not(target_os = "none"))] // SITL (Linux/Mac)
17+
pub type Px4PollEvent = c_ushort;
18+
19+
const POLLIN: Px4PollEvent = 0x01;
1120

1221
#[repr(C)]
1322
#[derive(Clone, Copy, Default)]

0 commit comments

Comments
 (0)