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

Method serial_read

serial_port/serial_port.cpp:510–543  ·  view source on GitHub ↗

---------------------------------------------------------*\ | serial_read | | Reads bytes from the serial port into | | Returns the number of bytes actually read | | If less than bytes are available, it will read| | all available bytes | \*----------------------------

Source from the content-addressed store, hash-verified

508| all available bytes |
509\*---------------------------------------------------------*/
510int serial_port::serial_read(char * buffer, int length)
511{
512 /*-----------------------------------------------------*\
513 | Windows-specific code path for serial read |
514 \*-----------------------------------------------------*/
515#ifdef _WIN32
516 DWORD bytesread;
517 ReadFile(file_descriptor, buffer, length, &bytesread, NULL);
518 return bytesread;
519#endif
520
521 /*-----------------------------------------------------*\
522 | Linux-specific code path for serial read |
523 \*-----------------------------------------------------*/
524#ifdef __linux__
525 int bytesread;
526 bytesread = read(file_descriptor, buffer, length);
527 return bytesread;
528#endif
529
530 /*-----------------------------------------------------*\
531 | MacOS-specific code path for serial read |
532 \*-----------------------------------------------------*/
533#ifdef __APPLE__
534 int bytesread;
535 bytesread = read(file_descriptor, buffer, length);
536 return bytesread;
537#endif
538
539 /*-----------------------------------------------------*\
540 | Return 0 on unsupported platforms |
541 \*-----------------------------------------------------*/
542 return 0;
543}
544
545/*---------------------------------------------------------*\
546| serial_write |

Callers 3

GetLEDsOnChannelMethod · 0.80
FanBusInterfaceMethod · 0.80
readMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected