Skip to content

Commit

Permalink
changed all unsigned chars to char for compatiblity with cstrings. Mi…
Browse files Browse the repository at this point in the history
…ght come back to bite me
  • Loading branch information
Dwatkins committed Aug 18, 2017
1 parent e243299 commit 8af2eec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/serial/include/serial/SerialPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ class SerialPort {
int connect (std::string device, int baud);
void disconnect(void);

int sendArray(unsigned char *buffer, int len);
int sendArray(char *buffer, int len);
int sendString(std::string msg);
int getArray (unsigned char *buffer, int len);

void flushPort(flush_type what);
int getArray (char *buffer, int len);

enum flush_type
{
flush_receive = TCIFLUSH,
flush_send = TCIOFLUSH,
flush_both = TCIOFLUSH
};

void flushPort(flush_type what);


};


Expand Down
8 changes: 4 additions & 4 deletions src/serial/src/serial/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ void SerialPort::disconnect(void){
port->close();
}

int SerialPort::sendArray(unsigned char *buffer, int len) {
int SerialPort::sendArray(char *buffer, int len) {
int n = boost::asio::write( *port,
boost::asio::buffer(buffer,len));
return n;
}

int SerialPort::sendString(std::string msg){
std::string tmp = msg + "\n";
SerialPort::sendArray((unsigned char *) tmp.c_str(), tmp.length());
SerialPort::sendArray((char *) tmp.c_str(), tmp.length());
}

int SerialPort::getArray (unsigned char *buffer, int len){
int SerialPort::getArray (char *buffer, int len){
char rcvChar;
int i = 0;
while ( i < len && boost::asio::read( *port, boost::asio::buffer(&rcvChar,1) ) == 1 )
Expand All @@ -41,7 +41,7 @@ int SerialPort::getArray (unsigned char *buffer, int len){

void SerialPort::flushPort(flush_type what)
{
::tcflush(this.lowest_layer().native_handle(), what);
::tcflush(this->port->lowest_layer().native_handle(), what);
}


Expand Down

0 comments on commit 8af2eec

Please sign in to comment.