doc, small fixes

This commit is contained in:
2022-05-08 19:23:52 +03:00
parent 460519c075
commit 3107949e6f
24 changed files with 1061 additions and 406 deletions

View File

@@ -137,21 +137,33 @@
#endif
/*! \class PISerial
* \brief Serial device
*
* \section PISerial_sec0 Synopsis
* This class provide access to serial device, e.g. COM port. It can read,
* write, wait for write. There are several read and write functions.
*
* \section PISerial_sec1 FullPath
* Since version 1.16.0 you can use as \a path DeviceInfo::id() USB identifier.
* \code
* PISerial * s = new PISerial("0403:6001");
* PIIODevice * d = PIIODevice::createFromFullPath("ser://0403:6001:115200");
* \endcode
*
*/
//! \class PISerial piserial.h
//! \details
//! \~english \section PISerial_sec0 Synopsis
//! \~russian \section PISerial_sec0 Краткий обзор
//! \~english
//! This class provide access to serial device, e.g. COM port. It can read,
//! write, wait for write. There are several read and write functions.
//!
//! \~russian
//! Этот класс предоставляет доступ к последовательному порту, например, COM-порт.
//!
//! \~english \section PISerial_sec1 FullPath
//! \~russian \section PISerial_sec1 Строка полного описания
//! \~english
//! Since version 1.16.0 you can use as \a path \a PISerial::DeviceInfo::id() USB identifier
//! for USB devices.
//!
//! \~russian
//! Начиная с версии 1.16.0 можно в качестве \a path использовать \a PISerial::DeviceInfo::id()
//! USB идентификатор для USB устройств.
//!
//! \~\code
//! PISerial * s = new PISerial("0403:6001");
//! PIIODevice * d = PIIODevice::createFromFullPath("ser://0403:6001:115200");
//! \endcode
//!
REGISTER_DEVICE(PISerial)
@@ -289,6 +301,16 @@ bool PISerial::isRNG() const {return isBit(TIOCM_RNG, "RNG");}
bool PISerial::isDSR() const {return isBit(TIOCM_DSR, "DSR");}
//! \~\details
//! \~english
//! If enabled, sends a continuous stream of zero bits.
//! Returns if state changed successfully.
//! \note The serial port has to be open before using this method
//!
//! \~russian
//! Если включено, отсылается непрерывный поток нулей.
//! Возвращает успешна ли смена состояния.
//! \note Порт должен быть открыт перед использованием этого метода
bool PISerial::setBreak(bool enabled) {
if (fd < 0) {
piCoutObj << "sendBreak error: \"" << path() << "\" is not opened!";
@@ -416,14 +438,24 @@ int PISerial::convertSpeed(PISerial::Speed speed) {
}
/** \brief Advanced read function
* \details Read to pointer "read_to" no more than "max_size" and no longer
* than "timeout_ms" milliseconds. If "timeout_ms" < 0 function will be
* wait forever until "max_size" will be readed. If size <= 0 function
* immediate returns \b false. For read data with unknown size use function
* \a readData().
* \returns \b True if readed bytes count = "max_size", else \b false
* \sa \a readData() */
//! \details
//! \~english
//! Read to pointer "read_to" no more than "max_size" and no longer
//! than "timeout_ms" milliseconds.\n
//! If "timeout_ms" < 0 function will be wait forever until "max_size" will be readed.\n
//! If "size" <= 0 function immediate returns \b false.\n
//! For read data with unknown size use function \a readData().
//! \returns If readed bytes count = "max_size"
//!
//! \~russian
//! Читает в указатель "read_to" не более "max_size" байт и не дольше
//! чем "timeout_ms" миллисекунд.\n
//! Если "timeout_ms" < 0 метод ожидает бесконечно, пока не будет прочитано "max_size" байт.\n
//! Если "size" <= 0, то метод немедленно возвращает \b false.\n
//! Для чтения данных неизвестного размера используется метод \a readData().
//! \returns Если количество прочитанных байт = "max_size"
//!
//! \sa \a readString(), \a readData()
bool PISerial::read(void * data, int size, double timeout_ms) {
if (data == 0 || size <= 0) return false;
int ret, all = 0;
@@ -454,15 +486,25 @@ bool PISerial::read(void * data, int size, double timeout_ms) {
}
/** \brief Advanced read function
* \details Read all or no more than "size" and no longer than
* "timeout_ms" milliseconds. If "timeout_ms" < 0 function will be
* wait forever until "size" will be readed. If "size" <= 0
* function will be read all until "timeout_ms" elaped. \n If size <= 0
* and "timeout_ms" <= 0 function immediate returns empty string.
* \n This function similar to \a readData() but returns data as string.
* \sa \a readData() */
PIString PISerial::read(int size, double timeout_ms) {
//! \details
//! \~english
//! Read all or no more than "size" bytes and no longer than "timeout_ms" milliseconds.\n
//! If "timeout_ms" < 0 function will be wait forever until "max_size" will be readed.\n
//! If "size" <= 0 function will be read all until "timeout_ms" elaped.\n
//! If "size" <= 0 and "timeout_ms" <= 0 function immediate returns empty string.\n
//! This function similar to \a readData() but returns data as string.
//! \returns If readed bytes count = "max_size"
//!
//! \~russian
//! Читает всё или не более "size" байт и не дольше чем "timeout_ms" миллисекунд.\n
//! Если "timeout_ms" < 0 метод ожидает бесконечно, пока не будет прочитано "max_size" байт.\n
//! Если "size" <= 0, то читает всё в течении "timeout_ms" миллисекунд.\n
//! Если "size" <= 0 и "timeout_ms" <= 0, то метод немедленно возвращает пустую строку.\n
//! Этот метод аналогичен \a readData(), но возвращает строку.
//! \returns Если количество прочитанных байт = "max_size"
//!
//! \sa \a readData()
PIString PISerial::readString(int size, double timeout_ms) {
PIString str;
if (size <= 0 && timeout_ms <= 0.) return str;
int ret, all = 0;
@@ -506,14 +548,24 @@ PIString PISerial::read(int size, double timeout_ms) {
}
/** \brief Advanced read function
* \details Read all or no more than "size" and no longer than
* "timeout_ms" milliseconds. If "timeout_ms" < 0 function will be
* wait forever until "size" will be readed. If "size" <= 0
* function will be read all until "timeout_ms" elaped. \n If size <= 0
* and "timeout_ms" <= 0 function immediate returns empty byte array.
* \n This function similar to \a read() but returns data as byte array.
* \sa \a read() */
//! \details
//! \~english
//! Read all or no more than "size" bytes and no longer than "timeout_ms" milliseconds.\n
//! If "timeout_ms" < 0 function will be wait forever until "max_size" will be readed.\n
//! If "size" <= 0 function will be read all until "timeout_ms" elaped.\n
//! If "size" <= 0 and "timeout_ms" <= 0 function immediate returns empty string.\n
//! This function similar to \a readString() but returns data as byte array.
//! \returns If readed bytes count = "max_size"
//!
//! \~russian
//! Читает всё или не более "size" байт и не дольше чем "timeout_ms" миллисекунд.\n
//! Если "timeout_ms" < 0 метод ожидает бесконечно, пока не будет прочитано "max_size" байт.\n
//! Если "size" <= 0, то читает всё в течении "timeout_ms" миллисекунд.\n
//! Если "size" <= 0 и "timeout_ms" <= 0, то метод немедленно возвращает пустую строку.\n
//! Этот метод аналогичен \a readString(), но возвращает массив байт.
//! \returns Если количество прочитанных байт = "max_size"
//!
//! \sa \a readString()
PIByteArray PISerial::readData(int size, double timeout_ms) {
PIByteArray str;
if (size <= 0 && timeout_ms <= 0.) return str;
@@ -722,11 +774,20 @@ void PISerial::setTimeouts() {
}
/** \brief Basic read function
* \details Read to pointer "read_to" no more than "max_size". If read is
* set to blocking this function will be wait at least one byte.
* \returns Readed bytes count
* \sa \a readData() */
//! \details
//! \~english
//! Read to pointer "read_to" no more than "max_size".
//! If \a PIIODevice::BlockingRead option set this function
//! will be wait at least one byte.
//! \returns Readed bytes count, -1 for error
//!
//! \~russian
//! Читает в указатель "read_to" не более "max_size" байт.
//! Если установлена опция \a PIIODevice::BlockingRead,
//! то этот метод ожидает хотя бы одного байта.
//! \returns Количество прочитанных байт, -1 при ошибке
//!
//! \~\sa \a readData(), \a readString()
int PISerial::readDevice(void * read_to, int max_size) {
#ifdef WINDOWS
if (!canRead()) return -1;