|
C++ serial port program problem
I have borrowed a simple program that is supposed to read from a file and
output to the screen. Simply pass the file to it at the command line. I am
pointing it at a serial port, instead of a regular file and I get different results when I run it from the old C++ compiler instead
of the new. Any help is VERY VERY appreciated. I am not sure if I am
simply not using the new standard appropriately, or if my system is
configured incorrectly, or the compiler.
Here are the specifics:
System: Suse Linux 9.0 (i586) Kernel 2.4.21-243-smp4G
Old compiler: g++ using gcc version 2.95.3 20010315 (release)
New compiler: g++ using gcc version 3.3.3 (SuSE Linux)
to run command line: a.out /dev/ttyS0
What happens:
When I compile under the old compiler it works fine, I send info down the
port, it reads it and displays it on my screen.
When I compile under the new compiler, it simply blocks, no info is read,
the program never proceeds past the first get().
Here is the code:
#include <fstream>
#include <iostream>
using namespace std;
int main (int argc, char* argv[])
{
ifstream file;
for (int i=1; i<argc; ++i) {
file.open(argv[i]);
char c;
while (file.get(c)) {
cout.put(c);
}
file.clear();
file.close();
}
}
|