---------------------------------------------------------*\ | serial_write | | Writes bytes to the serial port from | | Returns the number of bytes actually written | | Does not check for null-termination, so if is | | greater than the number of bytes in , it will | | read past and ma
| 551 | | read past <buffer> and may cause a segfault | |
| 552 | \*---------------------------------------------------------*/ |
| 553 | int serial_port::serial_write(char * buffer, int length) |
| 554 | { |
| 555 | /*-----------------------------------------------------*\ |
| 556 | | Windows-specific code path for serial write | |
| 557 | \*-----------------------------------------------------*/ |
| 558 | #ifdef _WIN32 |
| 559 | DWORD byteswritten; |
| 560 | WriteFile(file_descriptor, buffer, length, &byteswritten, NULL); |
| 561 | return byteswritten; |
| 562 | #endif |
| 563 | |
| 564 | /*-----------------------------------------------------*\ |
| 565 | | Linux-specific code path for serial write | |
| 566 | \*-----------------------------------------------------*/ |
| 567 | #ifdef __linux__ |
| 568 | int byteswritten; |
| 569 | tcdrain(file_descriptor); |
| 570 | byteswritten = write(file_descriptor, buffer, length); |
| 571 | tcdrain(file_descriptor); |
| 572 | return byteswritten; |
| 573 | #endif |
| 574 | |
| 575 | /*-----------------------------------------------------*\ |
| 576 | | MacOS-specific code path for serial write | |
| 577 | \*-----------------------------------------------------*/ |
| 578 | #ifdef __APPLE__ |
| 579 | int byteswritten; |
| 580 | tcdrain(file_descriptor); |
| 581 | byteswritten = write(file_descriptor, buffer, length); |
| 582 | tcdrain(file_descriptor); |
| 583 | return byteswritten; |
| 584 | #endif |
| 585 | |
| 586 | /*-----------------------------------------------------*\ |
| 587 | | Return 0 on unsupported platforms | |
| 588 | \*-----------------------------------------------------*/ |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | /*---------------------------------------------------------*\ |
| 593 | | serial_flush | |
no outgoing calls
no test coverage detected