From 434451c5cff415f0f9f68899369b090ed2dbd82d Mon Sep 17 00:00:00 2001 From: Phil Dougherty Date: Tue, 21 Jan 2020 13:01:10 -0600 Subject: [PATCH] added length-specified (in addition to null-terminated) serial put --- wiringPi/wiringSerial.c | 11 +++++++++++ wiringPi/wiringSerial.h | 1 + 2 files changed, 12 insertions(+) diff --git a/wiringPi/wiringSerial.c b/wiringPi/wiringSerial.c index e1587ad..af5c4ed 100644 --- a/wiringPi/wiringSerial.c +++ b/wiringPi/wiringSerial.c @@ -171,6 +171,17 @@ void serialPuts (const int fd, const char *s) } /* + * serialPut: + * Send an n character buffer to the serial port + ********************************************************************************* + */ + +void serialPut (const int fd, const char *s, const int n) +{ + write (fd, s, n) ; +} + +/* * serialPrintf: * Printf over Serial ********************************************************************************* diff --git a/wiringPi/wiringSerial.h b/wiringPi/wiringSerial.h index 430dc73..eb2d8b8 100644 --- a/wiringPi/wiringSerial.h +++ b/wiringPi/wiringSerial.h @@ -29,6 +29,7 @@ extern void serialClose (const int fd) ; extern void serialFlush (const int fd) ; extern void serialPutchar (const int fd, const unsigned char c) ; extern void serialPuts (const int fd, const char *s) ; +extern void serialPut (const int fd, const char *s, const int n) ; extern void serialPrintf (const int fd, const char *message, ...) ; extern int serialDataAvail (const int fd) ; extern int serialGetchar (const int fd) ;