5#include <QtCore/QByteArray>
6#include <QtCore/QLoggingCategory>
7#include <QtCore/QString>
8#include <QtCore/QStringList>
14Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
150QByteArray
read(
PortHandle handle,
int length, std::chrono::milliseconds timeout);
152int write(
PortHandle handle,
const char* data,
int length, std::chrono::milliseconds timeout);
virtual void resourceErrorArrived(ResourceErrorReason reason, const QString &detail)=0
virtual bool newDataArrived(const char *bytes, int length)=0
virtual void bytesWritten(int count)=0
bool getXon(PortHandle handle)
Under XON/XOFF flow control, false while the device has paused transmission.
bool isReading(PortHandle handle)
Result echoToCallbacks(PortHandle handle, const char *data, int length, int deliveredLength, int written, ResourceErrorReason reason, const QString &detail)
void deliverBytesWritten(PortHandle handle, int count)
qint64 PortHandle
Names an open port in every call to Java and in Java's callbacks. registerPort() makes one.
bool isControlLineSupported(PortHandle handle, QSerialPort::PinoutSignal line)
Whether the port has this one of the control lines.
QString getLastErrorDetail()
Result setLatencyTimer(PortHandle handle, int milliseconds)
Sets how long an FTDI chip holds back a partly filled packet, 1 to 255 ms. No other chip supports it.
bool deliverNewData(PortHandle handle, const char *bytes, int length)
FlowControl getFlowControl(PortHandle handle)
None also if the port cannot be asked.
void deliverResourceError(PortHandle handle, ResourceErrorReason reason, const QString &detail)
Result stopReading(PortHandle handle)
Stops delivering the port's input until startReading(); what arrives meanwhile is dropped.
constexpr const char * kJniUsbSerialManagerClassName
PortHandle registerPort(PortListener *listener)
Returns a handle under which Java's callbacks reach the listener until unregisterPort() has returned.
QByteArray read(PortHandle handle, int length, std::chrono::milliseconds timeout)
constexpr PortHandle kNoPort
Result setDataTerminalReady(PortHandle handle, bool set)
Result setRequestToSend(PortHandle handle, bool set)
PortHandle getPortHandle(const QString &portName)
The handle of the open port with this name, or kNoPort.
int write(PortHandle handle, const char *data, int length, std::chrono::milliseconds timeout)
Returns length, or a Result: Failed if the write timed out, otherwise what writeWithProgress() report...
bool hasPermission(const QString &portName)
Whether QGC may open the device of this port.
bool isControlLineActive(PortHandle handle, QSerialPort::PinoutSignal line)
Whether this one of the control lines is active.
Result startReading(PortHandle handle)
QList< QSerialPortInfo > portsAwaitingPermission()
The ports of attached devices that still need USB permission.
bool isPortOpen(const QString &portName)
QSerialPort::PinoutSignals getControlLines(PortHandle handle)
The control lines that are active.
Result purgeBuffers(PortHandle handle, QSerialPort::Directions directions)
QSerialPort::PinoutSignals getSupportedControlLines(PortHandle handle)
The control lines the port has at all. None also if the port cannot be asked.
QStringList unboundJavaNames()
Result setFlowControl(PortHandle handle, QSerialPort::FlowControl flowControl)
Result setBreak(PortHandle handle, bool set)
QList< QSerialPortInfo > availablePorts()
bool isPermissionDenied(const QString &portName)
int writeWithProgress(PortHandle handle, const char *data, int length, std::chrono::milliseconds timeout)
Result close(PortHandle handle)
bool isPortNameValid(const QString &portName)
Whether an attached device has a port with this name.
ResourceErrorReason
Why a port can no longer transfer data. QGCUsbSerialResourceError.java lists the same values.
@ WriteFailed
A write to the device failed.
@ ReadFailed
A read from the device failed.
@ DeviceDetached
The device was unplugged.
int open(const QString &portName, PortHandle handle)
bool requestPermission(const QString &portName)
Result setParameters(PortHandle handle, qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits, QSerialPort::Parity parity)
@ AlreadyOpen
Opening: the port is already open.
@ AmbiguousName
Opening: several attached devices share this stable name, so it opens none.
@ PermissionPending
The user was asked before, and has not answered yet.
@ PermissionDenied
Opening: QGC may not use the device, and the user denied the request to allow it.
@ PermissionAwaitsAndroid
The device was just attached, and Android asks the user first.
@ Unsupported
The port or its driver cannot do this.
@ NotOpen
No port is open under this handle.
@ DeviceNotFound
Opening: there is no such device.
@ PermissionRequested
This open has asked the user to allow it.
@ Failed
The call could not be made, or failed for a reason not listed here.
@ PermissionAwaitsFocus
The user is not asked while another window has the focus.
@ IoError
The device did not carry it out, and may be gone.
void unregisterPort(PortHandle handle)
QList< FlowControl > getSupportedFlowControl(PortHandle handle)
The flow control the port's driver has.
int writeAsync(PortHandle handle, const char *data, int length)