mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
px4io cleanup unnecessary Device CDev usage
This commit is contained in:
parent
01595947e5
commit
6ee47eef14
@ -111,7 +111,7 @@
|
||||
*
|
||||
* Encapsulates PX4FMU to PX4IO communications modeled as file operations.
|
||||
*/
|
||||
class PX4IO : public device::CDev
|
||||
class PX4IO : public cdev::CDev
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -446,12 +446,11 @@ private:
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
PX4IO *g_dev = nullptr;
|
||||
}
|
||||
|
||||
PX4IO::PX4IO(device::Device *interface) :
|
||||
CDev("px4io", PX4IO_DEVICE_PATH),
|
||||
CDev(PX4IO_DEVICE_PATH),
|
||||
_interface(interface),
|
||||
_hardware(0),
|
||||
_max_actuators(0),
|
||||
@ -552,10 +551,10 @@ PX4IO::detect()
|
||||
|
||||
if (protocol != PX4IO_PROTOCOL_VERSION) {
|
||||
if (protocol == _io_reg_get_error) {
|
||||
DEVICE_LOG("IO not installed");
|
||||
PX4_ERR("IO not installed");
|
||||
|
||||
} else {
|
||||
DEVICE_LOG("IO version error");
|
||||
PX4_ERR("IO version error");
|
||||
mavlink_log_emergency(&_mavlink_log_pub, "IO VERSION MISMATCH, PLEASE UPGRADE SOFTWARE!");
|
||||
}
|
||||
|
||||
@ -563,7 +562,7 @@ PX4IO::detect()
|
||||
}
|
||||
}
|
||||
|
||||
DEVICE_LOG("IO found");
|
||||
PX4_INFO("IO found");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -633,7 +632,7 @@ PX4IO::init()
|
||||
(_max_transfer < 16) || (_max_transfer > 255) ||
|
||||
(_max_rc_input < 1) || (_max_rc_input > 255)) {
|
||||
|
||||
DEVICE_LOG("config read error");
|
||||
PX4_ERR("config read error");
|
||||
mavlink_log_emergency(&_mavlink_log_pub, "[IO] config read fail, abort.");
|
||||
|
||||
// ask IO to reboot into bootloader as the failure may
|
||||
@ -768,7 +767,7 @@ PX4IO::init()
|
||||
/* re-send if necessary */
|
||||
if (!safety.armed) {
|
||||
orb_publish(ORB_ID(vehicle_command), pub, &vcmd);
|
||||
DEVICE_LOG("re-sending arm cmd");
|
||||
PX4_WARN("re-sending arm cmd");
|
||||
}
|
||||
|
||||
/* keep waiting for state change for 2 s */
|
||||
@ -799,7 +798,7 @@ PX4IO::init()
|
||||
ret = io_disable_rc_handling();
|
||||
|
||||
if (ret != OK) {
|
||||
DEVICE_LOG("failed disabling RC handling");
|
||||
PX4_ERR("failed disabling RC handling");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -846,7 +845,7 @@ PX4IO::init()
|
||||
nullptr);
|
||||
|
||||
if (_task < 0) {
|
||||
DEVICE_DEBUG("task start failed: %d", errno);
|
||||
PX4_ERR("task start failed: %d", errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@ -1221,7 +1220,7 @@ PX4IO::task_main()
|
||||
unlock();
|
||||
|
||||
out:
|
||||
DEVICE_DEBUG("exiting");
|
||||
PX4_DEBUG("exiting");
|
||||
|
||||
/* clean up the alternate device node */
|
||||
if (_primary_pwm_device) {
|
||||
@ -1586,7 +1585,7 @@ PX4IO::io_set_rc_config()
|
||||
ret = io_reg_set(PX4IO_PAGE_RC_CONFIG, offset, regs, PX4IO_P_RC_CONFIG_STRIDE);
|
||||
|
||||
if (ret != OK) {
|
||||
DEVICE_LOG("rc config upload failed");
|
||||
PX4_ERR("rc config upload failed");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1937,14 +1936,14 @@ PX4IO::io_reg_set(uint8_t page, uint8_t offset, const uint16_t *values, unsigned
|
||||
{
|
||||
/* range check the transfer */
|
||||
if (num_values > ((_max_transfer) / sizeof(*values))) {
|
||||
DEVICE_DEBUG("io_reg_set: too many registers (%u, max %u)", num_values, _max_transfer / 2);
|
||||
PX4_DEBUG("io_reg_set: too many registers (%u, max %u)", num_values, _max_transfer / 2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int ret = _interface->write((page << 8) | offset, (void *)values, num_values);
|
||||
|
||||
if (ret != (int)num_values) {
|
||||
DEVICE_DEBUG("io_reg_set(%hhu,%hhu,%u): error %d", page, offset, num_values, ret);
|
||||
PX4_DEBUG("io_reg_set(%hhu,%hhu,%u): error %d", page, offset, num_values, ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1962,14 +1961,14 @@ PX4IO::io_reg_get(uint8_t page, uint8_t offset, uint16_t *values, unsigned num_v
|
||||
{
|
||||
/* range check the transfer */
|
||||
if (num_values > ((_max_transfer) / sizeof(*values))) {
|
||||
DEVICE_DEBUG("io_reg_get: too many registers (%u, max %u)", num_values, _max_transfer / 2);
|
||||
PX4_DEBUG("io_reg_get: too many registers (%u, max %u)", num_values, _max_transfer / 2);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int ret = _interface->read((page << 8) | offset, reinterpret_cast<void *>(values), num_values);
|
||||
|
||||
if (ret != (int)num_values) {
|
||||
DEVICE_DEBUG("io_reg_get(%hhu,%hhu,%u): data error %d", page, offset, num_values, ret);
|
||||
PX4_DEBUG("io_reg_get(%hhu,%hhu,%u): data error %d", page, offset, num_values, ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2120,7 +2119,7 @@ PX4IO::mixer_send(const char *buf, unsigned buflen, unsigned retries)
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
DEVICE_LOG("mixer send error %d", ret);
|
||||
PX4_ERR("mixer send error %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2799,7 +2798,7 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
|
||||
}
|
||||
|
||||
if (io_crc != arg) {
|
||||
DEVICE_DEBUG("crc mismatch 0x%08x 0x%08lx", io_crc, arg);
|
||||
PX4_DEBUG("crc mismatch 0x%08x 0x%08lx", io_crc, arg);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user