ardupilot/libraries/AP_Scripting/AP_Scripting_SerialAccess.h
Thomas Watson a077e4a3ed AP_Scripting: introduce serial device simulation support
Allows a script to simulate a device attached via any serial protocol.
The script can read and write data and have it handled according to the
protocol as if exchanged over a serial port. The script can then do
protocol translation, data filtering and validation,
hardware-in-the-loop simulation, experimentation, etc., especially in
combination with the scripting protocol which lets the script itself
handle an attached device and so interpose any communication.
2024-06-27 12:00:18 +10:00

34 lines
692 B
C++

#pragma once
#include "AP_Scripting_config.h"
#include "AP_Scripting.h"
#include <AP_HAL/UARTDriver.h>
class AP_Scripting_SerialAccess {
public:
/* Do not allow copies */
CLASS_NO_COPY(AP_Scripting_SerialAccess);
AP_Scripting_SerialAccess() {}
void begin(uint32_t baud);
size_t write(uint8_t c);
size_t write(const uint8_t *buffer, size_t size);
int16_t read(void);
ssize_t read(uint8_t *buffer, uint16_t count);
uint32_t available(void);
void set_flow_control(enum AP_HAL::UARTDriver::flow_control fcs);
AP_HAL::UARTDriver *stream;
#if AP_SCRIPTING_ENABLED
#if AP_SCRIPTING_SERIALDEVICE_ENABLED
bool is_device_port;
#endif
#endif
};