MCPcopy Create free account
hub / github.com/crayzeewulf/libserial / testMultiThreadSerialPortReadWrite

Method testMultiThreadSerialPortReadWrite

test/MultiThreadUnitTests.cpp:247–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void
248MultiThreadUnitTests::testMultiThreadSerialPortReadWrite()
249{
250 //
251 // We must open the two serial ports before spawning the threads.
252 // Otherwise, one thread may flush the serial port I/O buffers *after* the
253 // other thread has already sent data.
254 //
255 serialPort1.Open(TEST_SERIAL_PORT_1) ;
256 serialPort1.SetBaudRate(BaudRate::BAUD_115200) ;
257 serialPort1.SetFlowControl(FlowControl::FLOW_CONTROL_HARDWARE) ;
258
259 serialPort2.Open(TEST_SERIAL_PORT_2) ;
260 serialPort2.SetBaudRate(BaudRate::BAUD_115200) ;
261 serialPort2.SetFlowControl(FlowControl::FLOW_CONTROL_HARDWARE) ;
262
263 std::thread serialPort1Thread(&MultiThreadUnitTests::serialPort1ThreadLoop, this) ;
264 std::thread serialPort2Thread(&MultiThreadUnitTests::serialPort2ThreadLoop, this) ;
265
266 serialPort1Thread.join() ;
267 serialPort2Thread.join() ;
268
269 serialPort1.Close() ;
270 serialPort2.Close() ;
271}
272
273TEST_F(MultiThreadUnitTests, testMultiThreadSerialStreamReadWrite)
274{

Callers

nothing calls this directly

Calls 4

OpenMethod · 0.45
SetBaudRateMethod · 0.45
SetFlowControlMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected