42 this->m_allocationSize = allocationSize;
44 this->m_device = device;
53 fd =
::open(device, O_RDWR | O_NOCTTY);
67 stat = tcgetattr(fd, &cfg);
94 stat = tcsetattr(fd, TCSANOW, &cfg);
107 stat = tcgetattr(fd, &t);
117 t.c_cflag |= CRTSCTS;
119 stat = tcsetattr(fd, TCSANOW, &t);
149 #if defined TGT_OS_TYPE_LINUX 157 relayRate = B1000000;
160 relayRate = B1152000;
163 relayRate = B1500000;
166 relayRate = B2000000;
170 relayRate = B2500000;
175 relayRate = B3000000;
180 relayRate = B3500000;
185 relayRate = B4000000;
190 FW_ASSERT(0, static_cast<FwAssertArgType>(baud));
194 struct termios newtio;
196 stat = tcgetattr(fd, &newtio);
220 newtio.c_cflag |= CS8 | CLOCAL | CREAD;
224 newtio.c_cflag |= (PARENB | PARODD);
227 newtio.c_cflag |= PARENB;
230 newtio.c_cflag &=
static_cast<unsigned int>(~PARENB);
238 stat = cfsetispeed(&newtio, static_cast<speed_t>(relayRate));
246 stat = cfsetospeed(&newtio, static_cast<speed_t>(relayRate));
261 newtio.c_iflag = INPCK;
264 (void)tcflush(fd, TCIFLUSH);
267 stat = tcsetattr(fd, TCSANOW, &newtio);
286 if (this->m_fd != -1) {
287 (void)close(this->m_fd);
297 if (this->m_fd == -1 || serBuffer.
getData() ==
nullptr || serBuffer.
getSize() == 0) {
300 unsigned char *data = serBuffer.
getData();
305 if (-1 == stat || stat != xferSize) {
318 void LinuxUartDriver ::serialReadTaskEntry(
void* ptr) {
322 while (!comp->m_quitReadThread) {
323 Fw::Buffer buff = comp->allocate_out(0,comp->m_allocationSize);
326 if (buff.
getData() ==
nullptr) {
328 comp->log_WARNING_HI_NoBuffers(_arg);
330 comp->recv_out(0, buff, status);
340 while ((stat == 0) && !comp->m_quitReadThread) {
341 stat =
static_cast<int>(::read(comp->m_fd, buff.
getData(), buff.
getSize()));
350 comp->log_WARNING_HI_ReadError(_arg, stat);
352 }
else if (stat > 0) {
353 buff.
setSize(static_cast<U32>(stat));
358 comp->recv_out(0, buff, status);
364 Os::Task::Arguments arguments(task, serialReadTaskEntry,
this, priority, stackSize, cpuAffinity);
370 this->m_quitReadThread =
true;
374 return m_readTask.
join();
static Status delay(Fw::TimeInterval interval)
delay the current task
bool isConnected_deallocate_OutputPort(FwIndexType portNum)
Status associated with the received data.
PlatformIntType NATIVE_INT_TYPE
Status start(const Arguments &arguments) override
start the task
Auto-generated base for LinuxUartDriver component.
Receive worked as expected.
void log_WARNING_HI_WriteError(const Fw::StringBase &device, I32 error)
Receive error occurred retrying may succeed.
void start(Os::Task::ParamType priority=Os::Task::TASK_DEFAULT, Os::Task::ParamType stackSize=Os::Task::TASK_DEFAULT, Os::Task::ParamType cpuAffinity=Os::Task::TASK_DEFAULT)
void deallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port deallocate.
message sent/received okay
Status join() override
block until the task has ended
void quitReadThread()
Quit thread.
void log_WARNING_HI_OpenError(const Fw::StringBase &device, I32 error, const Fw::StringBase &name) const
void log_ACTIVITY_HI_PortOpened(const Fw::StringBase &device) const
FwSizeType ParamType
backwards-compatible parameter type
LinuxUartDriver(const char *const compName)
Status returned by the send call.
UartBaudRate
Configure UART parameters.
C++ header for working with basic fprime types.
bool open(const char *const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, U32 allocationSize)
void ready_out(FwIndexType portNum)
Invoke output port ready.
bool isConnected_ready_OutputPort(FwIndexType portNum)
Os::Task::Status join()
Join thread.
Send error occurred retrying may succeed.