From f97139d715d144b00bbd0af166518a5f0ffe9b85 Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Wed, 17 Oct 2018 00:40:13 +1100 Subject: [PATCH] Made baudrate setable --- include/SerialPort.h | 2 +- src/SerialPort.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SerialPort.h b/include/SerialPort.h index 486d686..9612a45 100644 --- a/include/SerialPort.h +++ b/include/SerialPort.h @@ -24,7 +24,7 @@ class SerialPort COMSTAT status; DWORD errors; public: - SerialPort(char *portName); + SerialPort(char *portName, DWORD baudRate = CBR_9600); ~SerialPort(); int readSerialPort(char *buffer, unsigned int buf_size); diff --git a/src/SerialPort.cpp b/src/SerialPort.cpp index 6bc5386..04056ea 100644 --- a/src/SerialPort.cpp +++ b/src/SerialPort.cpp @@ -7,7 +7,7 @@ #include "SerialPort.h" -SerialPort::SerialPort(char *portName) +SerialPort::SerialPort(char *portName, DWORD baudRate) { this->connected = false; @@ -34,7 +34,7 @@ SerialPort::SerialPort(char *portName) printf("failed to get current serial parameters"); } else { - dcbSerialParameters.BaudRate = CBR_9600; + dcbSerialParameters.BaudRate = baudRate; dcbSerialParameters.ByteSize = 8; dcbSerialParameters.StopBits = ONESTOPBIT; dcbSerialParameters.Parity = NOPARITY;