~dcow90/myro-c++/extern-c

« back to all changes in this revision

Viewing changes to src/Scribbler.cpp

  • Committer: John Hoare
  • Date: 2011-03-09 19:12:27 UTC
  • Revision ID: john@johnami.com-20110309191227-qmifg4uj5x0w3mtj
Added a way to hard-code the connection into the connect() functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
    delete con;
139
139
}
140
140
 
141
 
int Scribbler::connect() {
142
 
    std::string device;
143
 
    std::cout << "Please enter the comport: ";
144
 
    std::cin >> device;
145
 
    std::cin.ignore();
 
141
int Scribbler::connect(std::string port) {
 
142
    if ( port == "" ){
 
143
        std::cout << "Please enter the comport: ";
 
144
        std::cin >> port;
 
145
        std::cin.ignore();
 
146
    } 
 
147
    else{
 
148
        std::cout << "Connecting to port: " << port << std::endl;
 
149
    }
146
150
    con = new serial(38400, 1);
147
 
    int status = con->connect(device.c_str());
 
151
    int status = con->connect(port.c_str());
148
152
    if(status < 0) {
149
 
        //fprintf(stderr, "Failed to connect to %s\n", device.c_str());
150
 
        std::cerr << "Failed to connect to " << device << std::endl;
 
153
        //fprintf(stderr, "Failed to connect to %s\n", port.c_str());
 
154
        std::cerr << "Failed to connect to " << port << std::endl;
151
155
        delete con;
152
156
        con = NULL;
153
157
        return -1;