Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ValRat committed May 21, 2016
2 parents 1f134f0 + e0ce0e7 commit e261619
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/drivers/src/SerialCommunication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SerialCommunication::~SerialCommunication()
void SerialCommunication::readData(int n, char *buf)
{
int i = read(fd, buf, n);
// buf[i] = '\0';
buf[i] = '\0';
return;
}

Expand Down
21 changes: 15 additions & 6 deletions src/drivers/src/gps_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,36 @@ void data_request(char c, char *buffer){
char read_byte;
int i = 0;
while(read_bit(&read_byte)){
*(buffer + i)= read_byte;
buffer[i]= read_byte;
i++;
}
}
cout << buffer;
return;
}


bool read_bit(char *c){
//returns true if next bit is char, false if \n
char *temp;
char temp[2]="\0";
while (temp == "\0"){
link_port.readData(1,temp);
if (*temp == '\n') return false;
else return true;
cout << temp;
if (temp[0] == '\n') return false;
else{
*c = temp[0];
return true;
}
}
}


bool open_port(unsigned int count){
//Attempts to open Serial Port
while( !link_port.connect(BAUD_RATE,(ARDUINO_PORT_NAME + to_string(count
)))&& count < 9){
count++;
}
cout << endl;
//cout << endl;
if (link_port.connect(BAUD_RATE,(ARDUINO_PORT_NAME + to_string(count)))){
cout << "Connected on port" << ARDUINO_PORT_NAME << count << endl;
return true;
Expand Down

0 comments on commit e261619

Please sign in to comment.