MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / serial_write

Method serial_write

serial_port/serial_port.cpp:553–590  ·  view source on GitHub ↗

---------------------------------------------------------*\ | 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

Source from the content-addressed store, hash-verified

551| read past <buffer> and may cause a segfault |
552\*---------------------------------------------------------*/
553int 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 |

Callers 12

SendDirectMethod · 0.80
GetLEDsOnChannelMethod · 0.80
SendPacketMethod · 0.80
SetLEDsAdalightMethod · 0.80
SetLEDsTPM2Method · 0.80
SetLEDsMethod · 0.80
DeviceUpdateLEDsMethod · 0.80
FanBusInterfaceMethod · 0.80
readMethod · 0.80
writeMethod · 0.80
process_queueMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected