mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 07:44:03 -04:00
HAL_PX4: added basic console driver (output only)
This commit is contained in:
parent
0ef003a45f
commit
da10e68e87
@ -3,6 +3,7 @@
|
||||
#define __AP_HAL_PX4_NAMESPACE_H__
|
||||
|
||||
namespace PX4 {
|
||||
class PX4ConsoleDriver;
|
||||
}
|
||||
|
||||
#endif //__AP_HAL_PX4_NAMESPACE_H__
|
||||
|
81
libraries/AP_HAL_PX4/Console.cpp
Normal file
81
libraries/AP_HAL_PX4/Console.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
#include <stdarg.h>
|
||||
#include "Console.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace PX4;
|
||||
|
||||
PX4ConsoleDriver::PX4ConsoleDriver() {}
|
||||
|
||||
void PX4ConsoleDriver::init(void* unused)
|
||||
{
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::backend_open()
|
||||
{}
|
||||
|
||||
void PX4ConsoleDriver::backend_close()
|
||||
{}
|
||||
|
||||
size_t PX4ConsoleDriver::backend_read(uint8_t *data, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t PX4ConsoleDriver::backend_write(const uint8_t *data, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::print_P(const prog_char_t *pstr) {
|
||||
print(pstr);
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::println_P(const prog_char_t *pstr) {
|
||||
println(pstr);
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::_printf_P(const prog_char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vfprintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::vprintf(const char *fmt, va_list ap) {
|
||||
vfprintf(stdout, fmt, ap);
|
||||
}
|
||||
|
||||
void PX4ConsoleDriver::vprintf_P(const prog_char *fmt, va_list ap) {
|
||||
vfprintf(stdout, fmt, ap);
|
||||
}
|
||||
|
||||
int16_t PX4ConsoleDriver::available() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t PX4ConsoleDriver::txspace() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t PX4ConsoleDriver::read() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t PX4ConsoleDriver::peek() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t PX4ConsoleDriver::write(uint8_t c) {
|
||||
fputc(c, stdout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
32
libraries/AP_HAL_PX4/Console.h
Normal file
32
libraries/AP_HAL_PX4/Console.h
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef __AP_HAL_PX4_CONSOLE_H__
|
||||
#define __AP_HAL_PX4_CONSOLE_H__
|
||||
|
||||
#include <AP_HAL_PX4.h>
|
||||
#include <AP_HAL_PX4_Namespace.h>
|
||||
|
||||
class PX4::PX4ConsoleDriver : public AP_HAL::ConsoleDriver {
|
||||
public:
|
||||
PX4ConsoleDriver();
|
||||
void init(void* machtnichts);
|
||||
void backend_open();
|
||||
void backend_close();
|
||||
size_t backend_read(uint8_t *data, size_t len);
|
||||
size_t backend_write(const uint8_t *data, size_t len);
|
||||
|
||||
void print_P(const prog_char_t *pstr);
|
||||
void println_P(const prog_char_t *pstr);
|
||||
void printf(const char *pstr, ...);
|
||||
void _printf_P(const prog_char *pstr, ...);
|
||||
void vprintf(const char *pstr, va_list ap);
|
||||
void vprintf_P(const prog_char *pstr, va_list ap);
|
||||
|
||||
int16_t available();
|
||||
int16_t txspace();
|
||||
int16_t read();
|
||||
int16_t peek();
|
||||
|
||||
size_t write(uint8_t c);
|
||||
};
|
||||
|
||||
#endif // __AP_HAL_PX4_CONSOLE_H__
|
@ -7,10 +7,13 @@
|
||||
#include <AP_HAL_PX4.h>
|
||||
#include "AP_HAL_PX4_Namespace.h"
|
||||
#include "HAL_PX4_Class.h"
|
||||
#include "Console.h"
|
||||
|
||||
#include <AP_HAL_Empty.h>
|
||||
#include <AP_HAL_Empty_Private.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace PX4;
|
||||
|
||||
static Empty::EmptyUARTDriver uartADriver;
|
||||
@ -26,7 +29,7 @@ static Empty::EmptyRCOutput rcoutDriver;
|
||||
static Empty::EmptyScheduler schedulerInstance;
|
||||
static Empty::EmptyUtil utilInstance;
|
||||
|
||||
static Empty::EmptyConsoleDriver consoleDriver(&uartADriver);
|
||||
static PX4ConsoleDriver consoleDriver;
|
||||
|
||||
HAL_PX4::HAL_PX4() :
|
||||
AP_HAL::HAL(
|
||||
@ -50,9 +53,6 @@ void HAL_PX4::init(int argc, char * const argv[]) const
|
||||
scheduler->init(NULL);
|
||||
uartA->begin(115200);
|
||||
console->init((void*) uartA);
|
||||
rcin->init(NULL);
|
||||
rcout->init(NULL);
|
||||
analogin->init(NULL);
|
||||
}
|
||||
|
||||
const HAL_PX4 AP_HAL_PX4;
|
||||
|
Loading…
Reference in New Issue
Block a user