|
LRAUV
revA
|
Implements both InStream and OutStream for the LPC3XXX Standard UART. More...
#include <UartStream.h>


Public Types | |
| enum | Baudrate { B_50, B_75, B_110, B_134, B_150, B_200, B_300, B_600, B_1200, B_1800, B_2400, B_4800, B_9600, B_19200, B_38400, B_57600, B_115200, B_230400 } |
| Baudrates as per termios. More... | |
| enum | UartId { NOT_UART, UART1_TX0, UART2_TX1, UART3_S1, UART4_S2, UART5_S0, UART6_S3, UART7_TX2, UART_A0, UART_A1, UART_A2, UART_A3, UART_A4, UART_A5, UART_A6, UART_A7, UART_B0, UART_B1, UART_B2, UART_B3, UART_B4, UART_B5, UART_B6, UART_B7 } |
| UARTS. More... | |
| enum | UartError { OK = 0, BUFFER_FULL, TIMEOUT, CANNOT_OPEN_SERIAL_PORT, CANNOT_GET_DEVICE_SETTINGS, BAD_BAUD_RATE_FOR_PORT, BAD_PARAMETERS_FOR_PORT, PORT_NOT_OPEN, WRITE_CHAR_LOST } |
| UART Errors. More... | |
Public Member Functions | |
| UartStream (const ConfigURI &uartCfg, const ConfigURI &baudCfg, const double timeoutSec, Logger &logger, size_t bufferSize=1, bool blocking=false) | |
| Constructor. More... | |
| ~UartStream () | |
| Destructor. More... | |
| const char * | getName () |
| Returns uart name. More... | |
| UartStream & | open () |
| UartStream & | openAtBaudrate (UartStream::Baudrate baud) |
| OutStream & | write (const char *data, size_t length=0xFFFFFFFF) |
| If length is unspecified, strlen is used to determine the length. More... | |
| UartStream & | readLine (char *buf, size_t bufsize) |
| Fills buffer until: buffer size is exceeded, CR, LF, or ETX character is received, or the serial timeout has expired. More... | |
| UartStream & | readLines (char *buf, size_t bufsize, size_t lines) |
| Fills buffer with given number of lines (CR/LF) until buffer size is exceeded or timeout has expired or ETX character is received. More... | |
| InStream & | read (char *buf, size_t num) |
| reads num bytes from stream to the buffer More... | |
| UartStream & | readUntil (char *buf, size_t num, const unsigned char match, bool flushUntil=false) |
| UartStream & | readUntil (char *buf, size_t num, const char *match, unsigned int matchLen, bool flushUntil=false) |
| UartStream & | readUntil (char *buf, size_t num, const unsigned char *match, unsigned int matchLen, bool flushUntil=false) |
| size_t | canReadUntil (const unsigned char match) |
| size_t | canReadUntil (const char *match, int matchLen=0, int maxCheck=0) |
| size_t | canReadUntil (const unsigned char *match, int matchLen=0, int maxCheck=0) |
| UartStream & | flushCRLF () |
| Flushes CR and LF characters out of the buffer until there are no more characters. More... | |
| UartStream & | flush (int num=-1) |
| Flushes any characters out of the buffer until there are no more characters, or if num is positive, until the specified number of characters are flushed. More... | |
| UartStream & | close () |
| UartStream & | setStartTimeout (const double timeout) |
| UartStream & | resetStartTimeout () |
| const char * | uartIdToString (UartId uart) |
| UartStream::UartError | getError () |
| bool | hasError () |
| const char * | errorString () |
| virtual bool | eof () |
| Indicates if the end of file has been reached. More... | |
| virtual bool | isReadable () |
| indicates whether the stream can actually be read from. More... | |
| virtual bool | isWritable () |
| indicates whether the stream can actually be written to. More... | |
| void | waitForBufferEmpty () |
| size_t | dataAvailable () |
| size_t | dataBuffered () |
| void | setDebug (bool debugOn) |
| void | enableUART (void) |
| void | disableUART (void) |
| void | fillInBuffer () |
Public Member Functions inherited from InStream | |
| virtual | ~InStream () |
| Destructor. More... | |
| InStream & | readChar (signed char &value) |
| reads a single byte to the input buffer/stream More... | |
| InStream & | readCharHex (signed char &byte) |
| reads a single unsigned char from the input buffer/stream as 2 hex chars More... | |
| InStream & | readUCharHex (unsigned char &byte) |
| reads a single unsigned char from the input buffer/stream as 2 hex chars More... | |
| virtual InStream & | readLine (char *buf, unsigned int bufsize) |
| InStream & | readShort (short &value) |
| reads a single short from the input buffer/stream More... | |
| InStream & | readShort (unsigned short &value) |
| reads a single short from the input buffer/stream More... | |
| InStream & | readShortHex (short &word) |
| reads a single short from the input buffer/stream as 4 hex chars More... | |
| InStream & | readUShortHex (unsigned short &value) |
| reads a single unsigned short from the input buffer/stream as 4 hex chars More... | |
| InStream & | readUShortCompact (unsigned short &value) |
| reads an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 16 bit value, encoded in 3 bytes More... | |
| InStream & | readInt24 (int &medInt) |
| reads a 3-byte integer to the input buffer/stream only works on little-endian machines! More... | |
| InStream & | readInt (int &value) |
| reads a 4-byte integer to the input buffer/stream More... | |
| InStream & | readLongLong (long long &value) |
| reads a 8-byte integer to the input buffer/stream More... | |
| InStream & | readLongLongCompact (long long &value) |
| reads a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value, encoded in 1 byte 10xxxxxx+1byte - 14 bit value, encoded in 2 bytes 110xxxxx+2bytes - 21 bit value, encoded in 3 bytes 1110xxxx+3bytes - 28 bit value, encoded in 4 bytes 11110xxx+4bytes - 35 bit value, encoded in 5 bytes 111110xx+5bytes - 42 bit value, encoded in 6 bytes 1111110x+6bytes - 49 bit value, encoded in 7 bytes 11111110+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes More... | |
| InStream & | readFloat (float &value) |
| reads a 4-byte float to the input buffer/stream More... | |
| InStream & | readFloat2 (float &value) |
| reads a 2-byte float to the input buffer/stream More... | |
| InStream & | readFloat3 (float &value) |
| reads a 3-byte float to the input buffer/stream More... | |
| InStream & | readDouble (double &value) |
| reads a 8-byte double to the input buffer/stream More... | |
| virtual InStream & | readUntil (char *buf, unsigned int num, unsigned char match) |
| size_t | bytesRead () |
| Indicates the number of bytes read in the last operation. More... | |
| size_t | getBytesRead () |
| Indicates the number of bytes read in the last operation. More... | |
| size_t | getTotalBytesRead () |
| Indicates the total number of bytes read;. More... | |
Public Member Functions inherited from OutStream | |
| virtual | ~OutStream () |
| Destructor. More... | |
| virtual OutStream & | writeHex (const char *buffer, size_t num) |
| writes num bytes from buffer to the output buffer/stream as hex chars More... | |
| virtual OutStream & | write (const char *buffer) |
| writes zero-terminated buffer to the output buffer/stream More... | |
| virtual OutStream & | writeHex (const char *buffer) |
| writes zero-terminated buffer to the output buffer/stream More... | |
| OutStream & | operator<< (const Str buffer) |
| write a Str, using stream operator More... | |
| OutStream & | operator<< (const char buffer[]) |
| write a Str, using stream operator More... | |
| OutStream & | operator<< (const char byte) |
| write a Str, using stream operator More... | |
| OutStream & | operator<< (const signed char byte) |
| write a Str, using stream operator More... | |
| OutStream & | operator<< (const unsigned char byte) |
| write a Str, using stream operator More... | |
| OutStream & | operator<< (const int number) |
| write a Str, using stream operator More... | |
| OutStream & | writeChar (const signed char value) |
| writes a single byte to the output buffer/stream More... | |
| OutStream & | writeCharHex (const signed char byte) |
| writes a single signed char to the output buffer/stream as 2 hex chars More... | |
| OutStream & | writeUCharHex (const unsigned char byte) |
| writes a single unsigned char to the output buffer/stream as 2 hex chars More... | |
| OutStream & | writeInteger (const int number, const unsigned int radix=10) |
| writes an integer as a base-radix string More... | |
| OutStream & | writeNumber (const double number, const unsigned int radix=10) |
| OutStream & | writeShort (const short value) |
| writes a single short to the output buffer/stream More... | |
| OutStream & | writeShortHex (const short word) |
| writes a single short to the output buffer/stream as 4 hex chars More... | |
| OutStream & | writeUShortHex (const unsigned short word) |
| writes a single unsigned short to the output buffer/stream as 4 hex chars More... | |
| OutStream & | writeUShortCompact (const unsigned short &value) |
| writes an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 16 bit value, encoded in 3 bytes More... | |
| OutStream & | writeInt24 (const int medInt) |
| writes a 3-byte integer to the output buffer/stream only works on little-endian machines! More... | |
| OutStream & | writeInt (const int value) |
| writes a 4-byte integer to the output buffer/stream More... | |
| OutStream & | writeLongLong (const long long value) |
| writes a 8-byte integer to the output buffer/stream More... | |
| OutStream & | writeLongLongCompact (const long long &value) |
| writes a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value, encoded in 1 byte 10xxxxxx+1byte - 14 bit value, encoded in 2 bytes 110xxxxx+2bytes - 21 bit value, encoded in 3 bytes 1110xxxx+3bytes - 28 bit value, encoded in 4 bytes 11110xxx+4bytes - 35 bit value, encoded in 5 bytes 111110xx+5bytes - 42 bit value, encoded in 6 bytes 1111110x+6bytes - 49 bit value, encoded in 7 bytes 11111110+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes More... | |
| OutStream & | writeFloat (const float value) |
| writes a 4-byte float to the output buffer/stream More... | |
| OutStream & | writeFloat2 (const float value) |
| writes a 2-byte float to the output buffer/stream More... | |
| OutStream & | writeFloat3 (const float value) |
| writes a 3-byte float to the output buffer/stream More... | |
| OutStream & | writeDouble (const double value) |
| writes a 8-byte double to the output buffer/stream More... | |
| OutStream & | writeDouble6 (const double value) |
| size_t | bytesWritten () |
Private Member Functions | |
| UartStream (const UartStream &old) | |
| void | serGetChar (unsigned char *c, int *success, const Timespan &timeout=Timespan::INVALID_TIMESPAN) |
| void | initializePort (UartStream::UartId) |
| const char * | uartToDevice (UartId uart) |
Static Private Member Functions | |
| static Str | LookupFilename (const ConfigURI &uartCfg, Logger &logger) |
| static Baudrate | LookupBaudrate (const ConfigURI &baudCfg, Logger &logger) |
| static UartId | DeviceToUART (const Str &name) |
| static const speed_t | BaudToSpeed (Baudrate baud) |
Private Attributes | |
| int | serPortFd_ |
| Str | filename_ |
| UartId | uartId_ |
| UartStream::Baudrate | defaultBaudrate_ |
| Timespan | startTimeout_ |
| Timespan | defaultStartTimeout_ |
| Timespan | betweenTimeout_ |
| UartStream::UartError | lastError_ |
| Logger | logger_ |
| char | pushedChar_ |
| char * | pushedChars_ |
| size_t | bufferSize_ |
| int | bufferPos_ |
| bool | blocking_ |
| bool | debug_ |
Static Private Attributes | |
| static const Timespan | SLEEP_TIME |
| A 10 millisecond sleep. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from InStream | |
| InStream () | |
| Protected Constructor for abstract class. More... | |
| void | zeroBytesRead () |
| void | incBytesRead () |
| void | incBytesRead (size_t incRead) |
| void | setBytesRead (size_t lastRead) |
| void | zeroTotalBytesRead () |
Protected Member Functions inherited from OutStream | |
| OutStream () | |
| Protected Constructor for abstract class. More... | |
Protected Attributes inherited from OutStream | |
| size_t | lastWritten_ |
Static Protected Attributes inherited from OutStream | |
| static const unsigned char | HEX_CHARS [] = "0123456789ABCDEF" |
| UartStream::UartStream | ( | const ConfigURI & | uartCfg, |
| const ConfigURI & | baudCfg, | ||
| const double | timeoutSec, | ||
| Logger & | logger, | ||
| size_t | bufferSize = 1, |
||
| bool | blocking = false |
||
| ) |
Constructor.
param uartCfg name of uart device definition in vehicle.cfg file param baudCfg name of baud rate definition in vehicle.cfg file param timeoutSec inter-character timeout param logger logger of the owning component param bufferSize size of buffer for readUntil operations param blocking set to true to idle processor waiting for timeoutSec
References bufferSize_, pushedChar_, and pushedChars_.
| UartStream::~UartStream | ( | ) |
Destructor.
References bufferSize_, close(), isReadable(), and pushedChars_.
|
private |
|
staticprivate |
| size_t UartStream::canReadUntil | ( | const unsigned char | match | ) |
References bufferPos_, fillInBuffer(), isReadable(), and pushedChars_.
Referenced by AcousticModem_Benthos_ATM900::clearUserPrompt(), DAT::clearUserPrompt(), NAL9602::cmdMode(), NAL9602::fillBuffer(), NAL9602::getMTQueueSignalStrength(), NAL9602::getReceivedSignalStrength(), BPC1::menusInitialized(), AcousticModem_Benthos_ATM900::readAndParseResponses(), DAT::readAndParseResponses(), Rowe_600::readEnsemble(), DVL_micro::readNQ1(), NAL9602::requestGSV(), Batt_Ocean_Server::run(), ISUS::runnable(), Aanderaa_O2::runnable(), CANONSampler::runnable(), VemcoVR2C::runnable(), CANONSampler::sampleStatus(), NAL9602::sendingVerify(), NAL9602::sessionMTQueueVerify(), Aanderaa_O2::starting(), ISUS::starting(), AcousticModem_Benthos_ATM900::starting(), and DAT::starting().
| size_t UartStream::canReadUntil | ( | const char * | match, |
| int | matchLen = 0, |
||
| int | maxCheck = 0 |
||
| ) |
References bufferPos_, bufferSize_, fillInBuffer(), isReadable(), and pushedChars_.
| size_t UartStream::canReadUntil | ( | const unsigned char * | match, |
| int | matchLen = 0, |
||
| int | maxCheck = 0 |
||
| ) |
References bufferPos_, bufferSize_, fillInBuffer(), isReadable(), and pushedChars_.
| UartStream & UartStream::close | ( | ) |
References lastError_, PORT_NOT_OPEN, and serPortFd_.
Referenced by openAtBaudrate(), ElevatorServo::pause(), MassServo::pause(), Aanderaa_O2::pause(), DVL_micro::pause(), BuoyancyServo::pause(), RudderServo::pause(), Turbulence_NPS::pause(), PNI_TCM::pause(), AHRS_3DMGX3::pause(), ThrusterServo::pause(), CTD_NeilBrown::pause(), AHRS_sp3003D::pause(), VemcoVR2C::start(), ISUS::start(), Aanderaa_O2::start(), CANONSampler::start(), WetLabsBB2FL::start(), SCPI::stop(), VemcoVR2C::stop(), ISUS::stop(), CANONSampler::stop(), Rowe_600::stop(), DVL_micro::stopped(), ElevatorServo::stopped(), MassServo::stopped(), RudderServo::stopped(), BuoyancyServo::stopped(), AcousticModem_Benthos_ATM900::stopped(), WetLabsBB2FL::stopped(), Turbulence_NPS::stopped(), DAT::stopped(), ThrusterServo::stopped(), PNI_TCM::stopped(), AHRS_3DMGX3::stopped(), CTD_NeilBrown::stopped(), AHRS_sp3003D::stopped(), BPC1::stopped(), NAL9602::stopped(), Batt_Ocean_Server::uninitialize(), DVL_micro::uninitialize(), CANONSampler::uninitialize(), Aanderaa_O2::uninitialize(), VemcoVR2C::uninitialize(), ISUS::uninitialize(), AcousticModem_Benthos_ATM900::uninitialize(), WetLabsBB2FL::uninitialize(), Turbulence_NPS::uninitialize(), DAT::uninitialize(), PNI_TCM::uninitialize(), AHRS_3DMGX3::uninitialize(), CTD_NeilBrown::uninitialize(), AHRS_sp3003D::uninitialize(), BPC1::uninitialize(), Rowe_600::uninitialize(), NAL9602::uninitialize(), and ~UartStream().
| size_t UartStream::dataAvailable | ( | ) |
References bufferPos_, fillInBuffer(), and isReadable().
Referenced by AcousticModem_Benthos_ATM900::paused(), Rowe_600::readEnsemble(), PNI_TCM::receiveGetDataResp(), NAL9602::requestFix(), AcousticModem_Benthos_ATM900::runnable(), BPC1::runnable(), NAL9602::sendingTransmit(), AcousticModem_Benthos_ATM900::starting(), DVL_micro::starting(), DAT::starting(), and PNI_TCM::starting().
| size_t UartStream::dataBuffered | ( | ) |
References bufferPos_, and isReadable().
Referenced by Rowe_600::readEnsemble().
|
staticprivate |
| void UartStream::disableUART | ( | void | ) |
References NOT_UART, LPC3Reg::P0OutpClrPhys_, UART1_SHUTDOWN, UART1_TX0, UART2_SHUTDOWN, UART2_TX1, UART3_S1, UART3_SHUTDOWN, UART4_S2, UART4_SHUTDOWN, UART5_S0, UART5_SHUTDOWN, UART6_S3, UART7_SHUTDOWN, UART7_TX2, UART_A0, UART_A1, UART_A2, UART_A3, UART_A4, UART_A5, UART_A6, UART_A7, UART_B0, UART_B1, UART_B2, UART_B3, UART_B4, UART_B5, UART_B6, UART_B7, and uartId_.
Referenced by ESPComponent::stopPPP(), Batt_Ocean_Server::uninitialize(), DVL_micro::uninitialize(), and NAL9602::uninitialize().
| void UartStream::enableUART | ( | void | ) |
References NOT_UART, LPC3Reg::P0OutpSetPhys_, UART1_SHUTDOWN, UART1_TX0, UART2_SHUTDOWN, UART2_TX1, UART3_S1, UART3_SHUTDOWN, UART4_S2, UART4_SHUTDOWN, UART5_S0, UART5_SHUTDOWN, UART6_S3, UART7_SHUTDOWN, UART7_TX2, UART_A0, UART_A1, UART_A2, UART_A3, UART_A4, UART_A5, UART_A6, UART_A7, UART_B0, UART_B1, UART_B2, UART_B3, UART_B4, UART_B5, UART_B6, UART_B7, and uartId_.
Referenced by Batt_Ocean_Server::initialize(), DVL_micro::resume(), CANONSampler::start(), VemcoVR2C::start(), AcousticModem_Benthos_ATM900::start(), DAT::start(), DVL_micro::start(), BPC1::start(), NAL9602::start(), and ESPComponent::startPPP().
|
inlinevirtual |
| const char * UartStream::errorString | ( | ) |
References BAD_BAUD_RATE_FOR_PORT, BAD_PARAMETERS_FOR_PORT, BUFFER_FULL, CANNOT_GET_DEVICE_SETTINGS, CANNOT_OPEN_SERIAL_PORT, lastError_, OK, PORT_NOT_OPEN, TIMEOUT, and WRITE_CHAR_LOST.
Referenced by NAL9602::fillBuffer(), NAL9602::getFix(), NAL9602::getMTQueueSignalStrength(), EZServoServo::getPosition(), NAL9602::getReceivedSignalStrength(), EZServoServo::getVelocityCmd(), BuoyancyServo::initBuoyancy(), ElevatorServo::initElevator(), Batt_Ocean_Server::initialize(), EZServoServo::initializeStart(), NAL9602::initiateSession(), RudderServo::initRudder(), ThrusterServo::initThruster(), EZServoServo::isCommunicating(), NAL9602::parseGSV(), BPC1::parseWriteDataA(), BPC1::parseWriteDataB(), AHRS_sp3003D::readAccelVecBin(), AcousticModem_Benthos_ATM900::readAndParseResponses(), DAT::readAndParseResponses(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), Rowe_600::readEnsemble(), AHRS_sp3003D::readMagneticsBin(), DVL_micro::readNQ1(), AHRS_3DMGX3::readTemperature(), AHRS_3DMGX3::readTransducers(), Turbulence_NPS::receive(), CTD_NeilBrown::receive(), PNI_TCM::receiveGetDataResp(), AHRS_sp3003D::receiveHeadingMagBin(), AHRS_sp3003D::receivePitchRollBin(), AHRS_sp3003D::receiveTransducers(), DVL_micro::resume(), MassServo::resume(), ElevatorServo::resume(), RudderServo::resume(), BuoyancyServo::resume(), Turbulence_NPS::resume(), AHRS_3DMGX3::resume(), ThrusterServo::resume(), PNI_TCM::resume(), CTD_NeilBrown::resume(), AHRS_sp3003D::resume(), MassServo::resuming(), NAL9602::retrieveAndQueueIncoming(), MassServo::runnable(), ElevatorServo::runnable(), VemcoVR2C::runnable(), RudderServo::runnable(), BuoyancyServo::runnable(), WetLabsBB2FL::runnable(), ThrusterServo::runnable(), SCPI::start(), ISUS::start(), VemcoVR2C::start(), CANONSampler::start(), AcousticModem_Benthos_ATM900::start(), WetLabsBB2FL::start(), DAT::start(), Turbulence_NPS::start(), PNI_TCM::start(), AHRS_3DMGX3::start(), DVL_micro::start(), CTD_NeilBrown::start(), AHRS_sp3003D::start(), BPC1::start(), Rowe_600::start(), NAL9602::start(), MassServo::starting(), ElevatorServo::starting(), BuoyancyServo::starting(), RudderServo::starting(), WetLabsBB2FL::starting(), PNI_TCM::starting(), ThrusterServo::starting(), AHRS_sp3003D::tryUartComms(), NAL9602::verifySessionXmit(), and MassServo::waitForHoming().
| void UartStream::fillInBuffer | ( | ) |
References bufferPos_, bufferSize_, InStream::bytesRead(), pushedChars_, read(), and serPortFd_.
Referenced by canReadUntil(), dataAvailable(), flush(), read(), and serGetChar().
| UartStream & UartStream::flush | ( | int | num = -1 | ) |
Flushes any characters out of the buffer until there are no more characters, or if num is positive, until the specified number of characters are flushed.
References bufferPos_, bufferSize_, fillInBuffer(), InStream::incBytesRead(), NOT_UART, serGetChar(), SLEEP_TIME, Timespan::sleepFor(), uartId_, Timespan::ZERO_TIMESPAN, and InStream::zeroBytesRead().
Referenced by NAL9602::clearMOBuffer(), DVL_micro::endPing(), NAL9602::fillBuffer(), NAL9602::getFix(), NAL9602::getMTQueueSignalStrength(), NAL9602::getReceivedSignalStrength(), BuoyancyServo::initBuoyancy(), Batt_Ocean_Server::initialize(), NAL9602::initiateSession(), ThrusterServo::initThruster(), Rowe_600::pause(), BPC1::pausing(), AHRS_sp3003D::readAccelVecBin(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), AHRS_sp3003D::readMagneticsBin(), AHRS_3DMGX3::readTemperature(), AHRS_3DMGX3::readTransducers(), PNI_TCM::receiveGetDataResp(), NAL9602::requestFix(), NAL9602::requestGSV(), AHRS_sp3003D::requestHeadingMagBin(), AHRS_sp3003D::requestPitchRollBin(), AHRS_sp3003D::requestTransducers(), DVL_micro::resume(), BPC1::resume(), Rowe_600::resume(), PNI_TCM::resuming(), NAL9602::retrieveAndQueueIncoming(), SCPI::runnable(), BPC1::runnable(), NAL9602::sendingFillBuffer(), NAL9602::sendingVerify(), SCPI::start(), AcousticModem_Benthos_ATM900::start(), DAT::start(), DVL_micro::start(), BPC1::start(), Rowe_600::start(), ISUS::starting(), AcousticModem_Benthos_ATM900::starting(), PNI_TCM::starting(), BPC1::starting(), DVL_micro::startPing(), AHRS_sp3003D::tryUartComms(), BuoyancyServo::uninitialize(), and NAL9602::waking().
| UartStream & UartStream::flushCRLF | ( | ) |
Flushes CR and LF characters out of the buffer until there are no more characters.
May need to "push" a character back onto the stream if necessary.
References bufferPos_, InStream::incBytesRead(), pushedChars_, serGetChar(), and Timespan::ZERO_TIMESPAN.
Referenced by NAL9602::clearMOBuffer(), AcousticModem_Benthos_ATM900::clearUserPrompt(), DAT::clearUserPrompt(), NAL9602::getFix(), EZServoServo::getPosition(), EZServoServo::getVelocityCmd(), BuoyancyServo::initBuoyancy(), ElevatorServo::initElevator(), Batt_Ocean_Server::initialize(), NAL9602::initiateSession(), RudderServo::initRudder(), ThrusterServo::initThruster(), EZServoServo::isCommunicating(), NAL9602::parseGSV(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), CTD_NeilBrown::receive(), MassServo::resuming(), ElevatorServo::runnable(), MassServo::runnable(), BuoyancyServo::runnable(), VemcoVR2C::runnable(), ISUS::runnable(), RudderServo::runnable(), ThrusterServo::runnable(), SCPI::starting(), ElevatorServo::starting(), MassServo::starting(), RudderServo::starting(), BuoyancyServo::starting(), AcousticModem_Benthos_ATM900::starting(), DAT::starting(), and ThrusterServo::starting().
|
inline |
References lastError_.
Referenced by Turbulence_NPS::receive(), CTD_NeilBrown::receive(), WetLabsBB2FL::runnable(), and WetLabsBB2FL::starting().
|
inlinevirtual |
|
inline |
References lastError_, and OK.
Referenced by NAL9602::fillBuffer(), NAL9602::getFix(), NAL9602::getMTQueueSignalStrength(), EZServoServo::getPosition(), NAL9602::getReceivedSignalStrength(), EZServoServo::getVelocityCmd(), BuoyancyServo::initBuoyancy(), ElevatorServo::initElevator(), Batt_Ocean_Server::initialize(), EZServoServo::initializeStart(), NAL9602::initiateSession(), RudderServo::initRudder(), ThrusterServo::initThruster(), EZServoServo::isCommunicating(), NAL9602::parseGSV(), BPC1::parseWriteDataA(), BPC1::parseWriteDataB(), AHRS_sp3003D::readAccelVecBin(), AcousticModem_Benthos_ATM900::readAndParseResponses(), DAT::readAndParseResponses(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), Rowe_600::readEnsemble(), AHRS_sp3003D::readMagneticsBin(), DVL_micro::readNQ1(), AHRS_3DMGX3::readTemperature(), AHRS_3DMGX3::readTransducers(), Turbulence_NPS::receive(), CTD_NeilBrown::receive(), PNI_TCM::receiveGetDataResp(), AHRS_sp3003D::receiveHeadingMagBin(), AHRS_sp3003D::receivePitchRollBin(), AHRS_sp3003D::receiveTransducers(), DVL_micro::resume(), MassServo::resume(), ElevatorServo::resume(), RudderServo::resume(), BuoyancyServo::resume(), Turbulence_NPS::resume(), AHRS_3DMGX3::resume(), ThrusterServo::resume(), PNI_TCM::resume(), CTD_NeilBrown::resume(), AHRS_sp3003D::resume(), MassServo::resuming(), NAL9602::retrieveAndQueueIncoming(), MassServo::runnable(), ElevatorServo::runnable(), RudderServo::runnable(), VemcoVR2C::runnable(), BuoyancyServo::runnable(), WetLabsBB2FL::runnable(), ThrusterServo::runnable(), SCPI::start(), VemcoVR2C::start(), ISUS::start(), CANONSampler::start(), AcousticModem_Benthos_ATM900::start(), WetLabsBB2FL::start(), DAT::start(), Turbulence_NPS::start(), DVL_micro::start(), PNI_TCM::start(), AHRS_3DMGX3::start(), CTD_NeilBrown::start(), AHRS_sp3003D::start(), BPC1::start(), Rowe_600::start(), NAL9602::start(), SCPI::starting(), MassServo::starting(), ElevatorServo::starting(), BuoyancyServo::starting(), RudderServo::starting(), WetLabsBB2FL::starting(), PNI_TCM::starting(), ThrusterServo::starting(), AHRS_sp3003D::tryUartComms(), NAL9602::verifySessionXmit(), and MassServo::waitForHoming().
|
private |
References NOT_UART, LPC3Reg::PioMuxClrPhys_, LPC3Reg::PioMuxSetPhys_, LPC3Reg::U4ClkPhys_, LPC3Reg::U4DllPhys_, UART1_TX0, UART2_TX1, UART3_S1, UART4_S2, UART5_S0, UART6_S3, UART7_TX2, UART_A0, UART_A1, UART_A2, UART_A3, UART_A4, UART_A5, UART_A6, UART_A7, UART_B0, UART_B1, UART_B2, UART_B3, UART_B4, UART_B5, UART_B6, UART_B7, LPC3Reg::UartClkCtrl_, LPC3Reg::UartClkModePhys_, and LPC3Reg::UartCtrlPhys_.
Referenced by openAtBaudrate().
|
inlinevirtual |
indicates whether the stream can actually be read from.
Implements InStream.
References serPortFd_.
Referenced by canReadUntil(), dataAvailable(), dataBuffered(), eof(), ISUS::start(), VemcoVR2C::start(), Aanderaa_O2::start(), CANONSampler::start(), WetLabsBB2FL::start(), DVL_micro::stopped(), ElevatorServo::stopped(), MassServo::stopped(), RudderServo::stopped(), BuoyancyServo::stopped(), AcousticModem_Benthos_ATM900::stopped(), WetLabsBB2FL::stopped(), DAT::stopped(), Turbulence_NPS::stopped(), AHRS_3DMGX3::stopped(), ThrusterServo::stopped(), PNI_TCM::stopped(), CTD_NeilBrown::stopped(), AHRS_sp3003D::stopped(), BPC1::stopped(), NAL9602::stopped(), and ~UartStream().
|
inlinevirtual |
indicates whether the stream can actually be written to.
Implements OutStream.
References serPortFd_.
|
staticprivate |
References StrValue::asString(), and Slate::ReadOnce().
|
inline |
References defaultBaudrate_, and openAtBaudrate().
Referenced by Batt_Ocean_Server::initialize(), EZServoServo::initializeStart(), openAtBaudrate(), DVL_micro::resume(), ElevatorServo::resume(), MassServo::resume(), BuoyancyServo::resume(), RudderServo::resume(), Turbulence_NPS::resume(), PNI_TCM::resume(), AHRS_3DMGX3::resume(), ThrusterServo::resume(), CTD_NeilBrown::resume(), AHRS_sp3003D::resume(), SCPI::start(), VemcoVR2C::start(), Aanderaa_O2::start(), CANONSampler::start(), ISUS::start(), AcousticModem_Benthos_ATM900::start(), WetLabsBB2FL::start(), Turbulence_NPS::start(), DAT::start(), DVL_micro::start(), AHRS_3DMGX3::start(), PNI_TCM::start(), CTD_NeilBrown::start(), AHRS_sp3003D::start(), BPC1::start(), Rowe_600::start(), and NAL9602::start().
| UartStream & UartStream::openAtBaudrate | ( | UartStream::Baudrate | baud | ) |
References Timespan::asFloat(), BAD_BAUD_RATE_FOR_PORT, BAD_PARAMETERS_FOR_PORT, BaudToSpeed(), blocking_, bufferPos_, CANNOT_GET_DEVICE_SETTINGS, CANNOT_OPEN_SERIAL_PORT, close(), defaultStartTimeout_, Syslog::INFO, initializePort(), lastError_, logger_, NOT_UART, OK, open(), serPortFd_, Logger::syslog(), uartId_, and uartToDevice().
Referenced by open().
|
virtual |
reads num bytes from stream to the buffer
Implements InStream.
References betweenTimeout_, bufferPos_, InStream::bytesRead(), Timestamp::elapsed(), fillInBuffer(), InStream::getBytesRead(), InStream::incBytesRead(), lastError_, Timestamp::Now(), OK, pushedChars_, SLEEP_TIME, Timespan::sleepFor(), startTimeout_, TIMEOUT, and InStream::zeroBytesRead().
Referenced by NAL9602::fillBuffer(), fillInBuffer(), NAL9602::getMTQueueSignalStrength(), NAL9602::getReceivedSignalStrength(), BPC1::parseWriteDataA(), BPC1::parseWriteDataB(), Rowe_600::pause(), AHRS_sp3003D::readAccelVecBin(), Rowe_600::readEnsemble(), AHRS_sp3003D::readMagneticsBin(), AHRS_3DMGX3::readTemperature(), AHRS_3DMGX3::readTransducers(), Turbulence_NPS::receive(), PNI_TCM::receiveGetDataResp(), AHRS_sp3003D::receiveHeadingMagBin(), AHRS_sp3003D::receivePitchRollBin(), MassServo::resuming(), Rowe_600::resuming(), NAL9602::retrieveAndQueueIncoming(), MassServo::runnable(), ElevatorServo::runnable(), RudderServo::runnable(), Aanderaa_O2::runnable(), BuoyancyServo::runnable(), serGetChar(), Aanderaa_O2::starting(), AcousticModem_Benthos_ATM900::starting(), DAT::starting(), and PNI_TCM::starting().
|
inline |
Fills buffer until: buffer size is exceeded, CR, LF, or ETX character is received, or the serial timeout has expired.
References readLines().
Referenced by EZServoServo::getPosition(), EZServoServo::getVelocityCmd(), BuoyancyServo::initBuoyancy(), ElevatorServo::initElevator(), Batt_Ocean_Server::initialize(), NAL9602::initiateSession(), RudderServo::initRudder(), ThrusterServo::initThruster(), EZServoServo::isCommunicating(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), DVL_micro::readNQ1(), CTD_NeilBrown::receive(), AHRS_sp3003D::receiveTransducers(), MassServo::resuming(), ElevatorServo::runnable(), MassServo::runnable(), RudderServo::runnable(), ISUS::runnable(), VemcoVR2C::runnable(), BuoyancyServo::runnable(), ThrusterServo::runnable(), SCPI::starting(), ElevatorServo::starting(), MassServo::starting(), BuoyancyServo::starting(), RudderServo::starting(), ThrusterServo::starting(), and AHRS_sp3003D::tryUartComms().
| UartStream & UartStream::readLines | ( | char * | buf, |
| size_t | bufsize, | ||
| size_t | lines | ||
| ) |
Fills buffer with given number of lines (CR/LF) until buffer size is exceeded or timeout has expired or ETX character is received.
References BUFFER_FULL, debug_, InStream::getBytesRead(), InStream::incBytesRead(), lastError_, OK, serGetChar(), startTimeout_, TIMEOUT, and InStream::zeroBytesRead().
Referenced by NAL9602::getFix(), and readLine().
|
inline |
Referenced by NAL9602::clearMOBuffer(), AcousticModem_Benthos_ATM900::clearUserPrompt(), DAT::clearUserPrompt(), Batt_Ocean_Server::initialize(), NAL9602::initiateSession(), NAL9602::parseGSV(), AcousticModem_Benthos_ATM900::readAndParseResponses(), DAT::readAndParseResponses(), Batt_Ocean_Server::readDataA(), Batt_Ocean_Server::readDataB(), Turbulence_NPS::receive(), CTD_NeilBrown::receive(), NAL9602::retrieveAndQueueIncoming(), CANONSampler::runnable(), WetLabsBB2FL::runnable(), CANONSampler::sampleStatus(), AcousticModem_Benthos_ATM900::starting(), WetLabsBB2FL::starting(), DAT::starting(), and NAL9602::verifySessionXmit().
| UartStream & UartStream::readUntil | ( | char * | buf, |
| size_t | num, | ||
| const char * | match, | ||
| unsigned int | matchLen, | ||
| bool | flushUntil = false |
||
| ) |
| UartStream & UartStream::readUntil | ( | char * | buf, |
| size_t | num, | ||
| const unsigned char * | match, | ||
| unsigned int | matchLen, | ||
| bool | flushUntil = false |
||
| ) |
|
inline |
|
private |
References betweenTimeout_, bufferPos_, bufferSize_, Timestamp::elapsed(), fillInBuffer(), Timespan::INVALID_TIMESPAN, Timestamp::Now(), pushedChars_, read(), serPortFd_, SLEEP_TIME, and Timespan::sleepFor().
Referenced by flush(), flushCRLF(), readLines(), and readUntil().
|
inline |
References debug_.
|
inline |
| const char * UartStream::uartIdToString | ( | UartId | uart | ) |
|
private |
| void UartStream::waitForBufferEmpty | ( | ) |
References Timestamp::elapsed(), LPC3Reg::Hsu2Level_, NOT_UART, Timestamp::Now(), SLEEP_TIME, Timespan::sleepFor(), LPC3Reg::U3LsrPhys_, LPC3Reg::U4LsrPhys_, LPC3Reg::U5LsrPhys_, LPC3Reg::U6LsrPhys_, UART1_TX0, UART2_TX1, UART3_S1, UART4_S2, UART5_S0, UART6_S3, UART7_TX2, UART_A0, UART_A1, UART_A2, UART_A3, UART_A4, UART_A5, UART_A6, UART_A7, UART_B0, UART_B1, UART_B2, UART_B3, UART_B4, UART_B5, UART_B6, UART_B7, and uartId_.
Referenced by AHRS_3DMGX3::readTemperature().
|
virtual |
If length is unspecified, strlen is used to determine the length.
Implements OutStream.
References debug_, lastError_, serPortFd_, uartId_, and WRITE_CHAR_LOST.
Referenced by NAL9602::fillBuffer(), PNI_TCM::resuming(), and PNI_TCM::starting().
|
private |
Referenced by read(), and serGetChar().
|
private |
Referenced by openAtBaudrate().
|
private |
Referenced by canReadUntil(), dataAvailable(), dataBuffered(), fillInBuffer(), flush(), flushCRLF(), openAtBaudrate(), read(), and serGetChar().
|
private |
Referenced by canReadUntil(), fillInBuffer(), flush(), serGetChar(), UartStream(), and ~UartStream().
|
private |
Referenced by readLines(), setDebug(), and write().
|
private |
Referenced by open().
|
private |
Referenced by openAtBaudrate(), and resetStartTimeout().
|
private |
Referenced by uartIdToString(), and uartToDevice().
|
private |
Referenced by close(), errorString(), getError(), hasError(), openAtBaudrate(), read(), readLines(), readUntil(), and write().
|
private |
Referenced by openAtBaudrate().
|
private |
Referenced by UartStream().
|
private |
Referenced by canReadUntil(), fillInBuffer(), flushCRLF(), read(), serGetChar(), UartStream(), and ~UartStream().
|
private |
Referenced by close(), fillInBuffer(), isReadable(), isWritable(), openAtBaudrate(), serGetChar(), and write().
|
staticprivate |
A 10 millisecond sleep.
Referenced by flush(), read(), serGetChar(), and waitForBufferEmpty().
|
private |
Referenced by read(), readLines(), readUntil(), resetStartTimeout(), and setStartTimeout().
|
private |
Referenced by disableUART(), enableUART(), flush(), getName(), openAtBaudrate(), waitForBufferEmpty(), and write().