forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work to recieve heartbeat from ODID Scanner
- Loading branch information
Showing
2 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
#include "AP_ODIDScanner.h" | ||
|
||
AP_ODIDScanner::AP_ODIDScanner() { | ||
// TODO: Random default for mav_port needs fix | ||
AP_ODIDScanner::AP_ODIDScanner() : _mav_port(7){ | ||
|
||
} | ||
void AP_ODIDScanner::init() { | ||
|
||
_chan = mavlink_channel_t(gcs().get_channel_from_port_number(_mav_port)); | ||
_initialised = true; | ||
_port = AP::serialmanager().get_serial_by_id(_mav_port); | ||
} | ||
|
||
void AP_ODIDScanner::update_recv() { | ||
mavlink_message_t msg; | ||
mavlink_status_t status; | ||
uint32_t tstart_us = AP_HAL::micros(); | ||
uint32_t now_ms = AP_HAL::millis(); | ||
|
||
status.packet_rx_drop_count = 0; | ||
|
||
const uint16_t nbytes = _port->available(); | ||
for (uint16_t i=0; i<nbytes; i++) | ||
{ | ||
const uint8_t c = (uint8_t)_port->read(); | ||
if (mavlink_frame_char_buffer(channel_buffer(), channel_status(), c, &msg, &status) == MAVLINK_FRAMING_OK) { | ||
// TODO: How do I process this? | ||
} | ||
} | ||
} | ||
void AP_ODIDScanner::update() { | ||
const uint32_t now_ms = AP_HAL::millis(); | ||
if (now_ms - last_send_ms > 5000) { | ||
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "The driver is here."); | ||
last_send_ms =now_ms; | ||
if (now_ms - last_dev_hb_ms > 5000 && now_ms - last_dev_hb_msg_ms > 5000) { | ||
last_dev_hb_msg_ms = now_ms; | ||
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Scanner: Device Not Found"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters